I need help creating checker pieces
Author |
Message |
timmy otoole
|
Posted: Tue Apr 24, 2012 10:32 am Post subject: I need help creating checker pieces |
|
|
What is it you are trying to achieve?
I am trying to create a checkers board game
What is the problem you are having?
I can't create the pieces
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<type oval:record
xpos,ypos:int
end record
var ovals: array 1..12 of oval
ovals(1).xpos:=120
ovals(1).ypos:=100
Please specify what version of Turing you are using
4.1.1
Thanks ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Beastinonyou
![](http://compsci.ca/v3/uploads/user_avatars/10820786614fe1f6d9ccbda.png)
|
Posted: Tue Apr 24, 2012 11:01 am Post subject: Re: I need help creating checker pieces |
|
|
Ok.. you got the co-ordinates ready.. What else do you need to draw Checkers?
You're going to need a width.. 2 different width's for an oval shape, or 1 width and use it for both the x_width and y_width to make a circle.. I'm pretty sure it's more common that checkers are circular rather than oval.
Something along these lines would be good:
Turing: | type PieceData : record
xPos, yPos, xWidth, yWidth, col : int % or 1 width and use for both x and y width's
end record
var rCheckers, bCheckers : array 1 .. 12 of PieceData
for i : 1 .. 12
% Set default checker positions corresponding to where they should be on the grid
rCheckers (i ).col := red
bCheckers (i ).col := black
end for |
Something along these lines would be a relatively easy way to do things. Creating the checkers pieces is really easy.. You're just drawing an oval / circle for the pieces, but you have to keep track of all the piece's co-ordinates.
Something like: Turing: | loop
for i : 1 .. 12
drawfilloval (rCheckers (i ).xPos, rCheckers (i ).yPos, rCheckers (i ).xWidth, rCheckers (i ).yWidth, rCheckers (i ).col )
drawfilloval (bCheckers (i ).xPos, bCheckers (i ).yPos, bCheckers (i ).xWidth, bCheckers (i ).yWidth, bCheckers (i ).col )
end for
% All the other stuff
end loop | Although you could simplify it further, this can give you an idea of how to draw each piece where it should be. |
|
|
|
|
![](images/spacer.gif) |
|
|