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

Username:   Password: 
 RegisterRegister   
 snakes and ladders
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
juju




PostPosted: Tue Jan 17, 2006 6:03 pm   Post subject: snakes and ladders

i'm trying to make a snakes and ladders game, just a basic one. but something just isn't right. i am unable to move the "game piece" (a ball) to another square and it isn't even appearing. any idea's to get my game working?

coding:
code:
const testString : string := "Snakes+Ladders"
var width : int
var fontID : int
fontID := Font.New (":26:Bold,Italic")
width := Font.Width (testString, fontID)
Font.Draw (testString, 1, 1, fontID, black)

var x1 : int := 100
var x2 : int := 130
var y1 : int := 70
var y2 : int := 100
var c : int
for B : 1 .. 9
    y1 := y1 + 30
    y2 := y2 + 30
    x1 := 100
    x2 := 130
    for A : 1 .. 9
        x1 := x1 + 30
        x2 := x2 + 30
        randint (c, 2, 10)
        drawfillbox (x1, y1, x2, y2, c)
    end for
end for



drawarc (265, 330, 20, 20, 90, 270, red)
drawarc (267, 330, 22, 20, 90, 270, red)
drawarc (266, 330, 23, 20, 90, 270, red)

drawarc (261, 290, 22, 20, 270, 90, red)
drawarc (262, 290, 23, 20, 280, 90, red)

drawarc (251, 252, 22, 20, 56, 236, red)
drawarc (252, 252, 25, 20, 56, 236, red)

drawfilloval (115, 114, 12, 12, white)

var locx, locy, btn, rc : int
loop
    mousewhere (locx, locy, btn)
    if btn = 1
            then
        for i : 1 .. 100000
        randint (rc,2,20)
        end for
        if locx > 130 and locx < 250 and locy > 100 and locy < 370
                then
            drawfilloval (locx, locy, 12, 12, white)
        or if
        locx>280 and locx<400 and locy>100 and locy<370
        then
         drawfilloval (locx, locy, 12, 12, white)
        end if
end if

var locx2, locy2, btn2, rc2 : int
loop
    mousewhere (locx2, locy2, btn2)
    if btn2 = 1
            then
        for i : 1 .. 100000
        end for
        locate (1, 1)
        randint (rc2, 250, 255)
        if locx2 > 250 and locx2 < 279 and locy2 > 341 and locy2 < 368
                then
            drawfilloval (235, 235, 12, 12, white)
        end if
    end if
end loop

var mx, my, mbutton, mx1, my1 : int
mx1 := 100
my1 := 100
drawfilloval (mx1, my1, 12, 12, white)
loop
    mousewhere (mx, my, mbutton)
    if mx > mx1 - 12 and mx < mx1 + 12 and my > my1 - 12 and my < my1
            + 12 and mbutton = 1 then
        drawfilloval (mx, my, 12, 12, white)
        delay (10)
        drawfilloval (mx, my, 12, 12, brightred)
    end if
end loop
end loop
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Jan 17, 2006 7:01 pm   Post subject: (No subject)

Hi and welcome.

Now let's get a few things clear. Thumbs up for using [ code] tags. You are saving retinas everywhere by doing so.
Thumbs down for posting non-executing code. It won't run when I try to, only if I edit it. And I don't have the time to do that...and when I say "I", I'm not necassarily referring to myself.

That being said:
code:

for i : 1 .. 100000
   randint (rc,2,20)
end for

What on Earth is that supposed to do? Set a random number 100 000 times?! There is no point in that.

code:

if locx > 130 and locx < 250 and locy > 100 and locy < 370
                then
            drawfilloval (locx, locy, 12, 12, white)
        or if
%...


I'm particularly interested in the 'or if' part. That is not how the sytax works. Instead it should be:

code:

if {condition} then
   ...
elsif {condition} then
   ...
else
   ...
end if


See that?

Try fix those and see if it works any better.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: