DIM MarioSheet
AS LONG ' small sprite sheet containing a few 16x16 Mario images DIM Direction
AS _BYTE ' Mario motion direction (-1, 1) DIM Mario
(3) AS LONG ' 4 Mario animated sprite cells
MarioSheet
= _LOADIMAGE("smariotest.png", 32) ' load the sprite sheetFOR count
= 0 TO 3 ' cycle through the 4 cells Mario
(count
) = _NEWIMAGE(16, 16, 32) ' create cell image holder _PUTIMAGE , MarioSheet
, Mario
(count
), (count
* 16, 0)-(count
* 16 + 15, 15) ' grab image from sprite sheet mx = 320 ' X,Y Mario starting point
my = 240
Cell = 0 ' animation cell
Direction = 1 ' Mario going right
_LIMIT 10 ' 10 frames per second PRINT ' print instructions PRINT " RIGHT/LEFT Arrow keys to move" PRINT " UP/DOWN Arrow keys to change size of Mario" Direction = -1 ' yes, going LEFT
mx = mx - 1 ' decrement Mario X location
Cell = Cell + 1 ' move to next animation cell
Direction = 1 ' yes, going RIGHT
mx = mx + 1 ' increment Mario X location
Cell = Cell + 1 ' move to next animation cell
IF _KEYDOWN(18432) THEN Size
= Size
+ .1 ' UP ARROW? if so increase size IF _KEYDOWN(20480) THEN Size
= Size
- .1 ' DOWN ARROW? if so decrease size IF Size
< 1 THEN Size
= 1 ' keep variables within limits
mx2 = mx + 16 * Size ' calculate box to place image in
my2 = my + 16 * Size
SELECT CASE Direction
' which direction is Marion going? _PUTIMAGE (mx2
, my
)-(mx
, my2
), Mario
(Cell
) ' draw image flipped horizontally _PUTIMAGE (mx
, my
)-(mx2
, my2
), Mario
(Cell
) ' no image flip needed