
HEy you Nubees..
this is a very basic code for you guys...
the only thing you will have to change is the sprites, backgrounds, and the position numbers...........
i hope this helps......
____________________________________________________________________
remstart
*****************************************************
Stomp the snake game
*****************************************************
remend
rem setting these two contants makes using flags easier to understand
TRUE = 1
FALSE = 0
Rem Set Up the Screen and Sync Rate
Sync On : Sync Rate 30
Hide Mouse : set text opaque
Load Bitmap "mtnTrail.bmp"
Rem set up a small bit map to 'clear' the scoreboard
Rem -- otherwise it prints on top of previous print
Create Bitmap 1,101,31
Copy Bitmap 0,0,0,100,30,1,0,0,100,30
Set Current Bitmap 0
Rem initialize the character sprites
GOSUB MakeCharacters
rem initialize all variables
GOSUB InitVariables
rem show the values of health and dead snakes
Copy Bitmap 1,0,0,100,30,0,0,0,100,30
ink 0,0
Set Cursor 0,0
Print "Health ", health
Print "Dead snakes ", deadsnakes
Rem Main loop
While health > 0
If enemyOn=FALSE
GOSUB CheckStartEnemy
Else
GOSUB ProcessEnemy
Endif
GOSUB ProcessMainCharacter
GOSUB CheckCollision
Rem Refresh Screen
Sync
Endwhile
rem *****************************************************
rem START ENEMY CHECK
rem *****************************************************
CheckStartEnemy:
If startEnemy > 0
startEnemy = startEnemy - 1
Else
enemyOn = TRUE
show sprite 2
enemyHz = 550
Endif
Return
rem *****************************************************
rem ENEMY LOGIC
rem *****************************************************
ProcessEnemy:
enemyHz=enemyHz-10
If enemyHz<=0
Hide Sprite 2
enemyOn = FALSE
startEnemy = rnd(100)
Endif
Sprite 2,enemyHz,enemyVt,2
Return
rem *****************************************************
rem MAIN CHAR LOGIC
rem *****************************************************
ProcessMainCharacter:
Rem Control input
rem we can make main char move left and right
If Rightkey()=1 Then horizontal = horizontal+5
If Leftkey()=1 Then horizontal = horizontal-5
rem the upkey will now be a jump key IF main char on ground
If (Upkey()=1 And vertical = 400) Then jumping = TRUE
rem if char is not jumping, assume he is falling
If jumping = TRUE
vertical=vertical-10
Else
rem this calculation won't do anything if main char on ground
vertical=vertical+10
Endif
rem the downkey will now be a 'stomp' key IF main char off ground
If (Downkey()=1 And vertical < 400)
vertical = 400
stomp = TRUE
Endif
rem make sure main char doesn't go off screen, too high or below ground
If vertical > 400 Then vertical = 400
If vertical < 250
jumping = 0
vertical = 250
Endif
If horizontal > 550 Then horizontal = 0
If horizontal < 0 Then horizontal = 550
rem 'move' the sprite to it's new position
Sprite 1,horizontal,vertical,1
Return
rem *****************************************************
rem Check for snake bites or stomped snake
rem *****************************************************
CheckCollision:
If Sprite Hit(1,2)
area = ABS(horizontal - enemyHz)
If (area < 30 And stomp = TRUE)
deadsnakes = deadsnakes + 1
hide sprite 2
Else
Dec health
jumping=TRUE
Endif
rem show the values of health and dead snakes
Copy Bitmap 1,0,0,100,30,0,0,0,100,30
ink 0,0
Set Cursor 0,0
Print "Health ", health
Print "Dead snakes ", deadsnakes
Endif
Return
rem *****************************************************
rem Initialization Routines
rem *****************************************************
MakeCharacters:
rem get the main character image and make its sprite...
load image "jumpguy.bmp",1
horizontal = 100
vertical = 400
Sprite 1,horizontal,vertical,1
rem the jumpguy bitmap was too big so we scaled it down
Scale Sprite 1,50
rem set up the main character's offset
spriteheight=(sprite height(1)/2)
spritewidth=(sprite width(1)/2)
Offset Sprite 1,spritewidth,spriteheight
rem now set up the enemy sprite
Load Image "snake.bmp",2
enemyHz=550
enemyVt=435
Sprite 2,enemyHz,enemyVt,2
rem set up the enemy's offset
spriteheight=(sprite height(2)/2)
spritewidth=(sprite width(2)/2)
Offset Sprite 2,spritewidth,spriteheight
Return
InitVariables:
rem use a random number to count when the enemy starts coming
startEnemy = rnd(100)
Hide Sprite 2
enemyOn = FALSE
stomp = FALSE
health = 20
deadsnakes = 0
Return
remstart
subroutines start with a capital letter
constants are in all capitals
Dark Basic commands start with a capital except GOSUB is all caps
the main loop (routine) simply calls each 'action' that needs to be done
each action does one and only one thing, and then returns
(long loops in a subroutine are not good)
remend