Hello Fellow Developers!
So I finished another exercise from the Beginner's guide to Dark Basic entitled the Audio Match Program. The main game works perfectly I believe but once I finished it, I think it stopped since I didn't go to the Score screen. I'm uploading both my code and the program.
Rem Project: AUDIO MATCH GAME!
Rem Created: Monday, March 05, 2012
Rem Designer: Andrew D. South
Rem ***** Main Source File *****
REMSTART
BASIC GAME INFORMATION
IMAGE DATA
IMAGE 1 - CARD CLOSE
IMAGE 2 - CARD SELECTED
IMAGE 3 - MOUSE CURSOR
IMAGE 4 - TITLE IMAGE
IMAGE 5 - WIN IMAGE
SPRITE USAGE
SPRITE 10 - MOUSE CURSOR
SPRITES 50 - 99 - MATCHING CARDS
SOUND USSAGE
SOUNDS 50-75 - SOUNDS TO MATCH
SOUNDS 13 - MATCH FOUND
SOUNDS 14 - MATCH NOT FOUND
REMEND
DATA "level01\123.wav"
DATA "level01\abc.wav"
DATA "level01\ardvark.wav"
DATA "level01\baa.wav"
DATA "level01\bark.wav"
DATA "level01\basic.wav"
DATA "level01\boom.wav"
DATA "level01\clunk.wav"
DATA "level01\cool.wav"
DATA "level01\Dark.wav"
DATA "level01\eek.wav"
DATA "level01\eieio.wav"
DATA "level01\HadAFarm.wav"
DATA "level01\hehehe.wav"
DATA "level01\horse.wav"
DATA "level01\meow.wav"
DATA "level01\moo.wav"
DATA "level01\oink.wav"
DATA "level01\OldMac.wav"
DATA "level01\quack.wav"
DATA "level01\roar.wav"
DATA "level01\squeek.wav"
DATA "level01\wee.wav"
DATA "level01\wild.wav"
DATA "level01\woof.wav"
`Dim all global Variables
DIM LevelData(50)
`1 stores current match
`2 stores first match
`3 stores second match
`4 stores total guesses
`5 stores the number of matches
DIM Selections(5)
SYNC OFF
SYNC RATE 30
MAINTITLE()
LOADSOUNDS()
SYNC
PLAYLEVEL()
END
`LOADS ALL THE SOUNDS
FUNCTION LOADSOUNDS()
`LOAD SOUNDS
FOR count = 50 TO 74
READ WaveFile$
LOAD 3DSOUND WaveFile$, count
`Randomly position it in the world
POSITION SOUND count, rnd(100), rnd(100), rnd(100)
NEXT count
`place the listener in the virutal world
POSITION LISTENER 0,0,0
ROTATE LISTENER 0,0,0
LOAD SOUND "media\Yeah.wav", 13
LOAD SOUND "media\bummer.wav", 14
ENDFUNCTION
`Setup the level
FUNCTION SETUPLEVEL()
`RANDOMIZE THE SOUND
RANDOMSEED = TIMER()
RANDOMIZE RANDOMSEED
FOR count = 1 TO 50
LEVELDATA(count) = 0
NEXT count
slotpicked = RND(49)+1
count2 = 0
FOR count = 50 TO 99
WHILE LEVELDATA(slotpicked) > 0
slotpicked = rnd(49)+1
ENDWHILE
LEVELDATA(slotpicked) = count
NEXT count
FOR count = 1 TO 50
IF LEVELDATA(count) > 74
LEVELDATA(count) = LEVELDATA(count) - 25
ENDIF
NEXT count
`load the images
LOAD IMAGE "card.bmp", 1
LOAD IMAGE "cardselect.bmp", 2
LOAD IMAGE "cursor.bmp", 3
`Centering the cards on the X ROW - Start at 120
`Centering the cards on the Y ROW - start at 40
FOR ypos = 0 TO 4
FOR xpos = 0 TO 9
spritenum = 50+(ypos*10)+xpos
spritex = 40 + (xpos*56)
spritey = 40 + (ypos*56)
SPRITE spritenum, spritex, spritey, 1
NEXT xpos
NEXT ypos
`Set up Mouse
HIDE MOUSE
SPRITE 10, MOUSEX(), MOUSEY(), 3
SHOW ALL SPRITES
`Set up Selection Variables
selections(1) = 0
selections(2) = 0
selections(3) = 0
selections(4) = 0
selections(5) = 0
ENDFUNCTION
`MAIN GAME LOOP
FUNCTION PLAYLEVEL()
setuplevel()
flag = 0
SYNC
WHILE flag = 0
PROCESSMOUSE()
PROCESSCLICKS()
PROCESSMATCHES()
DoWin = PROCESSWIN()
IF DoWin=1
SLEEP 500
PlayAgain = DOTHEWINSCREEN()
IF PlayAgain=1
SETUPLEVEL()
ELSE
flag = 1
ENDIF
ENDIF
SYNC
ENDWHILE
ENDFUNCTION
`process the mouse cursor
FUNCTION PROCESSMOUSE()
SPRITE 10, MOUSEX(), MOUSEY(), 3
ENDFUNCTION
`process mouse clicks
FUNCTION PROCESSCLICKS()
IF MOUSECLICK() <> 1 THEN EXITFUNCTION
cardselected = SPRITE COLLISION(10,0)
`NOT OVER A CARD
IF cardselected = 0 THEN EXITFUNCTION
IF cardselected = Selections(2) THEN EXITFUNCTION
IF cardselected = Selections(3) THEN EXITFUNCTION
IF SOUND PLAYING(13) THEN EXITFUNCTION
IF SOUND PLAYING(14) THEN EXITFUNCTION
FirstSelected = Selections(2) - 49
SecondSelected = Selections(3) - 49
Spx = SPRITE X(cardselected)
Spy = SPRITE Y(cardselected)
SPRITE cardselected, Spx, Spy, 2
Selections(1) = Selections(1) + 1
`Increament it by 1 to pass the Selections(1) info
CurrentSelect = Selections(1) + 1
Selections(CurrentSelect) = cardselected
cardselected = cardselected - 49
PLAY SOUND LEVELDATA(cardselected)
ENDFUNCTION
`Check for matches
FUNCTION PROCESSMATCHES()
Mysel1 = Selections(1)
Mysel2 = Selections(2)
Mysel3 = Selections(3)
If Mysel1 = 2
SLEEP 500
IF LEVELDATA(Mysel2-49) = LEVELDATA(Mysel3-49)
SPRITE Mysel2,-100,-100,1
SPRITE Mysel3,-100,-100,1
PLAY SOUND 13
Selections(5) = Selections(5) + 1
ELSE
SPRITE Mysel2, SPRITE X(Mysel2),SPRITE Y(Mysel2), 1
SPRITE Mysel3, SPRITE X(Mysel3),SPRITE Y(Mysel3), 1
ENDIF
Selections(1) = 0
Selections(2) = 0
Selections(3) = 0
Selections(4) = Selections(4) + 1
ENDIF
ENDFUNCTION
`Check to see if they've won
FUNCTION PROCESSWIN()
flag = 0
IF Selections(5) >= 25 THEN flag = 1
ENDFUNCTION flag
FUNCTION MAINTITLE()
load image "title.bmp",4
PASTE IMAGE 4,0,0
SYNC
WHILE (MOUSECLICK() = 0)
ENDWHILE
DELETE IMAGE 4
CLS
ENDFUNCTION
`307,184 -- Print number of tries
`386,313 to -- The Y of the Y/N
`414,347
FUNCTION DOTHEWINSCREEN()
HIDE ALL SPRITES
SLEEP 2000
SHOW MOUSE
flag = 0
LOAD IMAGE "win.bmp",5
PASTE IMAGE 5,0,0
SET CURSOR 307, 184
PRINT selections(4)
SYNC
WHILE (MOUSECLICK() = 0)
ENDWHILE
mx = MOUSEX()
my = MOUSEY()
IF mx >386 AND mx <414 AND my >313 AND my <347 THEN flag = 1
CLS
ENDFUNCTION flag
When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!