Hi Grog,
I've been up all night reworking the code from scratch. I forgot about having an old laptop with Vista on it. I had just received my copy of DarkGAME Studio on DVD...and Windows 7 kept arguing with me. So, I dragged out the old laptop, set both laptops up side by side, and started the process of cleaning up the code as I transfered. The code may still use some old-fashioned methods, but it is a lot cleaner. Here's the code:
Rem Project: Blast Em
Rem Created: Saturday, Feburary 05, 2011
Rem Revised: Wednesday, February 09, 2011
Rem Author: Michael Allard
Rem Design: Michael Allard
Rem Published Under: Just Push Play
Rem Programming Assistance: Grog Grueslayer (Thanks a million!)
Rem ***** Main Source File *****
Rem **** Setup Display ****
set display mode 800,600,16
sync on:sync rate 60
hide mouse
Rem **** Show user we are loading ****
ink rgb(255,255,255),rgb(0,0,0)
Print "Loading"
sync
Rem **** Load Images ****
load image "images\redbrick.png",1,1
load image "images\bluebrick.png",2,1
load image "images\greenbrick.png",3,1
load image "images\yellowbrick.png",4,1
load image "images\purplebrick.png",5,1
load image "images\background.jpg",6
load image "images\playfield.png",7,1
load image "images\paddle.png",8,1
load image "images\title.png",9,1
load image "images\titlephoto.png",10,1
Rem **** Load Music ****
load music "music\Deep Fried.mp3",1
load music "music\Fully Saturated.mp3",2
load music "music\Chillin.mp3",3
load music "music\The Weak Need Not Apply.mp3",4
load music "music\Nylon.mp3",5
Rem **** Load Sounds ****
load sound "sounds\mechanical_1.wav",1
load sound "sounds\hit.wav",2
load sound "sounds\radio_tuning.wav",3
load sound "sounds\hit_2.wav",4
load sound "sounds\boing_3.wav",5
load sound "sounds\nice_effect.wav",6
load sound "sounds\cork_pop.wav",7
Rem **** Initial Settings (Main) ****
dim brickgrid(7,27)
randomize timer()
cls
Rem **** Title Screen ****
Title:
`play sound 3
loop music 1
wait 500
paste image 9,90,50,1
paste image 10,150,160,1
set text font "Computerfont"
set text size 40
ink rgb(255,255,255),rgb(0,0,0)
center text screen width()/2,screen height()-40,"Copyright 2011 Just Push Play. All Rights Reserved."
set text size 100
` **** Cycle colors and check for key ****
do
r=r+8:b=b+6:g=g+4
if r>255 then r=1
if b>255 then r=1
if g>255 then g=1
ink rgb(r,g,b),rgb(0,0,0)
center text screen width()/2,screen height()-130,"Press Space"
if spacekey()=1
stop music 1
goto GameStart
endif
if escapekey()=1
goto quit
endif
sync
loop
Rem **** Game Start ****
GameStart:
level=1
brickset=10:bricknumber=brickset
paddlex=276:paddley=540
delayset=1000:blockdelay=delayset
score=0:matches=brickset
delay=timer():delay2=timer()
delay3=timer():delay5=15000:delay4=delay5
set text size 40
ink rgb(255,255,0),rgb(0,0,0)
Rem **** Clear Grid ****
ClearGrid:
for brickrow=0 to 27
for brickcolumn=0 to 7
brickgrid(brickcolumn,brickrow)=0
next brickcolumn
next brickrow
Rem **** Brick Generator ****
BrickGenerator:
for bricks=1 to bricknumber
brickcolor=rnd(4)+1
repeat
brickcolumn=rnd(7)
brickrow=rnd(13)
until brickgrid(brickcolumn,brickrow)=0
brickgrid(brickcolumn,brickrow)=brickcolor
next bricks
Rem **** Game Main ****
repeat
track=rnd(4)+1
until track>1
if m=2 then v=50 else v=65
loop music track
set music volume track,v
gosub SetPaddleBrick
do
paste image 6,0,0,0
paste image 7,0,0,1
gosub UpdateScore
gosub ControlKeys
gosub PlacePaddleBrick
gosub BrickDisplay
`If all matches are made
if matches=0
stop music track
brickset=brickset+5
bricknumber=brickset
matches=brickset
if matches>50 then matches=50
delay4=delay5-1000
if delay4<5000 then delay4=5000
level=level+1
gosub LevelBonus
goto ClearGrid
endif
for brickcolumn=0 to 7
if brickgrid(brickcolumn,26)>0
goto GameOver
endif
next brickcolumn
sync
loop
Rem **** Update Score ****
UpdateScore:
`Convert integers into strings
score$=str$(score)
matches$=str$(matches)
`Display Scoreboard
ink rgb(255,255,0),rgb(0,0,0)
center text screen width()/2+280,screen height()/2-200,"Score"
center text screen width()/2+280,screen height()/2-100,"Left"
ink rgb(255,100,0),rgb(0,0,0)
center text screen width()/2+280,screen height()/2-170,score$
center text screen width()/2+280,screen height()/2-70,matches$
return
Rem **** Control Keys ****
ControlKeys:
if leftkey()=1 and timer()>delay+100
delay=timer()
paddlex=paddlex-64
if paddlex<20 then paddlex=20
endif
if rightkey()=1 and timer()>delay+100
delay=timer()
paddlex=paddlex+64
if paddlex>468 then paddlex=468
endif
paste image 8,paddlex,paddley,1
if keystate(57) and timer()>delay2+500
delay2=timer()
gosub FireBrick
gosub CheckMatches
gosub SetPaddleBrick
endif
if keystate(25)=1 and timer()>delay2+1000
delay2=timer()
cls
repeat
center text screen width()/2,screen height()/2,"Paused"
sync
until keystate(25)=1 and timer()>delay2+700
delay2=timer()
cls
endif
return
Rem **** Paddle Brick Routines ****
SetPaddleBrick:
brickcolor=rnd(4)+1
PlacePaddleBrick:
if brickcolor=1 then paste image 4,paddlex,paddley,1
if brickcolor=2 then paste image 1,paddlex,paddley,1
if brickcolor=3 then paste image 3,paddlex,paddley,1
if brickcolor=4 then paste image 2,paddlex,paddley,1
if brickcolor=5 then paste image 5,paddlex,paddley,1
`This section translates the block's position for grid use
if paddlex=20 then blockcolumn=0
if paddlex=84 then blockcolumn=1
if paddlex=148 then blockcolumn=2
if paddlex=212 then blockcolumn=3
if paddlex=276 then blockcolumn=4
if paddlex=340 then blockcolumn=5
if paddlex=404 then blockcolumn=6
if paddlex=468 then blockcolumn=7
`sync
return
Rem **** Fire Brick ****
FireBrick:
play sound 4
brickcolumn=blockcolumn
for brickrow=26 to 1 step -1
if brickgrid(brickcolumn,brickrow-1)=0
goto Skip
else
brickgrid(brickcolumn,brickrow)=brickcolor
play sound 7
return
endif
Skip:
next brickrow
brickrow=0
if brickgrid(brickcolumn,brickrow)>0
brickgrid(brickcolumn,brickrow+1)=brickcolor
else
brickgrid(brickcolumn,brickrow)=brickcolor
endif
play sound 2
gosub SetPaddleBrick
return
Rem **** Brick Drop ****
BrickDrop:
`Adjust next timer delay
delay3=timer()
delay4=delay4-1000
if delay4<5000 then delay4=5000
`Perform Drop
for brickrow=26 to 0 step -1
play sound 1
for brickcolumn=7 to 0 step -1
if brickgrid(brickcolumn,brickrow)>0
brickgrid(brickcolumn,brickrow+1)=brickgrid(brickcolumn,brickrow)
brickgrid(brickcolumn,brickrow)=0
endif
next brickcolumn
next brickrow
brickrow=0
for brickcolumn=0 to 7
brickcolor2=rnd(4)+1
brickgrid(brickcolumn,brickrow)=brickcolor2
next brickcolumn
return
Rem **** Brick Display ****
BrickDisplay:
`Check if time for bricks to drop
if timer()>delay3+delay4 then gosub BrickDrop
for brickrow=0 to 27
for brickcolumn=0 to 7
if brickgrid(brickcolumn,brickrow)>0
`Horizontal Brick Position
if brickcolumn=0 then brickx=20
if brickcolumn=1 then brickx=84
if brickcolumn=2 then brickx=148
if brickcolumn=3 then brickx=212
if brickcolumn=4 then brickx=276
if brickcolumn=5 then brickx=340
if brickcolumn=6 then brickx=404
if brickcolumn=7 then brickx=468
`Vertical Brick Position
if brickrow=0 then bricky=20
if brickrow=1 then bricky=40
if brickrow=2 then bricky=60
if brickrow=3 then bricky=80
if brickrow=4 then bricky=100
if brickrow=5 then bricky=120
if brickrow=6 then bricky=140
if brickrow=7 then bricky=160
if brickrow=8 then bricky=180
if brickrow=9 then bricky=200
if brickrow=10 then bricky=220
if brickrow=11 then bricky=240
if brickrow=12 then bricky=260
if brickrow=13 then bricky=280
if brickrow=14 then bricky=300
if brickrow=15 then bricky=320
if brickrow=16 then bricky=340
if brickrow=17 then bricky=360
if brickrow=18 then bricky=380
if brickrow=19 then bricky=400
if brickrow=20 then bricky=420
if brickrow=21 then bricky=440
if brickrow=22 then bricky=460
if brickrow=23 then bricky=480
if brickrow=24 then bricky=500
if brickrow=25 then bricky=520
if brickrow=26 then bricky=540
if brickrow=27 then bricky=560
`Brick Color
if brickgrid(brickcolumn,brickrow)=1 then paste image 4,brickx,bricky,1
if brickgrid(brickcolumn,brickrow)=2 then paste image 1,brickx,bricky,1
if brickgrid(brickcolumn,brickrow)=3 then paste image 3,brickx,bricky,1
if brickgrid(brickcolumn,brickrow)=4 then paste image 2,brickx,bricky,1
if brickgrid(brickcolumn,brickrow)=5 then paste image 5,brickx,bricky,1
endif
next brickcolumn
next brickrow
`sync
return
Rem **** Check Matches Logic ****
CheckMatches:
`Vertical Match
if brickrow=0 then goto CheckMatch2
if brickgrid(brickcolumn,brickrow)=brickcolor
if brickrow=0 then goto CheckMatch2
if brickgrid(brickcolumn,brickrow-1)=brickcolor
if brickrow=1 then goto CheckMatch2
if brickgrid(brickcolumn,brickrow-2)=brickcolor
brickgrid(brickcolumn,brickrow+1)=0
brickgrid(brickcolumn,brickrow)=0
brickgrid(brickcolumn,brickrow-1)=0
brickgrid(brickcolumn,brickrow-2)=0
matches=matches-1
play sound 6
gosub AddScore
return
endif
endif
endif
CheckMatch2:
`Horizontal Match (2 Places Left)
if brickcolumn=0 then goto CheckMatch3
if brickgrid(brickcolumn-1,brickrow)=brickcolor
if brickcolumn<2 then goto CheckMatch3
if brickgrid(brickcolumn-2,brickrow)=brickcolor
brickgrid(brickcolumn-2,brickrow)=0
brickgrid(brickcolumn-1,brickrow)=0
brickgrid(brickcolumn,brickrow)=0
matches=matches-1
play sound 6
gosub AddScore
return
endif
endif
CheckMatch3:
`Horizontal Match (1 Left/1 Right)
if brickcolumn=0 then goto CheckMatch4
if brickgrid(brickcolumn-1,brickrow)=brickcolor
if brickcolumn=7 then goto CheckMatch4
if brickgrid(brickcolumn+1,brickrow)=brickcolor
brickgrid(brickcolumn-1,brickrow)=0
brickgrid(brickcolumn,brickrow)=0
brickgrid(brickcolumn+1,brickrow)=0
matches=matches-1
play sound 6
gosub AddScore
return
endif
endif
CheckMatch4:
`Horizontal Match (2 Right)
if brickcolumn=7 then return
if brickgrid(brickcolumn+1,brickrow)=brickcolor
if brickcolumn>5 then return
if brickgrid(brickcolumn+2,brickrow)=brickcolor
brickgrid(brickcolumn,brickrow)=0
brickgrid(brickcolumn+1,brickrow)=0
brickgrid(brickcolumn+2,brickrow)=0
matches=matches-1
play sound 6
gosub AddScore
return
endif
endif
return
Rem **** Add Match Points To Score ****
AddScore:
if brickcolor=1 then points=5*3
if brickcolor=2 then points=10*3
if brickcolor=3 then points=15*3
if brickcolor=4 then points=20*3
if brickcolor=5 then points=25*3
score=score+points
return
Rem **** Level Bonus ****
LevelBonus:
cls
`Set Bonus Points Possible
bp=level*750
`Bonus can't exceed 5000 points
if bp>5000 then bp=5000
center text screen width()/2,screen height()-400,"Bonus"
bonus$=str$(bp)
center text screen width()/2,screen height()-370,bonus$
sync
wait 1000
`Reset Penalty
penalty=0
`Figure up Penalty - Point value of all bricks not removed
for brickrow=27 to 0 step -1
for brickcolumn=7 to 0 step -1
if brickgrid(brickcolumn,brickrow)=1
penalty=penalty+5
endif
if brickgrid(brickcolumn,brickrow)=2
penalty=penalty+10
endif
if brickgrid(brickcolumn,brickrow)=3
penalty=penalty+15
endif
if brickgrid(brickcolumn,brickrow)=4
penalty=penalty+20
endif
if brickgrid(brickcolumn,brickrow)=5
penalty=penalty+25
endif
next brickcolumn
next brickrow
`Show Penalty
center text screen width()/2,screen height()-320,"Penalty"
penalty$=str$(penalty)
center text screen width()/2,screen height()-290,penalty$
sync
wait 1000
`Figure up actual bonus points awarded
award=(bp-penalty)
`Show actual bonus points awarded
award$=str$(award)
center text screen width()/2,screen height()-240,"Bonus Awarded"
center text screen width()/2,screen height()-210,award$
sync
wait 1000
`Add bonus to score
score=score+award
wait 3000
return
Rem **** Game Over ****
GameOver:
cls
set text size 100
ink rgb(255,255,255),rgb(0,0,0)
center text screen width()/2,screen height()-450,"Game Over"
center text screen width()/2,screen height()-270,"Final Score"
score$=str$(score)
center text screen width()/2,screen height()-220,score$
sync
wait 1000*8
stop music track
cls
goto Title
Rem **** Quit Program ****
Quit:
cls
stop music track
stop music 1
end
And an EXE can be found here:
http://forum.thegamecreators.com/?m=forum_view&t=181355&b=8
Since this EXE was compiled with a different computer system, see if it will run on your computer.