Main Page
News
History
Limitations
Graphics
Music
Levels
Gameplay
Now Browsing
Links
Download

Drift

        DRIFT                ValueOfGlobalShifting

Args:

  • ValueOfGlobalShifting: waits for a certain number of frames to pass before
    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
                                            Start   DemoPath1, Baddie1, 330, 70, KillClip
    InfLoop:
                                            Pause 255
                                            Goto    InfLoop

    Now, change the DemoLoop to this:

    DemoPath1:                    Drift     0
                                            PFor    3
                                                       Circle  50, 50, 0, 0, -2, -2, 128
                                            PNext
                                            KillSprite

    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
                                            PFor    3
                                                       Circle  50, 50, 0, 0, -2, -2, 128
                                            PNext
                                            KillSprite

    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.
    Now the reason we had to remove the PFor loop was that due to the drift, we have to start all the sprites in place, at the same time. Now this is tricky… And does in fact mean you have to work out locations on a circle yourself! But once done, the whole circle would slowly revolve and move across the screen as expected.


    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!).
    Let’s change the MasterPath to this:

    StartPathData:                 Wait    16                                                                    ; Make sure there’s some level on screen…

                                            Start   DemoPath1, Baddie1, 330+40, 70, KillClip
                                            Start   DemoPath1, Baddie1, 330, 70, KillClip
                                            Start   DemoPath1, Baddie1, 330, 70+40, KillClip
                                            Start   DemoPath1, Baddie1, 330+40, 70+40, KillClip
    InfLoop:
                                            Pause 255
                                            Goto    InfLoop

    This starts off 4 sprites at corners of the box, and runs the demo path from various points.
    Now let’s add the new script for DemoPath1:

    DemoPath1:                    Drift     -1
                                            PFor    20
                                                       Move    -2, 0
                                            PNext
    DemoPath2:                    Drift     -1
                                            PFor    20
                                                       Move    0, 2
                                            PNext
    DemoPath3:                    Drift     -1
                                            PFor    20
                                                       Move    2, 0
                                            PNext
    DemoPath4:                    Drift     -1
                                            PFor    20
                                                       Move    0, -2
                                            PNext
                                            Goto    DemoPath1

    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:
    MasterPath
    Circle
    Move
    Script

    Main Table