Will they always be traveling to the right or will they also be going left sometimes as well?
I have an idea how to make it work - and should even work with terrain that's moving up or down, but implementation will be a bit different depending which way the sprites are moving. If always to the right it will be a bit easier, but if they need to go both ways it will be a little more tricky.
Basically you will need an instance variable for each sprite, let's call it "direction". You will then need to set this instance variable to either "up" "down" "left" or "right" (or 1,2,3 or 4) using conditions - then set the movement in the desired direction based on the variable value. You will need a second variable for which *general* direction it's heading (left or right) if the sprites can move both ways. This second variable will act as a secondary condition check.
Pseudo code:
----------------------
[condition]
--- sub event
--- sub event
----------------------
(these vents would handle the "flat" sides of your sprite collision polygon)
[sprite is overlapping terrain at offset.x +1] (or x-1 if moving left)
--- Set Sprite.DirectionVariable to "up"
[sprite is overlapping terrain at offset.y +1]
--- Set Sprite.DirectionVariable to "right" (or left)
[sprite is overlapping terrain at offset.x -1]
--- Set Sprite.DirectionVariable to "down"
(Diagonals would be a little trickier)
[sprite is overlapping terrain at offset.x+1 AND offest.y+1] (upper left corner of your terrain object)
--- Set Sprite.DirectionVariable to "right" (if moving RIGHT, or set to DOWN here if moving LEFT - this is what I meant by it being a bit trickier with multiple directions)
[sprite is overlapping terrain at offset.x-1 AND offest.y+1] (upper right corner)
--- Set Sprite.DirectionVariable to "down" (if moving RIGHT, or set to LEFT here if moving LEFT)
(Then finally the movement itself)
[sprite.DirectionVariable = "up"]
--- Move sprite and angle 270 at speed X (bullet behaviour - customer movement - however you're moving them)
[sprite.DirectionVariable = "right"]
--- Move sprite and angle 0 at speed X
[sprite.DirectionVariable = "down"]
--- Move sprite and angle 90 at speed X
[sprite.DirectionVariable = "left"]
--- Move sprite and angle 180 at speed X
I hope that made sense. I can't make an example right now - but hopefully that helps a little?
~Sol
SoldjahBoy, thank you for the text examples but I'm still quite confused on how to go about implementing this. Can you please provide a example? I'm not too good with working with surfaces currently and things on them but I'm really interested in the movement and terrain that the sprites traverse on.
Again, thank you for taking your time to assist me.