Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JonnyBigBoi




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Neo




PostPosted: Wed Jan 05, 2005 4:59 pm   Post subject: (No 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
Cervantes




PostPosted: Wed Jan 05, 2005 5:13 pm   Post subject: (No 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:

code:

type player_t :
    record
        pawn : array 1 .. 8 of
            record
                x, y : int
                alive, firstmove, reached_other_side : boolean
                %firstmove necessary because pawn's can move two spaces on the first move
                %reached_other_side: if true, let the user select a piece to replace the pawn with
            end record
        bishop : array 1 .. 2 of
            record
                x, y : int
                alive : boolean
            end record
       %other pieces
    end record

var player_1 : player_t
%initialize stuff

var player_2 : player_t
%initialize stuff

(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:

code:

Pic.Draw (piece, x*square_width, y * square_height, picCopy)


Anyways, you're question was rather vague, so I decided to try to cover lots, in hopes that I actually answered your question.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: