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

Username:   Password: 
 RegisterRegister   
 Racing Game !!! Complete game with a lap counter problem !!!!!!! Please Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tttptiago




PostPosted: Thu Jun 07, 2007 11:31 am   Post subject: Racing Game !!! Complete game with a lap counter problem !!!!!!! Please Help

The Code is complete, and the game works. The only problems that im having is making the lap counter work. When the "racer" crosses the finish line my lap procedue does no work. i want the "racer" to do 3 laps.

Any help is greatly appreciated !
Mess with the code all you want , as long as positive production is completed.

THNX !



setscreen ("graphics")

var font1 : int
var keys : array char of boolean
var x, y : int
var lap : int := 0
font1 := Font.New ("Arial :20")
x := 230
y := 40

colorback (255)
cls
procedure Track

drawline (190, 30, 190, 60, 70) % finishline

drawline (1, 1, maxx, 1, 79) %Border
drawline (maxx - 1, 1, maxx - 1, maxy - 1, 79) %Border
drawline (maxx - 1, maxy - 1, 1, maxy - 1, 79) %Boreder
drawline (1, maxy - 1, 1, 1, 79) %Border

drawline (75, 30, 500, 30, 0) %Track Outside
drawline (500, 30, 500, 100, 0) %Track Outside
drawline (500, 100, 560, 100, 0) %Track Outside
drawline (560, 100, 560, 300, 0) %Track Outside
drawline (560, 300, 480, 300, 0) %Track Outside
drawline (480, 300, 480, 370, 0) %Track Outside
drawline (480, 370, 300, 370, 0) %Track Outside
drawline (300, 370, 300, 270, 0) %Track Outside
drawline (300, 270, 240, 270, 0) %Track Outside
drawline (240, 270, 240, 350, 0) %Track Outside
drawline (240, 350, 75, 350, 0) %Track Outside
drawline (75, 350, 75, 30, 0) %Track Outside


drawline (105, 60, 470, 60, 0) %Track Inside
drawline (470, 60, 470, 130, 0) %Track Inside
drawline (470, 130, 530, 130, 0) %Track Inside
drawline (530, 130, 530, 270, 0) %Track Inside
drawline (530, 270, 450, 270, 0) %Track Inside
drawline (450, 270, 450, 340, 0) %Track Inside
drawline (450, 340, 330, 340, 0) %Track Inside
drawline (330, 340, 330, 240, 0) %Track Inside
drawline (330, 240, 210, 240, 0) %Track Inside
drawline (210, 240, 210, 310, 0) %Track Inside
drawline (210, 310, 105, 310, 0) %Track Inside
drawline (105, 310, 105, 60, 0) %Track Inside


end Track

procedure Char

Draw.FillBox (x, y, x + 10, y + 5, 10)
Draw.FillBox (x, y + 5, x, y, 255)
Draw.FillBox (x + 10, y, x, y, 255)
Draw.FillBox (x, y, x + 10, y, 255)
Draw.FillBox (x + 10, y, x + 10, y + 5, 255)
Draw.FillBox (x + 10, y, x, y, 255)
Draw.FillBox (x, y + 5, x + 10, y + 5, 255)

end Char


procedure Keys

Input.KeyDown (keys)

if keys (KEY_RIGHT_ARROW)
then
delay (4) % Sets Speed
x += 1

elsif keys (KEY_LEFT_ARROW)
then
delay (4)
x -= 1

elsif keys (KEY_UP_ARROW)
then
delay (4)
y += 1

elsif keys (KEY_DOWN_ARROW)
then
delay (4)
y -= 1

end if

end Keys

procedure Collision



if whatdotcolour (x + 5, y + 5) = 8
or whatdotcolour (x + 10, y) = 8
or whatdotcolour (x - 1, y) = 8
or whatdotcolour (x + 5, y + 5) = 0
or whatdotcolour (x + 10, y) = 0
or whatdotcolour (x - 1, y) = 0

then
Font.Draw ("YOU HAVE CRASHED!", 170, 190, font1, 8)
delay (1000)

Font.Draw ("GAME OVER!", 220, 130, font1, red)
delay (1000)





end if

end Collision


if x = 190 and y >= 30 and y <= 60 then
lap := lap + 1
end if

color (white)
put "Laps : " , lap


Track


loop

Char
Keys
Collision
end loop
Sponsor
Sponsor
Sponsor
sponsor
DIIST




PostPosted: Thu Jun 07, 2007 12:13 pm   Post subject: Re: Racing Game !!! Complete game with a lap counter problem !!!!!!! Please Help

Create several check point regions on the map where if the user passes through them, it will be noted down. The finish line will be the last checkpoint region , and can only count as a lap if all the previous checkpoints have been completed.

* use code tags* Wink
tttptiago




PostPosted: Thu Jun 07, 2007 6:12 pm   Post subject: RE:Racing Game !!! Complete game with a lap counter problem !!!!!!! Please Help

can you explain how I would do this, or can anyone?
DIIST




PostPosted: Thu Jun 07, 2007 7:53 pm   Post subject: Re: Racing Game !!! Complete game with a lap counter problem !!!!!!! Please Help

Something like this. I modified you code slightly.
Turing:

setscreen ("graphics")

