
-----------------------------------
Naveg
Thu Mar 17, 2005 11:36 am

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?

-----------------------------------
Tony
Thu Mar 17, 2005 12:57 pm


-----------------------------------
what are you trying to draw? :?

-----------------------------------
Bacchus
Thu Mar 17, 2005 12:59 pm


-----------------------------------
im guessing a chekars board, like in title lol try something like this

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
Thu Mar 17, 2005 1:11 pm


-----------------------------------
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
Thu Mar 17, 2005 1:25 pm


-----------------------------------
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?

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 ;)

-----------------------------------
Bacchus
Thu Mar 17, 2005 5:02 pm


-----------------------------------
Better size ;) lol yes i kno, that was just an example. 
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
Thu Mar 17, 2005 7:26 pm


-----------------------------------
I've seen it suggested that you use a record with colour and occupied like this...

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
Thu Mar 17, 2005 7:41 pm


-----------------------------------
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.
