What is it you are trying to achieve?
Have all the lights be able to comeon simultaneously on my model built car (not the program)
What is the problem you are having?
I just dont know how. It lights up on the actual program, but on the car im using, it seems i can only send 1 parallelput "signal" at a time. I dont think this is the case
Describe what you have tried to solve this problem
Getting rid of some of the code, but then like the main functionality is lost
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Sorry in advance if its too long, i just think its easier instead of having to download the file
Turing: |
% This command tells the program that we are making a Graphics User Interface
% and imports the premade module for that
import GUI
% Here, the screen resolution is set.
setscreen ("graphics:640;480")
% The following 2 variables are the 2 background pictures that are used
var vipeback : int := Pic.FileNew ("viper2dash.bmp")
var vipebackON : int := Pic.FileNew ("viper2dashON.bmp")
% These variables control the toggle lights system for the
% left lights, right lights, break lights, and head lights, respectively
var llon : boolean
var rlon : boolean
var blon : boolean
var hlon : boolean
% Here we draw the more "darkened" out background, which represents a not fully on system
Pic.Draw (vipeback, maxx div 650, maxy div 650, 0)
delay (600)
% An altered Image of the car with the main light areas lightened up, as well as the dashboard, to simulate
% light being cast from the lights
Pic.Draw (vipebackON, maxx div 650, maxy div 650, 0)
% These are circles are drawn, to simulate an off position
% if we were to have made the GUI more realistic and changed to a different picture
% for each light, we would have 100's of combinations of lights, and result in a slow program
% Left Turn light
Draw.FillOval (265, 370, 9, 9, white)
Draw.FillOval (320, 312, 6, 6, white)
% Left Turn Light (Angled Model)
Draw.FillOval (614, 157, 3, 3, white)
% Right Turn light
Draw.FillOval (25, 370, 9, 9, white)
Draw.FillOval (600, 312, 6, 6, white)
% Right Turn Light (Angled Model)
Draw.FillOval (495, 111, 6, 6, white)
% Brake Lights
Draw.FillOval (325, 337, 10, 10, white)
Draw.FillOval (600, 337, 10, 10, white)
% Head Lights
Draw.FillOval (45, 365, 11, 11, white)
Draw.FillOval (245, 365, 11, 11, white)
% Head Lights (Angled Model)
Draw.FillOval (610, 148, 5, 5, white)
Draw.FillOval (515, 105, 7, 7, white)
% Backlights are red
% Turn signals are Yellow
% Headlights are orange
% The lefturn procedure begins when button1 is clicked, it reads the buttons current status
% and nots it, which is then "sent" to the GUI.Process.Event loop near the bottom
procedure lefturn
llon := not llon
end lefturn
% The righturn procedure begins when button2 is clicked, the same result as the left turn light occurs
procedure righturn
rlon := not rlon
end righturn
% The breaklight procedure begins when button3 is clicked, here we check if the button is on or not, and if it is, we
% draw the light on, if not, we draw the lights back to the off position
procedure breaklight
blon := not blon
if blon then
Draw.FillOval (325, 337, 10, 10, 40)
Draw.FillOval (600, 337, 10, 10, 40)
%parallelput (2)
else
Draw.FillOval (325, 337, 10, 10, white)
Draw.FillOval (600, 337, 10, 10, white)
%parallelput (0)
end if
end breaklight
% The headlight procedure begins when button4 is clicked, and the same result as the breaklight occurs
procedure headlight
hlon := not hlon
if hlon then
Draw.FillOval (45, 365, 11, 11, 41)
Draw.FillOval (245, 365, 11, 11, 41)
Draw.FillOval (610, 148, 5, 5, 41)
Draw.FillOval (515, 105, 7, 7, 41)
%parallelput (1)
else
Draw.FillOval (45, 365, 11, 11, white)
Draw.FillOval (245, 365, 11, 11, white)
Draw.FillOval (610, 148, 5, 5, white)
Draw.FillOval (515, 105, 7, 7, white)
%parallelput (0)
end if
end headlight
% These are the buttons themselves, all of them are "paired" with a procedure
% that begins when the button is clicked.
var button1 : int := GUI.CreateButton (25, 25, - 10, "", lefturn )
var button2 : int := GUI.CreateButton (25, 50, - 10, "", righturn )
var button3 : int := GUI.CreateButton (240, 25, - 10, "", breaklight )
var button4 : int := GUI.CreateButton (240, 50, - 10, "", headlight )
% Here we set the values for all the lights to false at the beginning,
% To represent them being off
llon := false
rlon := false
blon := false
hlon := false
% In the following loop, the off/on status of the buttons from the lefturn and righturn is processed
% and the lights turn on/off depending on the status of the button
% This loop is also run through out the entire program regardless, as GUI.Process.Event
% is the command that checks for any buttons pressed
loop
if llon then
Draw.FillOval (265, 370, 9, 9, yellow)
Draw.FillOval (320, 312, 6, 6, yellow)
Draw.FillOval (614, 157, 3, 3, yellow)
%parallelput (8)
delay (300)
Draw.FillOval (265, 370, 9, 9, white)
Draw.FillOval (320, 312, 6, 6, white)
Draw.FillOval (614, 157, 3, 3, white)
%parallelput (0)
delay (300)
end if
if rlon then
Draw.FillOval (25, 370, 9, 9, yellow)
Draw.FillOval (600, 312, 6, 6, yellow)
Draw.FillOval (495, 111, 6, 6, yellow)
%parallelput (4)
delay (300)
Draw.FillOval (25, 370, 9, 9, white)
Draw.FillOval (600, 312, 6, 6, white)
Draw.FillOval (495, 111, 6, 6, white)
%parallelput (0)
delay (300)
end if
exit when GUI.ProcessEvent
end loop
|
Please specify what version of Turing you are using
4.1.1A |