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

Username:   Password: 
 RegisterRegister   
 traffic light testing program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kokok




PostPosted: Sun May 06, 2007 9:29 pm   Post subject: traffic light testing program

hello. im kokok
currently im taking ICE3U
and we need to make a program using turing to control a mini traffic light

what we need to do is we need to click a circle that has color of red and then if you click it, it will turn into brighter red and if you click it again it will turn to the normal red, while you can make all of the lights on and off..
i been thinking about how to do this all day but i just dun get it
i tried to use double if...but it didn work..
im not saying you have to check my program but i want some advise on how to make such programs><

[quote]setscreen ("graphics:300;400:noecho:nocursur")

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------variables----------------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%variables for making pics%%
var red1, red2, green1, green2, yellow1, yellow2 : int
const r := 30
var R, Y, G : int := 0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------------actual program--------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
drawentire
var x, y, button : int

loop
Mouse.Where (x, y, button)

if x > 260 and x < 340 and y > 0 and y < 110 then %%green
if button = 1 then
Draw.FillOval (300, 80, r, r, 10)
G := 1
elsif button = 1 and G = 1 then
Draw.FillOval (300, 80, r, r, 2)
G := 0
end if

elsif x > 260 and x < 340 and y > 111 and y < 180 and button = 1 then %%%yellow
if button = 1 then
Draw.FillOval (300, 150, r, r, 44)
Y := 1
elsif button = 1 and Y = 1 then
Draw.FillOval (300, 150, r, r, 42)
Y := 0
end if

elsif x > 260 and x < 340 and y > 190 and y < 260 and button = 1 then %%red
if button = 1 then
Draw.FillOval (300, 220, r, r, 12)
R := 1
elsif button = 1 and R = 1 then
Draw.FillOval (300, 220, r, r, 4)
R := 0
end if
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: