-
Notifications
You must be signed in to change notification settings - Fork 0
/
CarSummative.t
131 lines (116 loc) · 3.87 KB
/
CarSummative.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
% |--------------------------------------------------------|
% | Car Project |
% | By: Verdi R-D and Kyle |
% | Program Description: This program acts as a remote |
% | control for car lights. More text will be added |
% | here later. |
% |--------------------------------------------------------|
% ---------------------------------------------------------
% Imports & Includes
% ---------------------------------------------------------
import GUI
% ---------------------------------------------------------
% Configuration
% ---------------------------------------------------------
View.Set("graphics")
const bgimagepath : string := "pic.jpg" % Path to the background image
const horntime : int := 100 % Time the horn is played in milliseconds
% ---------------------------------------------------------
% Globals
% ---------------------------------------------------------
var leftturnon : boolean := false
var rightturnon : boolean := false
var brakeon : boolean := false
var drivingon : boolean := false
var backupon : boolean := false
% ---------------------------------------------------------
% Background - Draws the background
% ---------------------------------------------------------
procedure background ()
var bgimage :int:= Pic.FileNew (bgimagepath)
bgimage := Pic.Scale(bgimage, View.maxx, View.maxy)
Pic.Draw (bgimage, 0, 0, 0)
Pic.Free(bgimage)
end background
% ---------------------------------------------------------
% Button click procedures
% ---------------------------------------------------------
procedure leftturn ()
if leftturnon then
parallelput(1)
leftturnon := true
else
parallelput(0)
leftturnon := false
end if
end leftturn
procedure rightturn ()
if rightturnon then
parallelput(2)
rightturnon := true
else
parallelput(0)
rightturnon := false
end if
end rightturn
procedure brake ()
if brakeon then
parallelput(4)
brakeon := true
else
parallelput(0)
brakeon := false
end if
end brake
procedure driving ()
if drivingon then
parallelput(8)
drivingon := true
else
parallelput(0)
drivingon := false
end if
end driving
procedure backup ()
if backupon then
parallelput(16)
backupon := true
else
parallelput(0)
backupon := false
end if
end backup
procedure horn ()
parallelput(32)
delay(horntime)
parallelput(0)
end horn
procedure alloff ()
parallelput(0)
end alloff
% ---------------------------------------------------------
% Menu - Display the menu and loop until a button is pressed
% ---------------------------------------------------------
procedure menu ()
var btnleftturn :int := GUI.CreateButton (maxx - 200, 200, 150, "Left Turn Lights", leftturn)
var btnrightturn :int := GUI.CreateButton (maxx - 200, 175, 150, "Right Turn Lights", rightturn)
var btnbrake :int := GUI.CreateButton (maxx - 200, 150, 150, "Brake Lights", brake)
var btndriving :int := GUI.CreateButton (maxx - 200, 125, 150, "Driving Lights", driving)
var btnbackup :int := GUI.CreateButton (maxx - 200, 100, 150, "Backup Lights", backup)
var btnhorn :int := GUI.CreateButton (maxx - 200, 75, 150, "Horn", horn)
var btnalloff :int := GUI.CreateButton (maxx - 200, 50, 150, "All Lights Off", alloff)
loop
exit when GUI.ProcessEvent
end loop
end menu
% ---------------------------------------------------------
% Main - Starts the entire program
% ---------------------------------------------------------
procedure main ()
background()
menu()
end main
% ---------------------------------------------------------
% Starts main (leave this alone)
% ---------------------------------------------------------
main()