I set up a sort of carnival in my game. One of the attractions is a sort of archery contest: The player at the left, target at the right, obstacles between. I'm trying to set it up to have progressive levels.
Basically, I set it up like this:
At the leftmost side of the area, there's a bow. In front of that is an "arrow" event, with no graphic (so it can't be seen). Triggering the bow (action button) activates a switch that runs the 2nd page of the 'arrow' event, which renders it visible (custom arrow graphic) and sets its move route to Move Right 20 times, as the first level sets the target about that far away.
In addition, I wanted the "camera" to follow the arrow, so I set up a Scroll Map event to coincide with the arrow's activation. This took a while to get right as setting the arrow's route via the "autonomous movement" options or just with a singular Move Right set to repeat caused the scrolling to move faster than the arrow no matter what speed was set. (If not for that, I could manage this all easily...But since each individual move has to be accounted for, it gets tedious)
Anyway, the issue I'm having is progression. I want each successive "level" of this contest to place the target farther away, so I need the arrow to move farther. Is there some way I can have it tack on extra Move commands (about 20 per level) automatically with each level, instead of manually editing the event in every level (there's about 10-20)?
It shouldn't be too hard to use variables, and just add the extra Move commands manually. Of course, your targets will need to be Events rather then Objects if you only want to see one target at a time. Don't forget to reset those variables back to zero when the player leaves or finishes the minigame if you want it to start from the beginning each time they play.
Yup, variables are the key. I guess a compact way to achieve what you want is combining the use of variables and loops.
Here are my thoughts on the thing: (spoiler tags in case you want to try before looking at my solution)
Mechanics: counting from 0 to the current level (or expected number of moves) and move the arrow for every count. You need at least 2 variables: one for the current level, one for counting.
1. Set Var1 = expected number of moves 2. Set Var2 = 0 (initialization of the count) 3. Once you've set the arrow sprite, use a loop:
@> loop -- @> Conditional branch: if Var2 < Var1 ----- @> Set move: arrow, move right (check "Wait for Completion", else your arrow won't reach the expected position...) ----- @> Set Var2 += 1 (add 1 to Var2) -- @> Else (meaning that Var2 = Var1 or Var2 > Var1, which is supposed not to be possible unless there's a bug) ----- @> Break loop -- @> Branch end Repeat above
IMPORTANT NOTE: make sure you reset Var2 either at the end or the beginning of your event.
Now, if you want to follow your arrow, you can use the same system of conditional branch within a loop. However, you need to know from which position/number of moves you need to move the screen. Let's say you want your arrow to be in the center of the screen (y=6) with an initial position at y=2. It means that you need to move 4 tiles before moving the screen. Add the following event commands just before "@>Set Var2 += 1":
----- @> Conditional branch: if Var2 > 3 (in facts, when 0 = move number 1, so when 3 = move number 4) -------- @> Scroll screen: 1 right (speed as you want) ----- @> Branch end
IMPORTANT NOTE: at the end of the screen scrolls, you have to scroll the screen back to the player (I know, what a pain...). So when you want to scroll back, just use the same conditional branch system as above.
@> Set Var2 = 0 @> loop -- @> Conditional branch: if Var2 < Var1 ----- @> Conditional branch: if Var2 > 3 -------- @> Scroll screen : 1 left (adapt the scrolling speed to the arrow speed !) ----- @> Branch end ----- @> Set Var2 += 1 -- @> Else ----- @> Break loop -- @> Branch end Repeat above
I guess this should be it. (I've just tested the code. It must be all okay)
This post has been edited by Onkei69: Apr 14 2012, 04:24 PM