i am making a racing game for my isu and i have a few problems
such as:
- laps don't decrease
- cars don't rest after race
help is much appreciated
here is code:
Turing: | View.Set ("offscreenonly")
var chars : array char of boolean
var chars2 : array char of boolean
var pic := Pic.FileNew ("G:/racers/car1.jpg")
var pic2 := Pic.FileNew ("G:/racers/race track.jpg")
var pic3 := Pic.FileNew ("G:/racers/car2.jpg")
var font : int
var player : string (1)
var car := pic
var car2 := pic3
var counter := 0
var counter2 := 0
var x, y : real := 5
var x2, y2 : real := 5
var picRotated : array 0 .. 35 of int
var picRotated2 : array 0 .. 35 of int
var lap, lap2 : int
for rep : 0 .. 35
picRotated (rep ) := Pic.Rotate (pic, rep * 10, Pic.Width (pic ) div 2 + 7, Pic.Height (pic ) div 2 + 5)
end for
for rep2 : 0 .. 35
picRotated2 (rep2 ) := Pic.Rotate (pic3, rep2 * 10, Pic.Width (pic3 ) div 2 + 7, Pic.Height (pic3 ) div 2 + 5)
end for
font := Font.New ("Agency FB:18")
loop
x := 0
y := 0
x2 := 0
y2 := 0
lap := 3
lap2 := 3
getch (player )
if player = "1" then
setscreen ("graphics:400,400")
View.Set ("offscreenonly")
loop
drawfill (0, 0, 40, 40)
drawfillbox (0, 0, 400, 400, 7)
drawfillbox (50, 50, 350, 350, 2)
drawfillbox (0, 50, 50, 70, 0)
drawfillbox (0, 50, 5, 55, 7)
drawfillbox (0, 60, 5, 65, 7)
drawfillbox (5, 55, 10, 60, 7)
drawfillbox (5, 65, 10, 70, 7)
drawfillbox (10, 50, 15, 55, 7)
drawfillbox (10, 60, 15, 65, 7)
drawfillbox (15, 55, 20, 60, 7)
drawfillbox (15, 65, 20, 70, 7)
drawfillbox (20, 50, 25, 55, 7)
drawfillbox (20, 60, 25, 65, 7)
drawfillbox (25, 55, 30, 60, 7)
drawfillbox (25, 65, 30, 70, 7)
drawfillbox (30, 50, 35, 55, 7)
drawfillbox (30, 60, 35, 65, 7)
drawfillbox (35, 55, 40, 60, 7)
drawfillbox (35, 65, 40, 70, 7)
drawfillbox (40, 50, 45, 55, 7)
drawfillbox (40, 60, 45, 65, 7)
drawfillbox (45, 55, 50, 65, 7)
drawfillbox (45, 65, 50, 70, 7)
drawfillbox (45, 60, 50, 65, 0)
drawfillmapleleaf (125, 125, 275, 275, 40)
Font.Draw ("MINI RACERS", 155, 185, font, 0)
Font.Draw ("laps to go", 155, 75, font, 0)
put lap
Input.KeyDown (chars )
if chars (KEY_RIGHT_ARROW) then
counter - = 1
car := picRotated (counter mod 36)
end if
if chars (KEY_LEFT_ARROW) then
counter + = 1
car := picRotated (counter mod 36)
end if
if chars (KEY_UP_ARROW) then
x + = cosd ((counter mod 36) * 10 + 90) * 5
y + = sind ((counter mod 36) * 10 + 90) * 5
end if
if chars (KEY_DOWN_ARROW) then
x - = cosd ((counter mod 36) * 10 + 90) * 5
y - = sind ((counter mod 36) * 10 + 90) * 5
end if
Pic.Draw (car, round (x ), round (y ), picMerge)
View.Update
cls
delay (25)
if x <= 1 then
x := x + 3
end if
if x >= 365 then
x := x - 3
end if
if y <= 1 then
y := y + 3
end if
if y >= 360 then
y := y - 3
end if
if x <= 50 and y = 70 then
lap := lap - 1
delay (50)
end if
if lap = 0 then
exit
end if
end loop
elsif player = "2" then
setscreen ("graphics:400,400")
View.Set ("offscreenonly")
loop
drawfill (0, 0, 40, 40)
drawfillbox (0, 0, 400, 400, 7)
drawfillbox (50, 50, 350, 350, 2)
drawfillbox (0, 50, 50, 70, 0)
drawfillbox (0, 50, 5, 55, 7)
drawfillbox (0, 60, 5, 65, 7)
drawfillbox (5, 55, 10, 60, 7)
drawfillbox (5, 65, 10, 70, 7)
drawfillbox (10, 50, 15, 55, 7)
drawfillbox (10, 60, 15, 65, 7)
drawfillbox (15, 55, 20, 60, 7)
drawfillbox (15, 65, 20, 70, 7)
drawfillbox (20, 50, 25, 55, 7)
drawfillbox (20, 60, 25, 65, 7)
drawfillbox (25, 55, 30, 60, 7)
drawfillbox (25, 65, 30, 70, 7)
drawfillbox (30, 50, 35, 55, 7)
drawfillbox (30, 60, 35, 65, 7)
drawfillbox (35, 55, 40, 60, 7)
drawfillbox (35, 65, 40, 70, 7)
drawfillbox (40, 50, 45, 55, 7)
drawfillbox (40, 60, 45, 65, 7)
drawfillbox (45, 55, 50, 65, 7)
drawfillbox (45, 65, 50, 70, 7)
drawfillbox (45, 60, 50, 65, 0)
drawfillmapleleaf (125, 125, 275, 275, 40)
Font.Draw ("MINI RACERS", 155, 185, font, 0)
put lap, " ", lap2
Input.KeyDown (chars2 )
if chars2 ('d') then
counter2 - = 1
car2 := picRotated2 (counter2 mod 36)
end if
if chars2 ('a') then
counter2 + = 1
car2 := picRotated2 (counter2 mod 36)
end if
if chars2 ('w') then
x2 + = cosd ((counter2 mod 36) * 10 + 90) * 5
y2 + = sind ((counter2 mod 36) * 10 + 90) * 5
end if
if chars2 ('s') then
x2 - = cosd ((counter2 mod 36) * 10 + 90) * 5
y2 - = sind ((counter2 mod 36) * 10 + 90) * 5
end if
Pic.Draw (car2, round (x2 ), round (y2 ), picMerge)
View.Update
Input.KeyDown (chars )
if chars (KEY_RIGHT_ARROW) then
counter - = 1
car := picRotated (counter mod 36)
end if
if chars (KEY_LEFT_ARROW) then
counter + = 1
car := picRotated (counter mod 36)
end if
if chars (KEY_UP_ARROW) then
x + = cosd ((counter mod 36) * 10 + 90) * 5
y + = sind ((counter mod 36) * 10 + 90) * 5
end if
if chars (KEY_DOWN_ARROW) then
x - = cosd ((counter mod 36) * 10 + 90) * 5
y - = sind ((counter mod 36) * 10 + 90) * 5
end if
Pic.Draw (car, round (x ), round (y ), picMerge)
View.Update
cls
delay (25)
if x <= 1 then
x := x + 3
end if
if x >= 365 then
x := x - 3
end if
if y <= 1 then
y := y + 3
end if
if y >= 360 then
y := y - 3
end if
if x2 <= 1 then
x2 := x2 + 3
end if
if y2 <= 1 then
y2 := y2 + 3
end if
if y2 >= 360 then
y2 := y2 - 3
end if
if x2 >= 365 then
x2 := x2 - 3
end if
if x <= 50 and y = 70 then
lap := lap - 1
delay (50)
end if
if x2 <= 50 and y2 = 70 then
lap2 := lap2 - 1
delay (50)
end if
if lap = 0 then
cls
put "PLAYER 1 WINS"
exit
end if
if lap2 = 0 then
cls
put "PLAYER 2 WINS"
exit
end if
end loop
end if
end loop
|
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|