DRIFT ValueOfGlobalShifting Args: executing the next command; this can be a number form 1 to 255. Cycles: 0 Drift is a simple but powerful concept that allows sprites to move on X by a certain number of pixels each game cycle. Normally, sprites sit over the background and aren’t attached to it in any way, usually this is good since it means you don’t have to worry about counter-scrolling or any of the odd effects this might have on things like your Circle command. However…what if you wanted to do a circle of baddies to kill, one that was attached to the display and just moved with it? This would be virtually impossible with the standard Circle command and would require a great deal of work with the Move command. Even if your sprites'path looks complicated, you dont have to care about its global horizontal movement, because you're able to perform it at the very start of the path's Script spending zero additional cycles. Example: rolling baddies approaching! Now you simple make a path and execute it in place (probably leaving out KillClip), and just letting Drift move your sprite across the screen. Let’s try it with our demo path:
StartPathData:
Wait 4 Now, change the DemoLoop to this:
DemoPath1: Drift
0 Now you’re sprite will spawn, do 3 circles in one place, then disappear. This is fine, and what we’d expect. Now change the Drift:
DemoPath1: Drift
-1 Now the whole thing will slowly move across the
screen. It’ll look a bit funny – like its doing a snaking ellipse,
but that’s just an optical illusion, and it is actually doing a
circle in place on a scrolling backdrop. Example: square cage ahead! It’s easier to show this with a simple cube and
its more understandable (it also saves us working out circle
locations!).
StartPathData:
Wait 16
; Make sure there’s some level on screen… This starts off 4 sprites at corners of the box,
and runs the demo path from various points.
DemoPath1: Drift
-1 This is simple box movement, and without the Drift it wouldn’t do much. But with it, it allows a sprite to orbit a square graphic on screen… or in our case, 4 sprites run around it. |
See also: |