2 problems:
1.) when i click to flip a card over, nothing happens. I commented out the mousey() detecting line of my MouseClick() function (to try and figure out where the problem was) and the cards will flip over, so something must be wrong with that line of the code I think, but I can't figure out what it is.
2.) When i comment out the mousey() detecting line of my MouseClick function as stated above, either nothing happens, or the wrong cards will flip over. Thought maybe it had something to do with either the camera angle in reference to mouse x y and z positions, or the Shuffle() function messing up the predetermined x and y positions of the cards...I'm not sure.
Here's the code:
`setup camera
make camera 1
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
`create data type for array
type CardInfo
ace as boolean
king as boolean
queen as boolean
jack as boolean
ten as boolean
nine as boolean
eight as boolean
seven as boolean
six as boolean
five as boolean
four as boolean
three as boolean
two as boolean
FaceDown as boolean
FaceUp as boolean
Suit as integer
`ObjectNumber as integer
CardXPos as integer
CardYPos as integer
endtype
`create array to hold card info
dim Deck(52) as CardInfo
`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
next z
`make cards and put deck on screen
MakeDeck()
`assign each object a card and a suit
CardAssign()
`shuffle the order before dealing
Shuffle()
`deal out the cards
Deal()
`********************************************************MAIN LOOP***********************************************************
while escapekey() <> 1
`click to turn cards over
MouseControl()
endwhile
`*****************************************************END OF MAIN LOOP********************************************************
`------------------------------------------------------END OF PROGRAM--------------------------------------------------------
`---------------------------------------------------------FUNCTIONS----------------------------------------------------------
FUNCTION MakeDeck()`draws the deck onscreen
LastCardPos = 0
for a = 52 to 1 step -1
FallHeight = -120
make object box a, 100, 130, 0
color object a, rgb(rnd(255),rnd(255),rnd(255))
`make animation for deck being built
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
LastCardPos = LastCardPos - 1
next a
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() `randomize the order of the cards in the deck
TempCard as CardInfo
randomize timer()
for n = 1 to 5000
card1 = rnd(51) + 1
card2 = rnd(51) + 1
TempCard = Deck(card1)
Deck(card1) = Deck(card2)
Deck(card2) = TempCard
next n
ENDFUNCTION
FUNCTION FlipCardUp(WhichCard) `animate the card being flipped up
for MoveUp = 1 to 5
move object up WhichCard, 6
wait 10
next MoveUp
for TwistLeft = 1 to 10
turn object left WhichCard, 18
wait 10
next TwistLeft
for PitchDown = 1 to 5
pitch object down WhichCard, 6
wait 10
next PitchDown
wait 1500
for PitchUp = 1 to 5
pitch object up WhichCard, 6
wait 10
next PitchUp
for MoveDown = 1 to 5
move object down WhichCard, 6
wait 10
next MoveDown
Deck(WhichCard).FaceDown = 0
Deck(WhichCard).FaceUp = 1
ENDFUNCTION
FUNCTION MouseControl()`click on cards to turn them over
do
if MouseClick() = 1 `if mouse is clicked
`check to see which cards x and y position holds the area where the mouse was clicked
for a = 1 to 52
if mousex() <= (Deck(a).CardXPos + 50) and mousex() >= (Deck(a).CardXPos - 50)
if mousey() <= (Deck(a).CardYPos + 65) and mousey() >= (Deck(a).CardYPos - 65)
`flip the card face up
FlipCardUp(a)
endif
endif
next a
endif
loop
MouseClicked = 0
ENDFUNCTION
FUNCTION CardAssign() `dictates which objects are which cards
for a = 1 to 52
select a
case 1:; Deck(a).two = 1; Deck(a).Suit = 1; color object a, rgb(255,0,0); endcase `two of hearts
case 2:; Deck(a).two = 1; Deck(a).Suit = 2; color object a, rgb(255,0,0); endcase `two of spades
case 3:; Deck(a).two = 1; Deck(a).Suit = 3; color object a, rgb(255,0,0); endcase `two of clubs
case 4:; Deck(a).two = 1; Deck(a).Suit = 4; color object a, rgb(255,0,0); endcase `two of diamonds
case 5:; Deck(a).three = 1; Deck(a).Suit = 1; color object a, rgb(0,255,0); endcase `three of hearts
case 6:; Deck(a).three = 1; Deck(a).Suit = 2; color object a, rgb(0,255,0); endcase `three of spades
case 7:; Deck(a).three = 1; Deck(a).Suit = 3; color object a, rgb(0,255,0); endcase `three of clubs
case 8:; Deck(a).three = 1; Deck(a).Suit = 4; color object a, rgb(0,255,0); endcase `three of diamonds
case 9:; Deck(a).four = 1; Deck(a).Suit = 1; color object a, rgb(0,0,255); endcase `four of hearts
case 10:; Deck(a).four = 1; Deck(a).Suit = 2; color object a, rgb(0,0,255); endcase `four of spades
case 11:; Deck(a).four = 1; Deck(a).Suit = 3; color object a, rgb(0,0,255); endcase `four of clubs
case 12:; Deck(a).four = 1; Deck(a).Suit = 4; color object a, rgb(0,0,255); endcase `four of diamonds
case 13:; Deck(a).five = 1; Deck(a).Suit = 1; color object a, rgb(255,255,0); endcase `five of hearts
case 14:; Deck(a).five = 1; Deck(a).Suit = 2; color object a, rgb(255,255,0); endcase `five of spades
case 15:; Deck(a).five = 1; Deck(a).Suit = 3; color object a, rgb(255,255,0); endcase `five of clubs
case 16:; Deck(a).five = 1; Deck(a).Suit = 4; color object a, rgb(255,255,0); endcase `five of diamonds
case 17:; Deck(a).six = 1; Deck(a).Suit = 1; color object a, rgb(255,0,255); endcase `six of hearts
case 18:; Deck(a).six = 1; Deck(a).Suit = 2; color object a, rgb(255,0,255); endcase `six of spades
case 19:; Deck(a).six = 1; Deck(a).Suit = 3; color object a, rgb(255,0,255); endcase `six of clubs
case 20:; Deck(a).six = 1; Deck(a).Suit = 4; color object a, rgb(255,0,255); endcase `six of diamonds
case 21:; Deck(a).seven = 1; Deck(a).Suit = 1; color object a, rgb(0,255,255); endcase `seven of hearts
case 22:; Deck(a).seven = 1; Deck(a).Suit = 2; color object a, rgb(0,255,255); endcase `seven of spades
case 23:; Deck(a).seven = 1; Deck(a).Suit = 3; color object a, rgb(0,255,255); endcase `seven of clubs
case 24:; Deck(a).seven = 1; Deck(a).Suit = 4; color object a, rgb(0,255,255); endcase `seven of diamonds
case 25:; Deck(a).eight = 1; Deck(a).Suit = 1; color object a, rgb(255,255,255); endcase `eight of hearts
case 26:; Deck(a).eight = 1; Deck(a).Suit = 2; color object a, rgb(255,255,255); endcase `eight of spades
case 27:; Deck(a).eight = 1; Deck(a).Suit = 3; color object a, rgb(255,255,255); endcase `eight of clubs
case 28:; Deck(a).eight = 1; Deck(a).Suit = 4; color object a, rgb(255,255,255); endcase `eight of diamonds
case 29:; Deck(a).nine = 1; Deck(a).Suit = 1; color object a, rgb(0,0,0); endcase `nine of hearts
case 30:; Deck(a).nine = 1; Deck(a).Suit = 2; color object a, rgb(0,0,0); endcase `nine of spades
case 31:; Deck(a).nine = 1; Deck(a).Suit = 3; color object a, rgb(0,0,0); endcase `nine of clubs
case 32:; Deck(a).nine = 1; Deck(a).Suit = 4; color object a, rgb(0,0,0); endcase `nine of diamonds
case 33:; Deck(a).ten = 1; Deck(a).Suit = 1; color object a, rgb(125,125,125); endcase `ten of hearts
case 34:; Deck(a).ten = 1; Deck(a).Suit = 2; color object a, rgb(125,125,125); endcase `ten of spades
case 35:; Deck(a).ten = 1; Deck(a).Suit = 3; color object a, rgb(125,125,125); endcase `ten of clubs
case 36:; Deck(a).ten = 1; Deck(a).Suit = 4; color object a, rgb(125,125,125); endcase `ten of diamonds
case 37:; Deck(a).jack = 1; Deck(a).Suit = 1; color object a, rgb(0,125,125); endcase `jack of hearts
case 38:; Deck(a).jack = 1; Deck(a).Suit = 2; color object a, rgb(0,125,125); endcase `jack of spades
case 39:; Deck(a).jack = 1; Deck(a).Suit = 3; color object a, rgb(0,125,125); endcase `jack of clubs
case 40:; Deck(a).jack = 1; Deck(a).Suit = 4; color object a, rgb(0,125,125); endcase `jack of diamonds
case 41:; Deck(a).queen = 1; Deck(a).Suit = 1; color object a, rgb(125,0,125); endcase `queen of hearts
case 42:; Deck(a).queen = 1; Deck(a).Suit = 2; color object a, rgb(125,0,125); endcase `queen of spades
case 43:; Deck(a).queen = 1; Deck(a).Suit = 3; color object a, rgb(125,0,125); endcase `queen of clubs
case 44:; Deck(a).queen = 1; Deck(a).Suit = 4; color object a, rgb(125,0,125); endcase `queen of diamonds
case 45:; Deck(a).king = 1; Deck(a).Suit = 1; color object a, rgb(125,125,0); endcase `king of hearts
case 46:; Deck(a).king = 1; Deck(a).Suit = 2; color object a, rgb(125,125,0); endcase `king of spades
case 47:; Deck(a).king = 1; Deck(a).Suit = 3; color object a, rgb(125,125,0); endcase `king of clubs
case 48:; Deck(a).king = 1; Deck(a).Suit = 4; color object a, rgb(125,125,0); endcase `king of diamonds
case 49:; Deck(a).ace = 1; Deck(a).Suit = 1; color object a, rgb(147,183,44); endcase `ace of hearts
case 50:; Deck(a).ace = 1; Deck(a).Suit = 2; color object a, rgb(147,183,44); endcase `ace of spades
case 51:; Deck(a).ace = 1; Deck(a).Suit = 3; color object a, rgb(147,183,44); endcase `ace of clubs
case 52:; Deck(a).ace = 1; Deck(a).Suit = 4; color object a, rgb(147,183,44); endcase `ace of diamonds
endselect
next a
ENDFUNCTION
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.