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

Username:   Password: 
 RegisterRegister   
 checkers board layout
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Naveg




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Neo




PostPosted: Sun Jan 23, 2005 11:39 am   Post subject: (No subject)

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




PostPosted: Sun Jan 23, 2005 11:44 am   Post subject: (No subject)

ok so i'm gonna need some help
Cervantes




PostPosted: Sun Jan 23, 2005 11:52 am   Post subject: (No subject)

Check out an array tutorial or two.
MysticVegeta




PostPosted: Sun Jan 23, 2005 12:41 pm   Post subject: (No 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!!!!
person




PostPosted: Tue Jan 25, 2005 5:29 pm   Post subject: (No 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
Naveg




PostPosted: Tue Jan 25, 2005 6:33 pm   Post subject: (No 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?
cycro1234




PostPosted: Tue Jan 25, 2005 7:40 pm   Post subject: (No 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.
Sponsor
Sponsor
Sponsor
sponsor
person




PostPosted: Tue Jan 25, 2005 8:18 pm   Post subject: (No 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
person




PostPosted: Tue Jan 25, 2005 8:20 pm   Post subject: (No subject)

btw, y dont u want to use arrays
Naveg




PostPosted: Tue Jan 25, 2005 8:39 pm   Post subject: (No 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
basketball4ever




PostPosted: Wed Jan 26, 2005 1:10 am   Post subject: (No 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
Trojan Man




PostPosted: Wed Jan 26, 2005 3:28 am   Post subject: (No 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...
basketball4ever




PostPosted: Wed Jan 26, 2005 2:06 pm   Post subject: (No 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
cycro1234




PostPosted: Wed Jan 26, 2005 3:43 pm   Post subject: (No 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.
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: