Computer Science Canada help |
Author: | JonnyBigBoi [ Wed Jan 05, 2005 2:58 pm ] |
Post subject: | help |
how would you lets say make board game pieces start off in a certain spot on the screen? |
Author: | Neo [ Wed Jan 05, 2005 4:59 pm ] |
Post subject: | |
At the start of your program give the variables that will store the location of your piece a specific value. Lets say you wanted to place it in the lower left hand corner at the start of the game, you'd do something like: var pieceX:=50 var pieceY:=50 |
Author: | Cervantes [ Wed Jan 05, 2005 5:13 pm ] | ||||
Post subject: | |||||
If you're going to have board game pieces, I'm going to assume you have a board. If so, make a 2D array for your grid and you can assign flag variables to it. Say a checkers board, 8x8, is what the user is looking at. The array is 1 .. 8, 1 .. 8. If you have only 2 different types of pieces you could make the grid array an integer array and use a code: 0 = empty 1 = player 1 piece 2 = player 2 piece (we'll ignore kings, for now). If you have lots of different pieces, say a chess board, you could still use the integer code and, combined with a case statement, you could make things work. Or you could declare a type like this:
(actually, I think chess uses LETTER:NUMBER, instead of x:y. Either way works, it's a matter of personal preferance.) Then, when you actually want to draw stuff onto the grid:
Anyways, you're question was rather vague, so I decided to try to cover lots, in hopes that I actually answered your question. |