var font1 : int
var keys : array char of boolean
var x, y : int
var lap : int := 0
font1 := Font.New ("Arial :20")
x := 230
y := 40
var check1, check2, check3 : int := 0
colorback (255)
cls
procedure Track

    drawline (190, 30, 190, 60, 70) % finishline

    drawline (1, 1, maxx, 1, 79) %Border
    drawline (maxx - 1, 1, maxx - 1, maxy - 1, 79) %Border
    drawline (maxx - 1, maxy - 1, 1, maxy - 1, 79) %Boreder
    drawline (1, maxy - 1, 1, 1, 79) %Border

    drawline (75, 30, 500, 30, 0) %Track Outside
    drawline (500, 30, 500, 100, 0) %Track Outside
    drawline (500, 100, 560, 100, 0) %Track Outside
    drawline (560, 100, 560, 300, 0) %Track Outside
    drawline (560, 300, 480, 300, 0) %Track Outside
    drawline (480, 300, 480, 370, 0) %Track Outside
    drawline (480, 370, 300, 370, 0) %Track Outside
    drawline (300, 370, 300, 270, 0) %Track Outside
    drawline (300, 270, 240, 270, 0) %Track Outside
    drawline (240, 270, 240, 350, 0) %Track Outside
    drawline (240, 350, 75, 350, 0) %Track Outside
    drawline (75, 350, 75, 30, 0) %Track Outside


    drawline (105, 60, 470, 60, 0) %Track Inside
    drawline (470, 60, 470, 130, 0) %Track Inside
    drawline (470, 130, 530, 130, 0) %Track Inside
    drawline (530, 130, 530, 270, 0) %Track Inside
    drawline (530, 270, 450, 270, 0) %Track Inside
    drawline (450, 270, 450, 340, 0) %Track Inside
    drawline (450, 340, 330, 340, 0) %Track Inside
    drawline (330, 340, 330, 240, 0) %Track Inside
    drawline (330, 240, 210, 240, 0) %Track Inside
    drawline (210, 240, 210, 310, 0) %Track Inside
    drawline (210, 310, 105, 310, 0) %Track Inside
    drawline (105, 310, 105, 60, 0) %Track Inside

    drawfillbox (531, 150, 559, 180, 38)
    drawfillbox (160, 311, 190, 349, 39)
    drawfillbox (160, 31, 190, 59, 40)


end Track

procedure Char

    Draw.FillBox (x, y, x + 10, y + 5, 10)
    Draw.FillBox (x, y + 5, x, y, 255)
    Draw.FillBox (x + 10, y, x, y, 255)
    Draw.FillBox (x, y, x + 10, y, 255)
    Draw.FillBox (x + 10, y, x + 10, y + 5, 255)
    Draw.FillBox (x + 10, y, x, y, 255)
    Draw.FillBox (x, y + 5, x + 10, y + 5, 255)

end Char


procedure Keys

    Input.KeyDown (keys)

    if keys (KEY_RIGHT_ARROW)
            then
        delay (4) % Sets Speed
        x += 1

    elsif keys (KEY_LEFT_ARROW)
            then
        delay (4)
        x -= 1

    elsif keys (KEY_UP_ARROW)
            then
        delay (4)
        y += 1

    elsif keys (KEY_DOWN_ARROW)
            then
        delay (4)
        y -= 1

    end if

end Keys

procedure Collision



    if whatdotcolour (x + 5, y + 5) = 8
            or whatdotcolour (x + 10, y) = 8
            or whatdotcolour (x - 1, y) = 8
            or whatdotcolour (x + 5, y + 5) = 0
            or whatdotcolour (x + 10, y) = 0
            or whatdotcolour (x - 1, y) = 0

            then
        Font.Draw ("YOU HAVE CRASHED!", 170, 190, font1, 8)
        delay (1000)

        Font.Draw ("GAME OVER!", 220, 130, font1, red)
        delay (1000)
        %What evers bellow is for the check points :)
    elsif whatdotcolour (x + 5, y + 5) = 38
            or whatdotcolour (x + 10, y) = 38
            or whatdotcolour (x - 1, y) = 38 then
        check1 := 1

    elsif whatdotcolour (x + 5, y + 5) = 39
            or whatdotcolour (x + 10, y) = 39
            or whatdotcolour (x - 1, y) = 39 then
        check2 := 2

    elsif whatdotcolour (x + 5, y + 5) = 12 %This should really be 40 but it 40=12 in turing colour pallet
            or whatdotcolour (x + 10, y) = 12
            or whatdotcolour (x - 1, y) = 12 then

        check3 := 3

        if check1 + check2 + check3 = 6 then
            lap += 1
            cls
            color (white)
            put "Laps : ", lap
            Track
            check1 := 0
            check2 := 0
            check3 := 0
        end if

    end if


end Collision


if x = 190 and y >= 30 and y <= 60 then
    lap := lap + 1
end if

color (white)
put "Laps : ", lap


Track

loop

    Char
    Keys
    Collision

end loop

This is what i mean. Its not the best code in the world, and i suggest you read up on the turing walktrough to find ways to make your code better. Hope it was helpfull. Wink
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  [ 4 Posts ]
Jump to:   


Style:  
Search: