TGC Codebase Backup



submarine by cactuar man

30th Aug 2007 0:07
Summary

a sidescroller submarine game



Description

firs it will ask you to choose a level. then a box will appear. use it to draw a submarine or just press ctrl to use the default. press space to rise and nothing to sink.

i hope you like it ^_^



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem * Title  : submarine
Rem * Author : zac romero
sync on
sync rate 50
load music "Jellyfsh.mid",1
levelmove#=0
`level selection
levsel:
print "what level would you like to do"
print " "
print "1------level 1(easy)"
print "2------level 2(medium)"
input level
if level>2 or level<1
cls
goto levsel
endif






`sync rate 200
presub#=0
line 71,0,71,47
line 0,47,71,47
ink rgb(0,0,0), rgb(200,200,200)
box 0,0,69,45
ink rgb(200,0,0),0

do
sync
dot 100,100
x=mousex()
y=mousey()

if controlkey()=1 then goto premadesub
if spacekey()=1 then goto finished
if x<70 and y<46 then gosub checkifclick

if color#=1 then ink rgb(0,200,0),0
if color#=2 then ink rgb(200,0,200),0
if color#=3 then ink rgb(200,0,0),0

if rightkey()=1 and color#<3 then gosub regright
if rightkey()=1 and color#=3 then gosub backright
if leftkey()=1 and color#>1 then gosub regleft
if leftkey()=1 and color#=1 then gosub backleft

loop

regright:
color#=color#+1
sleep 100
return

backright:
color#=1
sleep 100
return

regleft:
color#=color#-1
sleep 100
return

backleft:
color#=3
sleep 100
return



checkifclick:
if mouseclick()=1 then dot x,y
return


premadesub:
presub#=1
goto finished


finished:
get image 1,0,0,70,46

load bitmap "water.bmp"

if presub#=1 then load image "sub.bmp",1

if level=1 then load image "level.bmp",2
if level=2 then load image "level2.bmp",2
restart:
rem set variables
ysubpos#=180
life#=3
point#=0
level#=10



restartlv:
position#=0
ysubpos#=180
rem start loop
loop music 1
do
load bitmap "water.bmp"
set cursor 0,0
print point#
rem sync and sleep

`sleep 100
sync
rem level stuff
sprite 2,position#,0,2
position#=position#-level#



rem submarine stuff
sprite 1,0,ysubpos#,1


if spacekey()=0 then ysubpos#=ysubpos#+(6+levelmove#)
if spacekey()=1 then ysubpos#=ysubpos#-(8+levelmove#)

rem collision
if sprite hit(2,0)=1 then goto lose



if position#<-4000 then goto nextlv

point#=point#+1

loop


rem next level
nextlv:
delete sprite 1
delete sprite 2
cls
print "you have one the level"
print "you will go to the next level which is faster "
print "you have won ";point#;" points"
suspend for key
level#=level#+4
levelmove#=levelmove#+3
goto restartlv





rem lose
lose:
life#=life#-1
if life#=0 then goto alllifeslost
position#=0
goto restartlv

alllifeslost:
delete sprite 1
delete sprite 2
cls
print "you lost all you lifes"
print "you obtained ";point#;" points"
print " "
print "press any key when you are done"
suspend for key

back:

cls
print "would you like to play again "
print "1=yes"
print "2=no"
input continue#
if continue#=1 then goto restart
if continue#=2 then end
if continue#>2 or continue#<1 then goto wrong_continue_answer

wrong_continue_answer:
cls
print "you have put in a answer not acceptable"
sleep 3000
goto back