Here is my first ever Dark Basic game, that I named "Blake the Snake", and yes it is yet another classic worm game.
While the graphics lack any glitter, it does seem to allow the game to run very fast even on old computers.
I'm sure there are bugs and suggestions for this project as it stands, so I will welcome all advice/suggestions/comments
It was programmed in Dark Basic Classic and as of right now, only uses 3 sounds that are included in the Dark Basic Classic media folder under the sounds folder. Those sounds are "explode1", "hum1", and "select".
Here is my code:
sync rate 30:sync on
randomize timer()
dim pos(62,48)
dim app(62,48)
dim dx(260)
dim dy(260)
dim wall(64,48)
load sound "select.wav",1:load sound "explode1.wav",2
load sound "hum1.wav",3
newgame:
lf=4
CLS:backdrop off
hide mouse
ink 16761125,1
set text size 25
center text 310,100,"Blake"
wait 1200
center text 310,140,"the"
wait 1200
center text 310,190,"Snake"
wait 2000
ink 15132922,1
set text size 10
center text 310,240,"Created By: Zaxtor99"
wait 3000
ink 14276889,1
center text 310,300,"[W] = UP : [S] = DOWN : [A] = LEFT : [D] = RIGHT"
center text 310,320,"OR USE THE ARROW KEYS"
wait 1500
center text 310,350,"---> Use [Space Bar] To Pause Game <---"
wait 3500
ink 65535,1
center text 310,400,"Press {W key} -or- {UP Arrow} to Begin Game!"
wait 50
pressupkey:
if scancode()=17 or scancode()=200 then goto begin
goto pressupkey
begin:
play sound 1
cls
ink 8388352,1
set text size 20
center text 310,200,"GET READY !!"
wait 3000
set text size 10
start:
for z=1 to 160:dx(z)=0:dy(z)=0:next z
for v=1 to 62:
for z=1 to 48:pos(v,z)=0
next z
next v
SCORE=0:SCSUBT=0
RM=0
REM ************************ MAIN LOOP ***************************
newroom:
rm=rm+1
if rm=3 or rm=6 then cls:ink 8388352,1:center text 310,200,"EXTRA LIFE !!":lf=lf+1:wait 5000
if rm>1 then cls:ink 15132922,1:center text 310,240,"Entering Room "+str$(rm):wait 3000
lg=7:apl=10:ap=0:ScSubt=0:ap=0:od=0
Gosub roomdraw
if EG=1 then EG=0:goto gamecomp
goat:
gosub roomspecs
xc=xp:yc=yp:sp=10:ln=0
mnlp:
if ap=2 then goto mnlp3
if ap=0 then ax=rnd(55):ay=rnd(42):ax=(ax)+2:ay=(ay)+3
if ap=0 and ax>=xap1 and ax<=xap2 and ay>=yap1 and ay<=yap2 then goto mnlp
if ap=0 and ax>=xap3 and ax<=xap4 and ay>=yap3 and ay<=yap4 then goto mnlp
if ap=0 then ap=1:ink 16711680,1:text ax*10,ay*10,chr$(211)
mnlp3:
sc=scancode()
if sc=200 and dr=2 or sc=17 and dr=2 then goto mnlp2
if sc=203 and dr=4 or sc=30 and dr=4 then goto mnlp2
if sc=205 and dr=3 or sc=32 and dr=3 then goto mnlp2
if sc=208 and dr=1 or sc=31 and dr=1 then goto mnlp2
if sc=200 or sc=17 then dr=1
if sc=203 or sc=30 then dr=3
if sc=205 or sc=32 then dr=4
if sc=208 or sc=31 then dr=2
if sc=57 then gosub pauze
mnlp2:
if dr=1 then yc=yp-sp:ty=sp
if dr=2 then yc=yp+sp:ty=sp
if dr=3 then xc=xp-sp:tx=sp
if dr=4 then xc=xp+sp:tx=sp
if pos(xc/10,yc/10)=1 then goto krash
if xp=ax*10 and yp=ay*10 then ink 0,1:play sound 1:text ax*10,ay*10,chr$(211):ap=0:lg=lg+15:gosub apple
if lg>157 then lg=157
dx(ln)=xc:dy(ln)=yc
ln=ln+1:if ln>=lg then ln=ln-lg:Dis=1
xp=xc:yp=yc:pos(xp/10,yp/10)=1
ink 0,1
if dis=1 then text dx(ln),dy(ln),chr$(164):pos(dx(ln)/10,dy(ln)/10)=0
ink 8388352,1
text xp,yp,chr$(164)
SCSUBT=SCSUBT+1
if wall(xc/10,yc/10)>=1 then goto chkexit
sync
goto mnlp
REM ********* PAUSE GAME **********
pauze:
ink 14276889,1
center text 315,220,"GAME PAUSED"
wait 500
spckey:
if scancode()=57 then ink 0,1:center text 315,220,"GAME PAUSED":wait 300:return
goto spckey
REM ********* CRASH INTO SELF OR WALL **********
krash:
play sound 2
ink 14276889,1
center text 315,220,"OOPS! THAT HURT!"
wait 3000
ink 0,1
text ax*10,ay*10,chr$(211)
if od>0 then ap=2
if od=0 then ap=0
for x=0 to lg:text dx(x),dy(x),chr$(164):next x
center text 315,220,"OOPS! THAT HURT!"
center text 200,0,"LIVES: "+str$(lf)
lf=lf-1:if lf=0 then goto gameover
for z=1 to 160:dx(z)=0:dy(z)=0:next z
for v=1 to 62:
for z=1 to 48:pos(v,z)=0
next z
next v
goto goat
REM ************* LOST ALL LIVES *************
gameover:
CLS
ink 14276889,1
center text 310,240,"That's all of your lives!"
REM **** GAME OVER DUE TO COMPLETE ALL ROOMS ****
gamecomp:
wait 2000
ink 15132922,1
center text 310,310,"Your FINAL SCORE was: "+str$(SCORE)
wait 3500
ink 167400339,1
center text 310,370,"Play Again? (Y/N)"
chkplayagain:
if inkey$()="y" then goto newgame
if inkey$()="n" then end
sync
goto chkplayagain
REM *********** EAT AN APPLE ************
apple:
ink 0,1
center text 50,0,"SCORE: "+str$(SCORE)
ScApp=200-ScSubt:IF ScApp<10 then ScApp=10
SCORE=SCORE+ScApp:ScSubt=0
apl=apl-1:if apl<=0 then goto oprm1
center text 520,0,"APPLES LEFT: "+str$(apl+1)
ink 14276889,1
center text 50,0,"SCORE: "+str$(SCORE)
ink 16711680,1
center text 520,0,"APPLES LEFT: "+str$(apl)
return
REM *********** OPEN RANDOM DOOR ************
oprm1:
ink 0,1
center text 520,0,"APPLES LEFT: "+str$(apl+1)
ink 0,1:play sound 1:text ax*10,ay*10,chr$(211):ap=0
ink 16711680,1
center text 530,0,"GREAT! NOW EXIT THIS ROOM !!"
ink 0,1
od=rnd(3)+1
if od=1 then line 10,225,10,275
if od=2 then line 610,225,610,275
if od=3 then line 285,25,335,25
if od=4 then line 285,475,335,475
ap=2:ax=-5:ay=-5
return
rem *********** CHECK FOR EXIT ROOM OR CRASH ***********
chkexit:
exrm1:
if od=0 then goto krash
if od=1 and xc<15 and yc>=220 and yc<=270 then goto dissnake1
if od=2 and xc>605 and yc>=220 and yc<=270 then goto dissnake1
if od=3 and yc<25 and xc>=285 and xc<=335 then goto dissnake1
if od=4 and yc>465 and xc>=285 and xc<=335 then goto dissnake1
goto krash
rem *********** DELETE SNAKE FOR SCORE ON ROOM EXIT ***********
dissnake1:
for x=0 to ln
ink 0,1
text dx(x),dy(x),chr$(164)
center text 50,0,"SCORE: "+str$(SCORE)
SCORE=SCORE+2:play sound 3
ink 14276889,1
center text 50,0,"SCORE: "+str$(SCORE)
wait 3
next x
for x=ln to lg
ink 0,1
text dx(x),dy(x),chr$(164)
center text 50,0,"SCORE: "+str$(SCORE)
score=score+2:play sound 3
ink 14276889,1
center text 50,0,"SCORE: "+str$(SCORE)
wait 3
next x
wait 2000
for z=1 to 160:dx(z)=0:dy(z)=0:next z
for v=1 to 62:
for z=1 to 48:pos(v,z)=0
next z
next v
goto newroom
REM ************* DRAW NEW ROOM ************
roomdraw:
CLS:hide mouse
ap=0
rem clear room wall data on next line
for x=0 to 64:for y=0 to 48:wall(x,y)=0:next y:next x
ink 15132922,1
for x=1 to 60:wall(x,2)=wall(x,2)+1:wall(x,47)=1:next x
for y=2 to 46:wall(1,y)=wall(1,y)+2:wall(61,y)=2:next y
if rm=2 then for x=25 to 37:wall(x,20)=wall(x,20)+1:wall(x,29)=wall(x,29)+1:next x:xap1=25:xap2=38:xap3=0:xap4=0
if rm=2 then for y=20 to 28:wall(25,y)=wall(25,y)+2:wall(38,y)=wall(38,y)+2:next y:yap1=20:yap2=29:yap3=0:yap4=0
if rm=3 then for x=10 to 21:wall(x,15)=wall(x,15)+1:wall(x,35)=wall(x,35)+1:next x:xap1=10:xap2=22
if rm=3 then for y=15 to 34:wall(10,y)=wall(10,y)+2:wall(22,y)=wall(22,y)+2:next x:yap1=15:yap2=35
if rm=3 then for x=40 to 51:wall(x,15)=wall(x,15)+1:wall(x,35)=wall(x,35)+1:next x:xap3=40:xap4=52
if rm=3 then for y=15 to 34:wall(40,y)=wall(40,y)+2:wall(52,y)=wall(52,y)+2:next x:yap3=15:yap4=35
if rm=4 then for x=10 to 26:wall(x,12)=wall(x,12)+1:wall(x,38)=wall(x,38)+1:next x:xap1=10:xap2=27
if rm=4 then for y=12 to 37:wall(10,y)=wall(10,y)+2:wall(27,y)=wall(27,y)+2:next x:yap1=12:yap2=38
if rm=4 then for x=35 to 51:wall(x,12)=wall(x,12)+1:wall(x,38)=wall(x,38)+1:next x:xap3=35:xap4=52
if rm=4 then for y=12 to 37:wall(35,y)=wall(35,y)+2:wall(52,y)=wall(52,y)+2:next x:yap3=12:yap4=38
if rm=5 then for x=22 to 40:wall(x,21)=wall(x,21)+1:next x:xap1=22:xap2=41
if rm=5 then for y=2 to 20:wall(22,y)=wall(22,y)+2:wall(41,y)=wall(41,y)+2:next x:yap1=2:yap2=21
if rm=5 then for x=22 to 40:wall(x,28)=wall(x,28)+1:next x:xap3=22:xap4=41
if rm=5 then for y=28 to 46:wall(22,y)=wall(22,y)+2:wall(41,y)=wall(41,y)+2:next x:yap3=28:yap4=47
if rm=6 then for x=1 to 47:wall(x,11)=wall(x,11)+1:wall(x,14)=wall(x,14)+1:next x:xap1=1:xap2=48
if rm=6 then for y=11 to 13:wall(48,y)=wall(48,y)+2:next y:yap1=10:yap2=13
if rm=6 then for x=14 to 60:wall(x,18)=wall(x,18)+1:wall(x,21)=wall(x,21)+1:next x:xap3=14:xap4=61
if rm=6 then for y=18 to 20:wall(14,y)=wall(14,y)+2:next y:yap3=17:yap4=20
if rm>=7 then center TEXT 310,200,"You have completed every room built so far!"
if rm>=7 then center text 310,220,"However, more levels are coming soon...."
if rm>=7 then EG=1:return
REM *** DRAW SPECIFIC ROOM WALLS ***
for x=0 to 64:for y=0 to 48
if wall(x,y)=1 then line x*10,y*10+5,(x*10)+10,y*10+5
if wall(x,y)=2 then line x*10,y*10+5,x*10,(y*10)+15
if wall(x,y)=3 then line x*10,y*10+5,(x*10)+10,(y*10)+5:line x*10,y*10+5,x*10,Y*10+15
next y:next x
return
REM ******** ROOM STATS & START LOC, START DIRECTION *********
roomspecs:
ink 14276889,1
center text 50,0,"SCORE: "+str$(SCORE)
ink 8388352,1
center text 200,0,"LIVES: "+str$(lf)
ink 15132922,1
center text 360,1,"ROOM: "+str$(rm)
ink 16711680,1
if od=0 then center text 520,0,"APPLES LEFT: "+str$(apl)
if rm=1 then xp=310:yp=440:dr=1:return
if rm=2 then xp=20:yp=440:dr=4:return
if rm=3 then xp=310:yp=440:dr=1:return
if rm=4 then xp=310:yp=440:dr=1:return
if rm=5 then xp=60:yp=440:dr=1:return
if rm=6 then xp=60:yp=440:dr=4:return
do
loop
As of right now, I only have 6 rooms to progress through, but have plans to add more rooms, probably in the 12 to 15 room range.
If you copy and paste the code, you can simply change the SYNC rate at the beginning to alter the game speed! If my current game is too easy, you could always change the sync rate to 60, heh.
Anyhow, have fun with the downloadable executable that weighs in at only about 2 MB, and includes the sounds.
Keep in mind that I put in a stop that allowed people to go back into themselves thus killing themselves (ie hitting the 'move down' key while snake is moving up) ..so you cannot immediately move in the opposite direction that you are moving. This is pretty common in most of the snake games I have ever played, just keep this in mind while maneuvering through the rooms.
Please comment, no matter how "harsh" on my first completed game!
Enjoy!
- Zaxx