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

Username:   Password: 
 RegisterRegister   
 I need help creating checker pieces
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
timmy otoole




PostPosted: 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
Turing:





Please specify what version of Turing you are using
4.1.1

Thanks Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Beastinonyou




PostPosted: 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.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: