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

Username:   Password: 
 RegisterRegister   
 Checkerboard program code needed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Schaef




PostPosted: Thu Dec 11, 2003 10:16 pm   Post subject: Checkerboard program code needed

I need a code for a checker board that has sqaures that are 50 pixels by 50 pixels and has 8 rows and 8 colums
Sponsor
Sponsor
Sponsor
sponsor
Homer_simpson




PostPosted: Thu Dec 11, 2003 10:37 pm   Post subject: (No subject)

well basically u are going to need a 2d arrow like this: board_array : array 1..8,1..8 of blah

and yer gonna draw yer board like this :

for i : 1 .. 8
for j : 1 .. 8
drawbox (i * 50, j * 50 - 1, i * 50 - 50, j * 50 - 50, black)
end for
end for

and make up some rules for yer game and vohlaaaaaa!!!
vinkster




PostPosted: Fri Dec 12, 2003 12:00 am   Post subject: a little code

this might help.........property of a checker

code:

View.Set ("graphics:600;400,position:top;left,offscreenonly")
var x, y, x1, y1, btnNumber, btnUpDown, buttons : int
function roundto (roundnum, roundinput : int) : int
    result roundinput div roundnum * roundnum
end roundto
colourback (7)
cls
drawfillbox (0, 0, 100, 100, 4)
drawfillbox (0, 200, 100, 300, 4)
drawfillbox (0, 400, 100, 500, 4)
drawfillbox (100, 100, 200, 200, 4)
drawfillbox (300, 100, 400, 200, 4)
drawfillbox (100, 300, 200, 400, 4)
drawfillbox (200, 0, 300, 100, 4)
drawfillbox (400, 0, 500, 100, 4)
drawfillbox (300, 100, 400, 200, 4)
drawfillbox (300, 300, 400, 400, 4)
drawfillbox (200, 200, 300, 300, 4)
drawfillbox (400, 200, 500, 300, 4)
drawfillbox (500, 100, 600, 200, 4)
drawfillbox (500, 300, 600, 400, 4)
var pic : int
pic := Pic.New (0, 0, maxx, maxy)
Pic.Draw (pic, 0, 0, picCopy)
var z, w : int := 30
x := 50
y := 50
drawfilloval (x, y, z, w, 8)
loop
    Mouse.ButtonWait ("down", x1, y1, btnNumber, btnUpDown)
    if x >= x1 - 25 and x <= x1 + 25 and y >= y1 - 25 and y <= y1 + 25 then
        loop
            drawfilloval (x1, y1, z, w, 8)
            Pic.Draw (pic, 0, 0, picCopy)
            exit when Mouse.ButtonMoved ("up")
            Mouse.Where (x1, y1, buttons)
            drawfilloval (x1, y1, z, w, 3)
        View.Update
            end loop
        Mouse.ButtonWait ("up", x1, y1, btnNumber, btnUpDown)
        x1 := roundto (100, x1) + 50
        y1 := roundto (100, y1) + 50
        if whatdotcolour (x1,y1) not = 4 then
        x1+=100
        end if
        drawfilloval (x1, y1, z, w, 8)
        x := x1
        y := y1
    end if
View.Update
    end loop
DanShadow




PostPosted: Fri Dec 12, 2003 4:26 pm   Post subject: (No subject)

Homers way is correct...but when my teacher asked me to make checkers, my board was made out of lines...saves a few lines of codes. Wink
Schaef




PostPosted: Fri Dec 12, 2003 4:58 pm   Post subject: (No subject)

what would go in the place of "blah" for the array?
DanShadow




PostPosted: Fri Dec 12, 2003 5:38 pm   Post subject: (No subject)

board_array : array 1..8,1..8 of int
Very Happy
(blah=int) because the x,y val ues of each square is an integer value...well or real if you want it to be.
Homer_simpson




PostPosted: Fri Dec 12, 2003 6:43 pm   Post subject: (No subject)

well that depends on yer game for example if u need to know just if the block is empty or full ,u make it an array of booleans so whenever block(3,1) for example is full it's value is true.... or if u need to know which player's object is in the block... use an array of int so whenever block(5,2) for example has value 0 it's empty whenever 1 player one and when ever 2 player 2's object...
McKenzie




PostPosted: Fri Dec 12, 2003 10:28 pm   Post subject: (No subject)

homer++
code:
for x : 1 .. 8
for y : 1 .. 8
drawfillbox (x * 50, y * 50 - 1, x * 50 - 50, y * 50 - 50, ((x+y*7) mod 2) * black)
end for
end for
Sponsor
Sponsor
Sponsor
sponsor
drumersrule123




PostPosted: Fri Dec 12, 2003 10:35 pm   Post subject: (No subject)

just import a picture of a chess board with Pic.ScreenLoad
Andy




PostPosted: Sat Dec 13, 2003 4:58 pm   Post subject: (No subject)

then pic.scale it to 50 pixels
DanShadow




PostPosted: Sat Dec 13, 2003 5:00 pm   Post subject: (No subject)

Id prefer just using "for" to draw lines or boxes because on some peoples versions of Turing, pictures get REALLY screwy, and dont load, and freeze program, and other things. I know its happened to me b4, and I have Turing 4.04!
Schaef




PostPosted: Tue Dec 16, 2003 4:49 pm   Post subject: (No subject)

McKenzie, could you or someone else plz explain 'how' your code works?
Andy




PostPosted: Tue Dec 16, 2003 8:06 pm   Post subject: (No subject)

lol its not hard... but since my compsci teacher is good at explaining things, i'll let him explain...
Schaef




PostPosted: Wed Dec 17, 2003 8:20 am   Post subject: (No subject)

can someone plz explain it??
DanShadow




PostPosted: Wed Dec 17, 2003 11:55 am   Post subject: (No subject)

I think Mckenzies code makes (in two for statements), boxes which extend 8 spaces up, 8 spaces right, then draw the dif inside....
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  [ 15 Posts ]
Jump to:   


Style:  
Search: