The home ship

Let's make our ship move. Create program ASHMUPD and put this in:

PROGRAM:ASHMUPD
:..DATA
:[18183C7E66FF9981]→GDB0

That's the sprite for our character. It looks like this:

Now let's code the actual movement. Since our ship's just one ship, we won't put it in an array. We need to keep track of its X- and Y-positions; for simplicity, how about just X and Y? Here's prgmASHMUPK:

PROGRAM:ASHMUPK
:..KEYS
:If getKey(1)
:Y+2→Y
:End
:If getKey(2)
:X-2→X
:End :If getKey(3)
:X+2→X
:End
:If getKey(4)
:Y-2→Y
:End

As you can tell, we'll be moving two pixels each frame. It's a good amount.

We haven't given it an initial position yet, so put that in prgmASHMUPI (the initiation program). The ship should start in the center of the screen, perhaps a closer to the bottom edge. (44, 40) should work.

PROGRAM:ASHMUPI
:..INIT
:44→X
:40→Y
+ Tweet