Computer Science Canada

checkers board layout

Author:  Naveg [ Sun Jan 23, 2005 11:30 am ]
Post subject:  checkers board layout

will this work ?? or am i gonna have to learn arrays to be able to move the pieces

code:

setscreen ("graphics:320;320,nobuttonbar")

var boardx : int := 0
var boardy : int := 0

for row : 0 .. 7
    for column : 0 .. 7

        boardx := column * 40
        boardy := row * 40

        if (row rem 2 = 0 and column rem 2 = 0)
                or (row rem 2 = 1 and column rem 2 = 1) then
            drawfillbox (boardx, boardy, boardx + 40, boardy + 40, 91)

            if row = 0 or row = 1 or row = 2 then
                drawfilloval (boardx + 20, boardy + 20, 15, 15, 4)
            elsif row = 5 or row = 6 or row = 7 then
                drawfilloval (boardx + 20, boardy + 20, 15, 15, 2)
            end if

        else
            drawfillbox (boardx, boardy, boardx + 40, boardy + 40, 255)

        end if

    end for
end for

Author:  Neo [ Sun Jan 23, 2005 11:39 am ]
Post subject: 

Yes you'll need x and y coords for each piece, so an array is the way to go.

Author:  Naveg [ Sun Jan 23, 2005 11:44 am ]
Post subject: 

ok so i'm gonna need some help

Author:  Cervantes [ Sun Jan 23, 2005 11:52 am ]
Post subject: 

Check out an array tutorial or two.

Author:  MysticVegeta [ Sun Jan 23, 2005 12:41 pm ]
Post subject: 

Cervantes wrote:
Check out an array tutorial or two.

As cervantes mentioned check out the second link he posted. 2d arryas are great for makiong a layout of a checkerboard!!!!

Author:  person [ Tue Jan 25, 2005 5:29 pm ]
Post subject: 

u can learn arrays but if u really dont get it, u can just use lots of variables. but seriously.. arrays will save u a ton of time, so use arrays! Very Happy Very Happy Very Happy

Author:  Naveg [ Tue Jan 25, 2005 6:33 pm ]
Post subject: 

ok let me rephrase my question. The board and pieces are drawn using for loops and if statements. It works. The question is, will it be possible to have the pieces move and stuff with the setup like this, or are arrays a MUST?

Author:  cycro1234 [ Tue Jan 25, 2005 7:40 pm ]
Post subject: 

Well, u might have to use arrays when checking for things such as jumping over an enemy, or kinging someone. To move the pieces, u cud try using the mouse command "mouswhere" and have the pice follow the mouse. But then u'd have to make boundries so the user can't put the pieces anywhere he/she wants....

I love checkers! Good luck wit it, nd if its not a final project or sometin, PM me nd i'll help as best as i can.

Author:  person [ Tue Jan 25, 2005 8:18 pm ]
Post subject: 

now, if u dont like arrays for some odd reason, or u dont like mousewhere, u can always select a piece, and then using the arrow key to move it

Author:  person [ Tue Jan 25, 2005 8:20 pm ]
Post subject: 

btw, y dont u want to use arrays

Author:  Naveg [ Tue Jan 25, 2005 8:39 pm ]
Post subject: 

cause i dont know how to use em to draw a board, and how to apply them to identify each piece....the tutorials didnt help me so much

Author:  basketball4ever [ Wed Jan 26, 2005 1:10 am ]
Post subject: 

it IS possible, but your looking at around 1000-2000 lines just from the board, and not even the processing of each card (money/go to jail)

you just have to set a coordinate as position for each player... so that the position = position + dice roll

then u just set the coordinates for each position for example: (there should be 36 different positions for monopoly i believe) so position 1 (start) would be like (0,500) then position 2 (50,500) and so on...

strongly dont recomend it cos it takes alot of lines and trouble... but meh if you want it this way Rolling Eyes its easier with arrays definetly Razz

Author:  Trojan Man [ Wed Jan 26, 2005 3:28 am ]
Post subject: 

You'll be able to move the pieces without using arrays without much problem, but then when it comes to the rules of the game, that's gonna be a pain in the ass.
Quote:

it IS possible, but your looking at around 1000-2000 lines just from the board, and not even the processing of each card (money/go to jail)

you just have to set a coordinate as position for each player... so that the position = position + dice roll

then u just set the coordinates for each position for example: (there should be 36 different positions for monopoly i believe) so position 1 (start) would be like (0,500) then position 2 (50,500) and so on...

strongly dont recomend it cos it takes alot of lines and trouble... but meh if you want it this way its easier with arrays definetly

Umm, not to be mean or anything, but I think this topic is about checkers, not monopoly...

Author:  basketball4ever [ Wed Jan 26, 2005 2:06 pm ]
Post subject: 

Trojan Man wrote:
You'll be able to move the pieces without using arrays without much problem, but then when it comes to the rules of the game, that's gonna be a pain in the ass.
Quote:

it IS possible, but your looking at around 1000-2000 lines just from the board, and not even the processing of each card (money/go to jail)

you just have to set a coordinate as position for each player... so that the position = position + dice roll

then u just set the coordinates for each position for example: (there should be 36 different positions for monopoly i believe) so position 1 (start) would be like (0,500) then position 2 (50,500) and so on...

strongly dont recomend it cos it takes alot of lines and trouble... but meh if you want it this way its easier with arrays definetly

Umm, not to be mean or anything, but I think this topic is about checkers, not monopoly...


Quote:
for example

Smile make him think for himself Smile

Author:  cycro1234 [ Wed Jan 26, 2005 3:43 pm ]
Post subject: 

Just as used 2 for loops to create the gameboard, you can use an array to create empty variables for each space. That is, assign each variable a value of "0" if there is no piece, "1" if theres a player 1 piece, and "2" if there's a player 2 piece. Then, u can check to see position of the pieces using if statements.

Author:  person [ Wed Jan 26, 2005 6:40 pm ]
Post subject: 

wouldnt true/false be better than 1,2,3 since then, u can use buttons for turns


: