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

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




PostPosted: Thu Mar 17, 2005 11:36 am   Post subject: Checkers help

I have the array for a board

var board:array 1..8,1..8 of int

now how do i draw it?

i think its something to do with
for row:1..8
for col:1..8

but i'm not sure

can anyone help?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Mar 17, 2005 12:57 pm   Post subject: (No subject)

what are you trying to draw? Confused
Bacchus




PostPosted: Thu Mar 17, 2005 12:59 pm   Post subject: (No subject)

im guessing a chekars board, like in title lol try something like this

code:
var board:array 1..8,1..8 of int

var clr:int:=0

for row:1..8
clr+=1
for column:1..8
if clr mod 2=0 then
drawfillbox(maxy-(row*10),column*10,maxy-((row*10)+10),(column*10)+10,7)
else
drawfillbox(maxy-(row*10),column*10,maxy-((row*10)+10),(column*10)+10,12)
end if
clr+=1
end for
end for
Naveg




PostPosted: Thu Mar 17, 2005 1:11 pm   Post subject: (No subject)

so the actual drawing uses no arrays, the array is just a virtual record of whether or not a space is occupied and what colour it is?
Flikerator




PostPosted: Thu Mar 17, 2005 1:25 pm   Post subject: (No subject)

Vladimir wrote:
so the actual drawing uses no arrays, the array is just a virtual record of whether or not a space is occupied and what colour it is?


Why would you need to use an Array to Draw it?

Quote:
var clr : int := 0
for row : 1 .. 8
clr += 1
for column : 1 .. 8
if clr mod 2 = 0 then
drawfillbox (maxy - (row * 40), column * 40, maxy - ((row * 40) + 40), (column * 40) + 40, 7)
else
drawfillbox (maxy - (row * 40), column * 40, maxy - ((row * 40) + 40), (column * 40) + 40, 12)
end if
clr += 1
end for
end for


Better size Wink
Bacchus




PostPosted: Thu Mar 17, 2005 5:02 pm   Post subject: (No subject)

Flikerator wrote:
Better size Wink
lol yes i kno, that was just an example.
Vladimir wrote:
so the actual drawing uses no arrays, the array is just a virtual record of whether or not a space is occupied and what colour it is?
thats true, the drawing doesnt use the array really at all but wat you can then do it use the array to hold checks and such. like you have the array 1..8,1..8 and one part is for rows, while the other is for column, you can store a number in there (ex: 0=empty, 1=black, 2=red) to show who piece is where then you just have to compare numbers and such instead of using whatdotcolor to check
Naveg




PostPosted: Thu Mar 17, 2005 7:26 pm   Post subject: (No subject)

I've seen it suggested that you use a record with colour and occupied like this...

code:
type square:
     record
          red:boolean
          occupied:boolean
     end record


wouldnt it be easier to use an array of ints instead of squares and just say 0=nothing, 1=red, 2=black??
Cervantes




PostPosted: Thu Mar 17, 2005 7:41 pm   Post subject: (No subject)

It depends on how much data you need to store for each square. If you only need to know one thing about your square (ie. whether it's occupied/by who) then it'd probably be easier to forget the type and just use a legend (0 = empty, 1 = occupied by black, etc.) If you need to know, say, occupied status, width in pixels, height in pixels, colour, and various other stuff, then use the type. In checkers, I can't forsee needing any more than occupied status though, so I would do without the type.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: