TGC Codebase Backup



simple box movement by blood scent

12th Aug 2005 20:41
Summary

moves a box around without sprite use



Description

randomize timer
rem setup positions
set display mode 640,480,16
x#=0
y#=0
x2#=10
y2#=10
rem setup box to control
box x#,y#,x2#,y2#
boxcolor=rgb(rnd(255),rnd(255),rnd(255))
rem main game loop
do
boxcolor=rgb(rnd(255),rnd(255),rnd(255))
rem move left
if leftkey()=1 and x#>0
cls
x#=x#-1
x2#=x2#-1
box x#,y#,x2#,y2#
endif
rem move right
if rightkey()=1 and x2#<640
cls
x2#=x2#+1
x#=x#+1
box x#,y#,x2#,y2#
endif
rem move down
if downkey()=1 and y2#<480
cls
y#=y#+1
y2#=y2#+1
box x#,y#,x2#,y2#
endif
rem move up
if upkey()=1 and y#>0
cls
y#=y#-1
y2#=y2#-1
box x#,y#,x2#,y2#
endif
ink boxcolor,0
loop



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    randomize timer
rem setup positions
set display mode 640,480,16
x#=0
y#=0
x2#=10
y2#=10
rem setup box to control
box x#,y#,x2#,y2#
boxcolor=rgb(rnd(255),rnd(255),rnd(255))
rem main game loop
do
boxcolor=rgb(rnd(255),rnd(255),rnd(255))
rem move left
if leftkey()=1 and x#>0
cls
x#=x#-1
x2#=x2#-1
box x#,y#,x2#,y2#
endif
rem move right
if rightkey()=1 and x2#<640
 cls
x2#=x2#+1
x#=x#+1
box x#,y#,x2#,y2#
endif
rem move down
if downkey()=1 and y2#<480
cls
y#=y#+1
y2#=y2#+1
box x#,y#,x2#,y2#
endif
rem move up
if upkey()=1 and y#>0
cls
y#=y#-1
y2#=y2#-1
box x#,y#,x2#,y2#
endif
ink boxcolor,0
loop