smallg and SirFire i forgot to thank you for taking the time to help me by replying to this thread, so thx
. btw sirfire im using a skybox, so poly count couldn't really be a problem for me in this case. and crighton lol thx
again ur logic is spot-on. the skybox rotation works although now that its rotating i'm having the same problem that i was and still am having with the text: when i click cards the text disappears and the skybox stops rotating. I understand completely what you said about clicking cards leaving the main loop and all, but I can't fathom a solution
any ideas anyone?
Here's the code:
`create data type for array
type CardInfo
Color as integer
Value$ as string
AlreadyMatched as boolean
FaceDown as boolean
FaceUp as boolean
Suit as integer
CardXPos as integer
CardYPos as integer
endtype
`create arrays and variables
dim Deck(52) as CardInfo `deck
dim FirstCard(1) as CardInfo `first clicked card info holder variable for match detecion
dim SecondCard(1) as CardInfo `second clicked card info holder variable for match detecion
dim Card(1) as CardInfo `function parameter being passed to match detection function
dim Shuffler(1) as CardInfo `variable to hold data during shuffle function
global NumberOfCardsFlipped = 0 `keeps track of how many cards have been flipped over
global FirstCardClicked `1st card clicked, info to be passed to card flipping and match detecting function
global SecondCardClicked `2nd card clicked, info to be passed to card flipping and match detecting function
global CardsToBeMatched `keeps track of how many cards have been passed to match detecting function
global FirstCard `holds info for 1st card sent to match detecting function
global SecondCard `holds info for 2nd card sent to match detecting function
global MatchedCards `holds number of cards that have been matched together for GameOver() function
global NowPlaying = 9 `holds number of song being played in MusicPlayer() function
`setup basic card info
data 0,0, 125,0, 250,0, 375,0, 500,0, 625,0, 750,0, 875,0, 1000,0,
data 0,-175, 125,-175, 250,-175, 375,-175, 500,-175, 625,-175, 750,-175, 875,-175, 1000,-175,
data 0,-350, 125,-350, 250,-350, 375,-350, 500,-350, 625,-350, 750,-350, 875,-350, 1000,-350,
data 0,-525, 125,-525, 250,-525, 375,-525, 500,-525, 625,-525, 750,-525, 875,-525, 1000,-525,
data 0,-700, 125,-700, 250,-700, 375,-700, 500,-700, 625,-700, 750,-700, 875,-700, 1000,-700,
data 0,-875, 125,-875, 250,-875, 375,-875, 500,-875, 625,-875, 750,-875, 875,-875, 1000,-875,
data 0,-1050, 125,-1050, 250,-1050, 375,-1050, 500,-1050, 625,-1050, 750,-1050
for z = 1 to 52
read Deck(z).CardXPos
read Deck(z).CardYPos
Deck(z).FaceDown = 1
Deck(z).FaceUp = 0
Deck(z).AlreadyMatched = 0
next z
`load sounds
load sound "cardclick.wav", 1
`load music
for MusicLoad = 1 to 9
load music "" + str$(MusicLoad) + ".mp3", MusicLoad
next MusicLoad
`load images
`for ImageLoad = 1 to 52
` load image ImageLoad, " "
`next ImageLoad
MainMenu()
`********************************************************MAIN LOOP***********************************************************
while escapekey() <> 1 `hit Escape to exit game
text 400, 10, str$(screen fps())
angle = wrapvalue(angle) + 1
rotate object 53, 0, angle, 0
MusicPlayer()
Clock()
MouseControl()
GameOver()
endwhile
`*****************************************************END OF MAIN LOOP********************************************************
`------------------------------------------------------END OF PROGRAM--------------------------------------------------------
`---------------------------------------------------------FUNCTIONS----------------------------------------------------------
FUNCTION MainMenu() `main menu
cls
load image "MainMenuBackground.bmp", 53
paste image 53,0,0
set text font "Century Gothic"
set text size 30
ink rgb(79,114,218),0
text 60, 568, "New Game"
text 60, 618, "Options"
text 60, 668, "Quit"
`suspend for mouse
do
if mouseclick() = 1
if mousex() >= 60 and mousex() <= 205
if mousey() >=568 and mousey() <= 598
play sound 1
ink rgb(255,255,255),0
text 60, 568, "New Game"
wait 1500
delete image 53
cls
StartUp()
exit
endif
endif
if mousex() >= 60 and mousex() <= 160
if mousey() >=618 and mousey() <= 648
ink rgb(255,255,255),0
text 60, 618, "Options"
play sound 1
wait 1500
`Options()
exit
endif
endif
if mousex() >= 60 and mousex() <= 100
if mousey() >=668 and mousey() <= 698
ink rgb(255,255,255),0
text 60, 668, "Quit"
play sound 1
wait 1500
end
endif
endif
endif
loop
ENDFUNCTION
FUNCTION StartUp()
`setup camera
make camera 1
Set Camera Range 1, 30.0,170000.0
position camera 1, 500, -1000, -1000 `plain is facing toward monitor, so alter z instead of y for raised camera
point camera 1, 500, 0, 1000
`load background
load object "skybox.x", 53
SET OBJECT 53, 1, 1, 0, 0, 0
scale object 53, 170000, 170000, 170000
rotate object 53, 0, 210, 0
`start music
play music NowPlaying
loop music NowPlaying
set music volume NowPlaying, 70
StartGame()
ENDFUNCTION
FUNCTION StartGame() `draws the deck onscreen and assigns objects card values and textures
`create deck entities
LastCardPos = 0 `keeps track of z value of card in deck
for a = 52 to 1 step -1
FallHeight = -120
make object box a, 100, 130, 0
`Assign card a value using MOD, and a specific color depending on what card it is, to group the cards by color
value = a mod 13
if value <= 0 then Deck(a).Value$ = "A": color object a, rgb(0, 255, 0): Deck(a).Color = rgb(0, 255, 0)
if value <=9 and value >= 1 then Deck(a).Value$ = str$(value + 1): color object a, rgb((value^value)+ 100, (value*25)+30, value*12):Deck(a).Color = rgb((value^value)+ 100, (value*25)+30, value*12)
if value = 10 then Deck(a).Value$ = "J": color object a, rgb(255,255,255): Deck(a).Color = rgb(255,255,255)
if value = 11 then Deck(a).Value$ = "Q": color object a, rgb(0,0,255):Deck(a).Color = rgb(0,0,255)
if value = 12 then Deck(a).Value$ = "K": color object a, rgb(255,0,0): Deck(a).Color = rgb(255,0,0)
`Assign Suit
Deck(a).Suit = int(a / 13.1) + 1
`make animation for cards falling onto deck
for b = 1 to 5
position object a, 0, 200, FallHeight `y pos is 200 so that deck will sit beyond card dealing area
FallHeight = FallHeight + 20
wait 1
next b
position object a, 0, 200, LastCardPos `these 2 lines place cards slightly above each other
LastCardPos = LastCardPos - 1 `creating the appearance of a stack of cards
next a
Shuffle()
ENDFUNCTION
FUNCTION Deal() `deals the cards out onscreen
for a = 1 to 52
position object a, Deck(a).CardXPos, Deck(a).CardYPos, 1
wait 30
next a
ENDFUNCTION
FUNCTION Shuffle() `randomizes the card data
randomize timer()
for n = 1 to 5000
card1 = rnd(51) + 1
card2 = rnd(51) + 1
if card1 = card2 `make sure each of the 52 cards are represented by making sure that the 2 variables that
while card1 = card2 `store the random object numbers are not the same
card1 = rnd(51) + 1
card2 = rnd(51) + 1
endwhile
endif
Shuffler(1).Color = Deck(card1).Color
Shuffler(1).Value$ = Deck(card1).Value$
Shuffler(1).AlreadyMatched = Deck(card1).AlreadyMatched
Shuffler(1).FaceDown = Deck(card1).FaceDown
Shuffler(1).FaceUp = Deck(card1).FaceUp
Shuffler(1).Suit = Deck(card1).Suit
Deck(card1).Color = Deck(card2).Color
Deck(card1).Value$ = Deck(card2).Value$
Deck(card1).AlreadyMatched = Deck(card2).AlreadyMatched
Deck(card1).FaceDown = Deck(card2).FaceDown
Deck(card1).FaceUp = Deck(card2).FaceUp
Deck(card1).Suit = Deck(card2).Suit
color object card1, Deck(card1).Color
Deck(card2).Color = Shuffler(1).Color
Deck(card2).Value$ = Shuffler(1).Value$
Deck(card2).AlreadyMatched = Shuffler(1).AlreadyMatched
Deck(card2).FaceDown = Shuffler(1).FaceDown
Deck(card2).FaceUp = Shuffler(1).FaceUp
Deck(card2).Suit = Shuffler(1).Suit
color object card2, Deck(card2).Color
next n
Deal()
ENDFUNCTION
FUNCTION FlipFirstCardUp(WhichCardOne) `flips the first card over that is clicked
if Deck(WhichCardOne).AlreadyMatched = 1 `if the card has already been matched don't continue trying to match it again
exitfunction
endif
if Deck(WhichCardOne).FaceUp = 0 and Deck(WhichCardOne).FaceDown = 1 `if card is face down, set its values to face up
Deck(WhichCardOne).FaceDown = 0
Deck(WhichCardOne).FaceUp = 1
else
for ErrorMessage = 1 to 70 `if its already face up, give error message
text (screen width() - ((Screen width()/10) * 9)), (screen height() - ((Screen height()/10) * 9)), "Please try another card."
wait 1
next ErrorMessage
exitfunction
endif
play sound 1
for MoveUp = 1 to 5 `if card is being set to face up, animate the card flipping over and being tilted
move object up WhichCardOne, 6 `toward the player
wait 2
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCardOne, 18
wait 2
next TwistLeft
for PitchDown = 1 to 5
pitch object down WhichCardOne, 6
wait 2
next PitchDown
wait 1000 `short delay for card to face toward player
for PitchUp = 1 to 5
pitch object up WhichCardOne, 6
wait 2
next PitchUp
for MoveDown = 1 to 5
move object down WhichCardOne, 6
wait 2
next MoveDown
MatchDetector(WhichCardOne) `send the first card's data to match detection functino
ENDFUNCTION
FUNCTION FlipSecondCardUp(WhichCardTwo) `flips 2nd card over that is flipped
if Deck(WhichCardTwo).AlreadyMatched = 1 `same as function above
exitfunction
endif
if Deck(WhichCardTwo).FaceUp = 0 and Deck(WhichCardTwo).FaceDown = 1 `same as function above
Deck(WhichCardTwo).FaceDown = 0
Deck(WhichCardTwo).FaceUp = 1
else
for ErrorMessage = 1 to 70 `same as function above
text (screen width() - ((Screen width()/10) * 9)), (screen height() - ((Screen height()/10) * 9)), "Please try another card."
wait 1
next ErrorMessage
exitfunction
endif
play sound 1
for MoveUp = 1 to 5 `same as function above
move object up WhichCardTwo, 6
wait 2
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCardTwo, 18
wait 2
next TwistLeft
for PitchDown = 1 to 5
pitch object down WhichCardTwo, 6
wait 2
next PitchDown
wait 1000
for PitchUp = 1 to 5
pitch object up WhichCardTwo, 6
wait 2
next PitchUp
for MoveDown = 1 to 5
move object down WhichCardTwo, 6
wait 2
next MoveDown
MatchDetector(WhichCardTwo) `sends 2nd card's data to match detection function
ENDFUNCTION
FUNCTION FlipCardDown(WhichCard) `turns card back over
for MoveUp = 1 to 5
move object up WhichCard, 6
wait 5
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCard, 18
wait 5
next TwistLeft
for MoveDown = 1 to 5
move object down WhichCard, 6
wait 5
next MoveDown
Deck(WhichCard).FaceDown = 1 `sets card data back to face down
Deck(WhichCard).FaceUp = 0
ENDFUNCTION
FUNCTION MouseControl() `let player use mouse to interact with cards
if MouseClick() = 1 `if mouse is clicked
blanktester = pick object (mousex(), mousey(), 1, 52)
if blanktester = 0
exitfunction
endif
NumberOfCardsFlipped = NumberOfCardsFlipped + 1 `increment how many cards have been clicked so far
if NumberOfCardsFlipped = 1
FirstCardClicked = pick object (mousex(), mousey(),1,52) `if 1, send that card data to card flipper
FlipFirstCardUp(FirstCardClicked)
exitfunction
else
if NumberOfCardsFlipped = 2
SecondCardClicked = pick object (mousex(), mousey(),1,52) `if 2 send 2nd card data to card flipper
FlipSecondCardUp(SecondCardClicked)
NumberOfCardsFlipped = 0 `set # of cards clicked back to 0 for next match test
endif
endif
endif
ENDFUNCTION
FUNCTION MatchDetector(Card)
CardsToBeMatched = CardsToBeMatched + 1
if CardsToBeMatched = 1
FirstCard = Card
exitfunction
endif
if CardsToBeMatched = 2
SecondCard = Card
if Deck(FirstCard).Value$ = Deck(SecondCard).Value$
Deck(FirstCard).AlreadyMatched = 1
Deck(SecondCard).AlreadyMatched = 1
ghost object on FirstCard
ghost object on SecondCard
for fader = 10 to 1 step -1
fade object FirstCard, fader * 10
fade object SecondCard, fader * 10
wait 5
next fader
delete object FirstCard
delete object SecondCard
`hide object FirstCard
`hide object SecondCard
CardsToBeMatched = 0
MatchedCards = MatchedCards + 2
exitfunction MatchedCards
else
FlipCardDown(FirstCard)
Deck(FirstCard).FaceUp = 0
Deck(FirstCard).FaceDown = 1
FlipCardDown(SecondCard)
Deck(SecondCard).FaceUp = 0
Deck(SecondCard).FaceDown = 1
CardsToBeMatched = 0
endif
endif
ENDFUNCTION MatchedCards
FUNCTION Clock()
ink rgb(255,153,0), 0
`line 5,5,175,5
`line 5,5,5,28
line 5,28,155,28
line 155,5,155,28
seconds$ = right$(get time$(), 3)
minutes$ = mid$(get time$(), 4) + mid$(get time$(), 5)
set text font "Arial"
set text size 16
if left$(get time$(), 1) = "0"
hours$ = mid$(get time$(), 2) + mid$(get time$(), 3)
text 10,10, "The time is: " + hours$ + minutes$ + seconds$ + "am"
else
if left$(get time$(), 2) <> "10" and left$(get time$(), 2) <> "11" and left$(get time$(), 2) <> "12"
hours = (val(left$(get time$(), 2)) - 12)
hours$ = str$(hours) + mid$(get time$(), 3)
text 10,10, "The time is: " + hours$ + minutes$ + seconds$ + "pm"
else
hours$ = left$(get time$(), 3)
text 10,10, "The time is: " + hours$ + minutes$ + seconds$ + "am"
endif
endif
ENDFUNCTION
FUNCTION GameOver()
if MatchedCards >=52
cls
create bitmap 54, 1024, 768
current = music volume(NowPlaying)
negator = current / 2.5
for volume = 1 to negator
current = current - 2.5
set music volume NowPlaying, current
next volume
stop music NowPlaying
delete camera 1
for done = 1 to 53
delete object done
next done
set current bitmap 0
set text size 25
ink rgb(255,255,255), 0
do
center text 512, 384, "Press '1' to play again, Press 'M' to go to the Main Menu,Press 'Q' to quit..."
AfterGame$ = inkey$()
select AfterGame$
case "1": StartUp(): exit: endcase
case "q": end: endcase
case "m": MainMenu(): exit: endcase
endselect
loop
endif
ENDFUNCTION
FUNCTION MusicPlayer()
if inkey$() = "1" then stop music NowPlaying: play music 1: loop music 1: NowPlaying = 1: exitfunction NowPlaying
if inkey$() = "2" then stop music NowPlaying: play music 2: loop music 2: NowPlaying = 2: exitfunction NowPlaying
if inkey$() = "3" then stop music NowPlaying: play music 3: loop music 3: NowPlaying = 3: exitfunction NowPlaying
if inkey$() = "4" then stop music NowPlaying: play music 4: loop music 4: NowPlaying = 4: exitfunction NowPlaying
if inkey$() = "5" then stop music NowPlaying: play music 5: loop music 5: NowPlaying = 5: exitfunction NowPlaying
if inkey$() = "6" then stop music NowPlaying: play music 6: loop music 6: NowPlaying = 6: exitfunction NowPlaying
if inkey$() = "7" then stop music NowPlaying: play music 7: loop music 7: NowPlaying = 7: exitfunction NowPlaying
if inkey$() = "8" then stop music NowPlaying: play music 8: loop music 8: NowPlaying = 8: exitfunction NowPlaying
if inkey$() = "9" then stop music NowPlaying: play music 9: loop music 9: NowPlaying = 9: exitfunction NowPlaying
if inkey$() = "*" then stop music NowPlaying
if inkey$() = "-" then set music volume NowPlaying, (music volume(NowPlaying) - 10)
if inkey$() = "+" then set music volume NowPlaying, (music volume(NowPlaying) + 10)
ink rgb(255,153,0), 0
`line 864,5,1019,5
line 864,28,1019,28
line 864,5,864,28
`line 1019,5,1019,28
center text 941,10, "Now Playing: Track No. " + str$(NowPlaying)
ENDFUNCTION NowPlaying
Thanks as usual, and my specs are in my sig.
DBPro User
PC: WinXP, AthlonXP 2100+ 1.7ghz, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mb DDR400 system RAM. Thank you for your help.