Making a Match Cards game, hopefully everyone knows how that game goes heh. Anyway made the function to deal the cards out from the top of the deck, but when it runs, the cards don't go to their proper spots. I'm trying to set the cards down in an 8x6 grid, the last row will have 6 cards instead of 8 (52 cards in a deck). Could use some help as to why cards won't position properly. Here's the code:
`setup camera
make camera 1
position camera 1, 600, -1500, -1000 `plain is facing toward monitor, so alter z instead of y for raised camera
point camera 1, 600, 0, 900
`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
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
for z = 1 to 52
Deck(z).ObjectNumber = z
next z
`make cards and put deck on screen
MakeDeck()
Deal()
`********************************************************MAIN LOOP***********************************************************
while escapekey() <> 1
endwhile
`*****************************************************END OF MAIN LOOP********************************************************
`------------------------------------------------------END OF PROGRAM--------------------------------------------------------
`---------------------------------------------------------FUNCTIONS----------------------------------------------------------
FUNCTION MakeDeck()`draws the deck onscreen
LastCardPos = 0
for a = 1 to 52
FallHeight = -120
make object box a, 100, 150, 1
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
d = 0
MoveOver = 0 `holds the distance on the x-axis that each card in row will be positioned
for d = 52 to 1 step - 1 `does this function for all 52 cards
position object d, Deck(d).CardXPos, Deck(d).CardYPos, 1
Deck(d).CardXPos = Deck(d).CardXPos + MoveOver
MoveOver = MoveOver + 125
If Deck(d).CardXPos >= 1001 `tests to see if the row being dealt already has 8 cards
Deck(d).CardXPos = 0
Deck(d).CardYPos = Deck(d).CardYPos - 175 `if so, go to a new row and start over
endif
wait 30
next d
ENDFUNCTION
Also, i wanted the movement of each card from the top of the deck to its proper space on the playing area to be animated, like a smooth movement instead of the card disappearing and reappearing. I don't know what commands to use to do that tho, the "move object" command only takes parameters for object number and speed of movement, i need something that will allow me to input a start position and end position i think. I thought of trying a method of using repeated positiob object commands in a loop but couldn't think of the math to handle the position of all 52 cards. Any ideas? Thx in advance.
DBPro User
PC: WinXP, AthlonXP 2100+ 1.7ghz, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 system RAM. Thank you for your help.