TGC Codebase Backup



RAA Tutorial by Scimitar Products

5th May 2005 10:58
Summary

A very short game tutorial that uses rem statments.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem Start
gosub load
gosub setpermiters
do
gosub character
sync
loop
remstart
 By using subroutines, we can effectively use the same commands through out
 a game. Often times one may need to complete a task in a game. Then one
 should use repeat_until commands.
remend
rem Character
`1-Walk Right(1)
`2-Walk Right(2)
`3-Walk Left(1)
`4-Walk Left(2)
`5-Normal Right()
`6-Normal Left()
`7-Punch Right()
`8-Punch Left()
character:
if side$="Right" then sprite 1,x,y,5
if side$="Left" then sprite 1,x,y,6
if rightkey()=1 and side$="Right" and walkcycle#=1 then sprite 1,x,y,1 : x=x+10 : walkcycle#=2
if rightkey()=1 and side$="Right" and walkcycle#=2 then sprite 1,x,y,2 : x=x+10 : walkcycle#=1
if rightkey()=1 and side$="Left" and walkcycle#=1 then sprite 1,x,y,1 : x=x+10  : walkcycle#=2 : side$="Right"
if rightkey()=1 and side$="Left" and walkcycle#=2 then sprite 1,x,y,2 : x=x+10  : walkcycle#=1 : side$="Right"
if leftkey()=1 and side$="Right" and walkcycle#=1 then sprite 1,x,y,3 : x=x-10 : walkcycle#=2 : side$="Left"
if leftkey()=1 and side$="Right" and walkcycle#=2 then sprite 1,x,y,4 : x=x-10 : walkcycle#=1 : side$="Left"
if leftkey()=1 and side$="Left" and walkcycle#=1 then sprite 1,x,y,3 : x=x-10 : walkcycle#=2
if leftkey()=1 and side$="Left" and walkcycle#=2 then sprite 1,x,y,4 : x=x-10 : walkcycle#=1
if spacekey()=1 and side$="Right" then sprite 1,x,y,7
if spacekey()=1 and side$="Left" then sprite 1,x,y,8
remstart
 One should load basic bitmaps at the begining of the game.
 Here, instead of having a couple of different bitmaps, we only have one.
 By mirroring the bitmap, one can turn the same bitmap around.
remend 
load:
load bitmap "RAA Walk.bmp",1
get image 1,0,0,78,93
delete bitmap 1
load bitmap "RAA Walk.bmp",2
get image 2,78,0,157,93
delete bitmap 2
load bitmap "RAA Walk.bmp",3
mirror bitmap 3
get image 3,0,0,78,93
delete bitmap 3
load bitmap "RAA Walk.bmp",4
mirror bitmap 4
get image 4,78,0,157,93
delete bitmap 4
load bitmap "Sprite Normal01.bmp",5
get image 5,0,0,54,94
delete bitmap 5
load bitmap "Sprite Normal01.bmp",6
mirror bitmap 6
get image 6,0,0,54,94
delete bitmap 6
load bitmap "Sprite Punch01.bmp",7
get image 7,0,0,69,94
delete bitmap 7
load bitmap "Sprite Punch01.bmp",8
mirror bitmap 8
get image 8,0,0,69,94
delete bitmap 8
return
remstart
 This is important, so your program has less errors.
remend
setpermiters:
sync rate 100
x=80
y=80
spriteimage=5
side$="Right"
walkcycle#=1
sprite 1,x,y,1
return