Traffic Lights Project Help!!!
Author |
Message |
hotmail
|
Posted: Fri Jan 04, 2013 3:52 pm Post subject: Traffic Lights Project Help!!! |
|
|
%Turing
%Set the screen
View.Set ("graphics:1400;750")
var Sonic : array 0 .. 6 of int
Sonic (0) := Pic.FileNew ("Sonic0.jpg")
Sonic (1) := Pic.FileNew ("Sonic1.jpg")
Sonic (2) := Pic.FileNew ("Sonic2.jpg")
Sonic (3) := Pic.FileNew ("Sonic3.jpg")
Sonic (4) := Pic.FileNew ("Sonic4.jpg")
Sonic (5) := Pic.FileNew ("Sonic5.jpg")
Sonic (6) := Pic.FileNew ("Sonic6.jpg")
var playrev : boolean := false
var Sonic2 : array 0 .. 6 of int
Sonic2 (0) := Pic.FileNew ("Sonic0a.jpg")
Sonic2 (1) := Pic.FileNew ("Sonic1a.jpg")
Sonic2 (2) := Pic.FileNew ("Sonic2a.jpg")
Sonic2 (3) := Pic.FileNew ("Sonic3a.jpg")
Sonic2 (4) := Pic.FileNew ("Sonic4a.jpg")
Sonic2 (5) := Pic.FileNew ("Sonic5a.jpg")
Sonic2 (6) := Pic.FileNew ("Sonic6a.jpg")
var i3, x3, y3 : int
y3 := 475
i3 := 0
x3 := 1200
var Tree : array 0 .. 5 of int
Tree (0) := Pic.FileNew ("Tree1.jpg")
Tree (1) := Pic.FileNew ("Tree1.jpg")
Tree (2) := Pic.FileNew ("Tree1.jpg")
Tree (3) := Pic.FileNew ("Tree1.jpg")
Tree (4) := Pic.FileNew ("Tree1.jpg")
var Building : array 0 .. 5 of int
Building (0) := Pic.FileNew ("Building1.jpg")
var Character : array 0 .. 6 of int
Character (0) := Pic.FileNew ("Sonic0.jpg")
Character (1) := Pic.FileNew ("Sonic1.jpg")
Character (2) := Pic.FileNew ("Sonic2.jpg")
Character (3) := Pic.FileNew ("Sonic3.jpg")
Character (4) := Pic.FileNew ("Sonic4.jpg")
Character (5) := Pic.FileNew ("Sonic5.jpg")
Character (6) := Pic.FileNew ("Sonic6.jpg")
var CharIndex : int := 0
var row : int
randint (row, 1, 100)
var column : int
randint (column, 1, 100)
var Hand : array 1 .. 4 of int
Hand (1) := Pic.FileNew ("imgHand.jpg")
Hand (2) := Pic.FileNew ("imgHand.jpg")
Hand (3) := Pic.FileNew ("imgHand.jpg")
Hand (4) := Pic.FileNew ("imgHand.jpg")
var Walk : array 1 .. 4 of int
Walk (1) := Pic.FileNew ("imgWalk.jpg")
Walk (2) := Pic.FileNew ("imgWalk.jpg")
Walk (3) := Pic.FileNew ("imgWalk.jpg")
Walk (4) := Pic.FileNew ("imgWalk.jpg")
var x1, y : int
x1 := 100
y := 100
var chars : array char of boolean
var x2, y2, b2 : int
var FlagIndex : int := 0
var Flag : array 0 .. 74 of int
Flag (0) := Pic.FileNew ("Frame0.jpg")
Flag (1) := Pic.FileNew ("Frame1.jpg")
Flag (2) := Pic.FileNew ("Frame2.jpg")
Flag (3) := Pic.FileNew ("Frame3.jpg")
Flag (4) := Pic.FileNew ("Frame4.jpg")
Flag (5) := Pic.FileNew ("Frame5.jpg")
Flag (6) := Pic.FileNew ("Frame6.jpg")
Flag (7) := Pic.FileNew ("Frame7.jpg")
Flag (8) := Pic.FileNew ("Frame8.jpg")
Flag (9) := Pic.FileNew ("Frame9.jpg")
Flag (10) := Pic.FileNew ("Frame10.jpg")
Flag (11) := Pic.FileNew ("Frame11.jpg")
Flag (12) := Pic.FileNew ("Frame12.jpg")
Flag (13) := Pic.FileNew ("Frame13.jpg")
Flag (14) := Pic.FileNew ("Frame14.jpg")
Flag (15) := Pic.FileNew ("Frame15.jpg")
Flag (16) := Pic.FileNew ("Frame16.jpg")
Flag (17) := Pic.FileNew ("Frame17.jpg")
Flag (18) := Pic.FileNew ("Frame18.jpg")
Flag (19) := Pic.FileNew ("Frame19.jpg")
Flag (20) := Pic.FileNew ("Frame20.jpg")
Flag (21) := Pic.FileNew ("Frame21.jpg")
Flag (22) := Pic.FileNew ("Frame22.jpg")
Flag (23) := Pic.FileNew ("Frame23.jpg")
Flag (24) := Pic.FileNew ("Frame24.jpg")
Flag (25) := Pic.FileNew ("Frame25.jpg")
Flag (26) := Pic.FileNew ("Frame26.jpg")
Flag (27) := Pic.FileNew ("Frame27.jpg")
Flag (28) := Pic.FileNew ("Frame28.jpg")
Flag (29) := Pic.FileNew ("Frame29.jpg")
Flag (30) := Pic.FileNew ("Frame30.jpg")
Flag (31) := Pic.FileNew ("Frame31.jpg")
Flag (32) := Pic.FileNew ("Frame32.jpg")
Flag (33) := Pic.FileNew ("Frame33.jpg")
Flag (34) := Pic.FileNew ("Frame34.jpg")
Flag (35) := Pic.FileNew ("Frame35.jpg")
Flag (36) := Pic.FileNew ("Frame36.jpg")
Flag (37) := Pic.FileNew ("Frame37.jpg")
Flag (38) := Pic.FileNew ("Frame38.jpg")
Flag (39) := Pic.FileNew ("Frame39.jpg")
Flag (40) := Pic.FileNew ("Frame40.jpg")
Flag (41) := Pic.FileNew ("Frame41.jpg")
Flag (42) := Pic.FileNew ("Frame42.jpg")
Flag (43) := Pic.FileNew ("Frame43.jpg")
Flag (44) := Pic.FileNew ("Frame44.jpg")
Flag (45) := Pic.FileNew ("Frame45.jpg")
Flag (46) := Pic.FileNew ("Frame46.jpg")
Flag (47) := Pic.FileNew ("Frame47.jpg")
Flag (48) := Pic.FileNew ("Frame48.jpg")
Flag (49) := Pic.FileNew ("Frame49.jpg")
Flag (50) := Pic.FileNew ("Frame50.jpg")
Flag (51) := Pic.FileNew ("Frame51.jpg")
Flag (52) := Pic.FileNew ("Frame52.jpg")
Flag (53) := Pic.FileNew ("Frame53.jpg")
Flag (54) := Pic.FileNew ("Frame54.jpg")
Flag (55) := Pic.FileNew ("Frame55.jpg")
Flag (56) := Pic.FileNew ("Frame56.jpg")
Flag (57) := Pic.FileNew ("Frame57.jpg")
Flag (58) := Pic.FileNew ("Frame58.jpg")
Flag (59) := Pic.FileNew ("Frame59.jpg")
Flag (60) := Pic.FileNew ("Frame60.jpg")
Flag (61) := Pic.FileNew ("Frame61.jpg")
Flag (62) := Pic.FileNew ("Frame62.jpg")
Flag (63) := Pic.FileNew ("Frame63.jpg")
Flag (64) := Pic.FileNew ("Frame64.jpg")
Flag (65) := Pic.FileNew ("Frame65.jpg")
Flag (66) := Pic.FileNew ("Frame66.jpg")
Flag (67) := Pic.FileNew ("Frame67.jpg")
Flag (68) := Pic.FileNew ("Frame68.jpg")
Flag (69) := Pic.FileNew ("Frame69.jpg")
Flag (70) := Pic.FileNew ("Frame70.jpg")
Flag (71) := Pic.FileNew ("Frame71.jpg")
Flag (72) := Pic.FileNew ("Frame72.jpg")
Flag (73) := Pic.FileNew ("Frame73.jpg")
Flag (74) := Pic.FileNew ("Frame74.jpg")
var Car : array 1 .. 6 of int
Car (1) := Pic.FileNew ("Car1.jpg")
Car (2) := Pic.FileNew ("Car2.jpg")
Car (3) := Pic.FileNew ("Car3.jpg")
Car (4) := Pic.FileNew ("Car8.jpg")
var Explosion : int := Pic.FileNew ("Explosion.jpg")
var StopLight : array 0 .. 2 of int
StopLight (0) := Pic.FileNew ("StopLight0.jpg")
StopLight (1) := Pic.FileNew ("StopLight1.jpg")
StopLight (2) := Pic.FileNew ("StopLight2.jpg")
var x : int := 0
var i : int := 0
var CarMove : array 1 .. 6 of int
CarMove (1) := 0
CarMove (2) := 1400
CarMove (3) := 750
CarMove (4) := 0
var Duck : array 1 .. 4 of int
Duck (1) := Pic.FileNew ("duck-small.jpg")
Duck (2) := Pic.FileNew ("duck-small1.jpg")
Duck (3) := Pic.FileNew ("duck-small.jpg")
Duck (4) := Pic.FileNew ("duck-small1.jpg")
var Stop : boolean := true
var NorthSouth : boolean := false
var EastWest : boolean := true
var EastWestGo : boolean := true
var NorthSouthGo : boolean := false
var timer : real := 0
var imgDown : array 0 .. 1 of int
imgDown (0) := Pic.FileNew ("Down0.jpg")
imgDown (1) := Pic.FileNew ("Down1.jpg")
var imgUp : array 0 .. 1 of int
imgUp (0) := Pic.FileNew ("Up0.jpg")
imgUp (1) := Pic.FileNew ("Up1.jpg")
var imgRight : array 0 .. 1 of int
imgRight (0) := Pic.FileNew ("Right0.jpg")
imgRight (1) := Pic.FileNew ("Right1.jpg")
var imgLeft : array 0 .. 1 of int
imgLeft (0) := Pic.FileNew ("Left0.jpg")
imgLeft (1) := Pic.FileNew ("Left1.jpg")
var LeftCount : int := 0
var RightCount : int := 0
var UpCount : int := 0
var DownCount : int := 0
var Left : boolean := false
var Right : boolean := true
var Up : boolean := false
var Down : boolean := false
procedure DrawSideWalkLines
%West Top Side Walk
for Counter : 50 .. 550 by 50
drawfillbox (Counter, 475, Counter + 3, 510, black)
end for
%West Bottom Side Walk
for Counter : 50 .. 550 by 50
drawfillbox (Counter, 240, Counter + 3, 275, black)
end for
%East Top Side Walk
for Counter : 840 .. 1400 by 50
drawfillbox (Counter, 475, Counter + 3, 510, black)
end for
%East Bottom Side Walk
for Counter : 840 .. 1400 by 50
drawfillbox (Counter, 240, Counter + 3, 275, black)
end for
%South Left Side Walk
for decreasing counter : 240 .. 0 by 50
drawfillbox (560, counter, 600, counter - 3, black)
end for
%South Right Side Walk
for decreasing counter : 240 .. 0 by 50
drawfillbox (800, counter, 840, counter - 3, black)
end for
%North Left Side Walk
for counter : 515 .. 1400 by 50
drawfillbox (560, counter, 600, counter - 3, black)
end for
%North Right Side Walk
for counter : 515 .. 1400 by 50
drawfillbox (800, counter, 840, counter - 3, black)
end for
end DrawSideWalkLines
var DuckX : int := 200
var DuckY : int := 620
var DuckX1 : int := 270
var DuckY1 : int := 650
var DuckY2 : int := 570
var DuckX2 : int := 300
var GoingRight : boolean := true
var GoingRight1 : boolean := true
var GoingRight2 : boolean := true
var GoingLeft : boolean := false
var GoingLeft1 : boolean := false
var GoingLeft2 : boolean := false
procedure DrawPond
drawfilloval (200, 620, 160, 75, blue)
%Throw some ducks in there
var RandomNum : int
randint (RandomNum, 130, 200)
if GoingRight = true then
Pic.Draw (Duck (1), DuckX, DuckY, picCopy) % ------------------------------------------------MISTAKE--------------------%
if DuckX < 250 then
DuckX := DuckX + 1
else
GoingLeft := true
GoingRight := false
end if
else
Pic.Draw (Duck (2), DuckX, DuckY, picCopy)
if DuckX > 100 then
DuckX := DuckX - 1
else
GoingLeft := false
GoingRight := true
end if
end if
if GoingRight1 = true then
Pic.Draw (Duck (3), DuckX1, DuckY1, picCopy)
if DuckX1 < 250 then
DuckX1 := DuckX1 + 2
else
GoingLeft1 := true
GoingRight1 := false
end if
else
Pic.Draw (Duck (4), DuckX1, DuckY1, picCopy)
if DuckX1 > 100 then
DuckX1 := DuckX1 - 2
else
GoingLeft1 := false
GoingRight1 := true
end if
end if
if GoingRight2 = true then
Pic.Draw (Duck (3), DuckX2, DuckY2, picCopy)
if DuckX2 < 250 then
DuckX2 := DuckX2 + 2
else
GoingLeft2 := true
GoingRight2 := false
end if
else
Pic.Draw (Duck (4), DuckX2, DuckY2, picCopy)
if DuckX2 > 100 then
DuckX2 := DuckX2 - 2
else
GoingLeft2 := false
GoingRight2 := true
end if
end if
end DrawPond
procedure DrawCrossWalk
drawfillbox (600, 275, 597, 475, white)
drawfillbox (560, 275, 557, 475, white)
drawfillbox (600, 510, 800, 513, white)
drawfillbox (800, 475, 600, 477, white)
drawfillbox (840, 475, 843, 275, white)
drawfillbox (800, 475, 803, 275, white)
drawfillbox (800, 275, 600, 278, white)
drawfillbox (800, 240, 600, 243, white)
drawbox (560, 240, 840, 510, white)
drawbox (600, 275, 800, 475, white)
end DrawCrossWalk
procedure DrawRoad
drawfillbox (0, 0, maxx, maxy, green) %Set the background to green
drawfillbox (0, 275, maxx, 475, 20) %Draw the horizontal road
drawfillbox (600, 0, 800, maxy, 20) %Draw the vertical road
end DrawRoad
procedure DrawSideWalk
drawfillbox (0, 475, maxx div 2 - 100, 510, grey) %Draw sidewalk for top east side
drawfillbox (0, 275, maxx div 2 - 100, 240, grey) %Draw sidewalk for bottom east side
drawfillbox (1400, 475, maxx div 2 + 102, 510, grey) %Draw sidewalk for top right side
drawfillbox (1400, 275, maxx div 2 + 102, 240, grey) %Draw sidewalk for bottom right side
drawfillbox (600, 0, 560, 275, grey) %Draw sidewalk for top left side
drawfillbox (800, 0, 840, 275, grey) %Draw sidewalk for bottom left side
drawfillbox (600, maxy, 560, maxy div 2 + 101, grey) %Draw sidewalk for north left side
drawfillbox (800, maxy, 840, maxy div 2 + 101, grey) %Draw sidewalk for north left side
end DrawSideWalk
procedure DrawRoadLines
drawfillbox (0, 375, maxx div 2 - 100, 370, yellow) %Draw the first left line BOX NOT LINE
%drawfillbox(0,375,maxx div 2 - 100, 375, yellow)%Draw the first left line LINE NOT BOX
drawfillbox (0, 370, maxx div 2 - 100, 370, yellow) %Draw the second left line
drawfillbox (maxx div 2 + 100, 375, maxx, 370, yellow) %Draw the first right line
drawfillbox (maxx div 2, maxy, maxx div 2, maxy div 2 + 100, yellow)
drawfillbox (maxx div 2, 0, maxx div 2, maxy div 2 - 100, yellow)
drawline (maxx div 2 + 100, 370, maxx, 370, yellow) %Draw the first right line
drawfillbox (maxx div 2 - 5, maxy, maxx div 2, maxy div 2 + 100, yellow)
drawfillbox (maxx div 2 - 5, 0, maxx div 2, maxy div 2 - 100, yellow)
end DrawRoadLines
%process BackgroundMusic
% Music.PlayFile ("Lemon Jelly.mp3")
%end BackgroundMusic
process PlayEngineRev
Music.PlayFile ("engine-rev.mp3")
end PlayEngineRev
%fork BackgroundMusic
loop
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
if Up = true and UpCount = 0 then
UpCount := UpCount + 1
end if
Up := true
Right := false
Left := false
Down := false
RightCount := 0
LeftCount := 0
DownCount := 0
y := y + 10
end if
if chars (KEY_RIGHT_ARROW) then
if Right = true and RightCount = 0 then
RightCount := RightCount + 1
end if
Up := false
Right := true
Left := false
Down := false
UpCount := 0
LeftCount := 0
DownCount := 0
x1 := x1 + 10
end if
if chars (KEY_LEFT_ARROW) then
if Left = true and LeftCount = 0 then
LeftCount := LeftCount + 1
end if
Up := false
Right := false
Left := true
Down := false
UpCount := 0
RightCount := 0
DownCount := 0
x1 := x1 - 10
end if
if chars (KEY_DOWN_ARROW) then
if Down = true and DownCount = 0 then
DownCount := DownCount + 1
end if
Up := false
Right := false
Left := false
Down := true
UpCount := 0
LeftCount := 0
RightCount := 0
y := y - 10
end if
DrawRoad
DrawRoadLines
%---------------------------------------CrossWalk-------------------------------------------
DrawCrossWalk
%---------------------------------------DrawPond--------------------------------------------
DrawPond
%---------------------------------------SIDEWALK--------------------------------------------
DrawSideWalk
%-------------------------------------SIDEWALK LINES----------------------------------------
DrawSideWalkLines
Mouse.Where (x2, y2, b2)
locate (1, 1)
%put "X ", x2, " Y ", y2
%------------------------------------Trees---------------------------------------------------
Pic.Draw (Tree (0), 100, 50, picCopy)
Pic.Draw (Tree (0), 1000, 550, picCopy)
%------------------------------------Buildings-----------------------------------------------
Pic.Draw (Building (0), 900, 10, picCopy)
%------------------------------------Flags----------------------------------------------------
Pic.Draw (Flag (FlagIndex), 0, 0, picCopy)
FlagIndex := FlagIndex + 1
%------------------------------------Cars-----------------------------------------------------
Pic.Draw (Car (1), CarMove (1), 282, picCopy)
Pic.Draw (Car (2), CarMove (2), 390, picCopy)
Pic.Draw (Car (3), 610, CarMove (3), picCopy)
Pic.Draw (Car (4), 720, CarMove (4), picCopy)
if CarMove (1) = 410 and EastWestGo = false then
else
CarMove (1) := CarMove (1) + 10
end if
if CarMove (2) = 850 and EastWestGo = false then
else
CarMove (2) := CarMove (2) - 10
end if
if CarMove (3) = 520 and NorthSouthGo = false then
else
CarMove (3) := CarMove (3) - 10
end if
if CarMove (4) = 80 and NorthSouthGo = false then
else
CarMove (4) := CarMove (4) + 10
end if
if CarMove (1) > maxx then
CarMove (1) := 0
end if
if CarMove (2) < 0 then
CarMove (2) := 1400
end if
if CarMove (3) < 0 then
CarMove (3) := 750
end if
if CarMove (4) > 750 then
CarMove (4) := 0
end if
%--------------------------------------StopLights-------------------------------------------
%West stop light
if EastWest = true then
Pic.Draw (Hand (1), 545, 475, picCopy) % North South Hand Light
Pic.Draw (Hand (2), 820, 475, picCopy) % North South Hand Light
Pic.Draw (Hand (3), 820, 245, picCopy) % West Walk Light
Pic.Draw (Hand (4), 545, 245, picCopy) % North South Hand Light
Pic.Draw (StopLight (0), 680, 474, picCopy)
Pic.Draw (StopLight (0), 680, 230, picCopy)
if timer < 30 then
Pic.Draw (Hand (1), 570, 510, picCopy) % West Stop Light
Pic.Draw (Hand (2), 800, 510, picCopy) % East Hand Light
Pic.Draw (Hand (3), 570, 215, picCopy) % West Walk Light
Pic.Draw (Hand (4), 800, 215, picCopy) % East Walk Light
EastWestGo := false
playrev := false
Pic.Draw (StopLight (0), 560, 350, picCopy) %West red stop light
Pic.Draw (StopLight (0), 800, 350, picCopy) %East red stop light
elsif timer < 100 then
EastWestGo := true
Pic.Draw (Walk (1), 570, 510, picCopy) % West Walk Light
Pic.Draw (Walk (2), 800, 510, picCopy) % East Walk Light
Pic.Draw (Walk (3), 570, 215, picCopy) % West Walk Light
Pic.Draw (Walk (4), 800, 215, picCopy) % East Walk Light
if playrev = false then
fork PlayEngineRev
playrev := true
else
end if
Pic.Draw (StopLight (1), 560, 350, picCopy) %West green stop light
Pic.Draw (StopLight (1), 800, 350, picCopy) %East green stop light
elsif timer < 120 then
EastWestGo := false
Pic.Draw (Hand (1), 570, 510, picCopy) % West Hand Light
Pic.Draw (Hand (2), 800, 510, picCopy) % East Hand Light
Pic.Draw (Hand (3), 570, 215, picCopy) % West Walk Light
Pic.Draw (Hand (4), 800, 215, picCopy) % East Walk Light
Pic.Draw (StopLight (2), 560, 350, picCopy) %West yellow stop light
Pic.Draw (StopLight (2), 800, 350, picCopy) %East yellow stop light
end if
else
Pic.Draw (Hand (1), 570, 510, picCopy) % West Hand Light
Pic.Draw (Hand (2), 800, 510, picCopy) % East Hand Light
Pic.Draw (Hand (3), 570, 215, picCopy) % West Walk Light
Pic.Draw (Hand (4), 800, 215, picCopy) % East Walk Light
Pic.Draw (StopLight (0), 560, 350, picCopy) %West red stop light
Pic.Draw (StopLight (0), 800, 350, picCopy) %East red stop light
if timer < 30 then
Pic.Draw (Hand (1), 545, 475, picCopy) % West Hand Light
Pic.Draw (Hand (2), 820, 475, picCopy) % East Hand Light
Pic.Draw (Hand (3), 820, 245, picCopy) % West Walk Light
Pic.Draw (Hand (4), 545, 245, picCopy) % East Walk Light
NorthSouthGo := false
playrev := false
Pic.Draw (StopLight (0), 680, 474, picCopy) %North red stop light
Pic.Draw (StopLight (0), 680, 230, picCopy) %South red stop light
elsif timer < 100 then
NorthSouthGo := true
Pic.Draw (Walk (1), 545, 475, picCopy) % West Walk Light
Pic.Draw (Walk (2), 820, 475, picCopy) % East Walk Light
Pic.Draw (Walk (3), 820, 245, picCopy) % West Walk Light
Pic.Draw (Walk (4), 545, 245, picCopy) % East Walk Light
Pic.Draw (StopLight (1), 680, 474, picCopy) %North green stop light
Pic.Draw (StopLight (1), 680, 230, picCopy) %South green stop light
if playrev = false then
fork PlayEngineRev
playrev := true
else
end if
elsif timer < 120 then
NorthSouthGo := false
Pic.Draw (Hand (1), 545, 475, picCopy) % West Hand Light
Pic.Draw (Hand (2), 820, 475, picCopy) % East Hand Light
Pic.Draw (Hand (3), 820, 245, picCopy) % West Walk Light
Pic.Draw (Hand (4), 545, 245, picCopy) % West Walk Light
Pic.Draw (StopLight (2), 680, 474, picCopy) %North yellow stop light
Pic.Draw (StopLight (2), 680, 230, picCopy) %South yellow stop light
end if
end if
%-----------------------------Character-----------------------------------------------------
if CharIndex = 6 then
CharIndex := 0
end if
if y > 750 then
y := 1
elsif y < 0 then
y := 750
end if
if x1 > 1400 then
x1 := 0
elsif x1 < 0 then
x1 := 1400
end if
%drawoval(x1,y,70,70,red)
if Right = true then
Pic.Draw (imgRight (RightCount), x1, y, picCopy) %--------------------------------------------------------------------------------------------
elsif Left = true then
Pic.Draw (imgLeft (LeftCount), x1, y, picCopy)
elsif Up = true then
Pic.Draw (imgUp (UpCount), x1, y, picCopy)
else
Pic.Draw (imgDown (DownCount), x1, y, picCopy)
end if
%------------------------------------Sonic--------------------------------------------------
Pic.Draw (Sonic (i), x, 475, picCopy)
x := x + 2
i := i + 1
if i = 6 then
i := 0
end if
Pic.Draw (Sonic2 (i3), x3, y3, picCopy)
if y3 < 241 then
x3 := x3 - 3
elsif x3 < 810 and x3 > 803 then
y3 := y3 - 2
else
x3 := x3 - 3
end if
i3 := i3 + 1
if i3 = 6 then
i3 := 0
end if
delay (70)
if FlagIndex = 74 then
FlagIndex := 0
end if
delay (10)
timer := timer + 1
locate (1, 1)
%-------------------------------------Switch the lights-------------------------------------------
if timer > 115 then
timer := 0
if EastWest = true then
EastWest := false
NorthSouth := true
else
EastWest := true
NorthSouth := false
end if
end if
end loop
%for i : 1..1400
%end for
So my questions is the part that is bold is the problem im having, when ever i run the program it keeps highlight that as the mistake, and once i delete that another mistake shows up, can some please help me making this project work.)
StopLight (2) := Pic.FileNew ( |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Fri Jan 04, 2013 4:33 pm Post subject: RE:Traffic Lights Project Help!!! |
|
|
What kind of a mistake is it? (That is, what does the error message say?)
Also
Quote:
...
Flag (70) := Pic.FileNew ("Frame70.jpg")
Flag (71) := Pic.FileNew ("Frame71.jpg")
Flag (72) := Pic.FileNew ("Frame72.jpg")
Flag (73) := Pic.FileNew ("Frame73.jpg")
Flag (74) := Pic.FileNew ("Frame74.jpg")
Doesn't this look like it could be simplified with using a for-loop? Since every line is so similar and the only difference is a counter. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Panphobia
![](http://compsci.ca/v3/uploads/user_avatars/62033050050c6b61548706.png)
|
Posted: Fri Jan 04, 2013 5:27 pm Post subject: RE:Traffic Lights Project Help!!! |
|
|
Are you from ccvi in a grade 11 engineering class o: mr. Cutten your teacher? Not on topic just wondering because I did the same thing last year |
|
|
|
|
![](images/spacer.gif) |
evildaddy911
|
Posted: Sat Jan 05, 2013 1:16 pm Post subject: RE:Traffic Lights Project Help!!! |
|
|
Panphobia: i did a very similar project last year too, must just be a common project idea...
Hotmail: in the future, if you want to post a program that long, please just upload the file; there's an attachments button at the bottom of the posting page
Most of the time, an error at a Pic.Draw command is because the picture file didn't load properly. the most common reasons for this are:
-- file doesn't exist
-- file wasn't in the same folder as the program
-- you misspelled the file name
-- picture format (.png, .gif) isn't supported |
|
|
|
|
![](images/spacer.gif) |
|
|