TGC Codebase Backup



Gambit moving across the screen by the green scar

21st Oct 2006 18:41
Summary

This is a program to show a 2d character moving across the screen.



Description

This progam shows you how to grab images from a bitmap and make a continuous motion out of them. It can be used for any series of images in bitmap form.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem * Title  : Gambit
Rem * Author : Nicholas Tello

rem Load character into hidden bitmap
LOAD BITMAP "gambit 7.bmp",1

rem Grab images for character animation
y=0
FOR x=0 TO 6
GET IMAGE 1+x+(y*7),(x*89),(y*120),(x*89)+89,(y*120)+120
NEXT x

rem Delete character bitmap
DELETE BITMAP 1

rem Set player variables
xpos=0
ypos=200
image=1

rem Activate manual syncronization
SYNC ON
hide mouse

rem Begin Loop
DO

rem Run right and wrap
xpos=xpos+6 : IF xpos>640 THEN xpos=-64

Rem Animate runner and wrap
image=image+1 : IF image>7 THEN image=2

rem Update sprite
sprite 1,xpos,ypos,image

rem Refresh screen now
SYNC : SLEEP 50

rem End Loop
LOOP