What is it you are trying to achieve?
I am trying to make a floorplan which has lights in it- with a menu to turn the lights on and off
What is the problem you are having?
<I am trying to make a menu with this floorplan and want to turn the lights on (room turns yellow) and off (room turns greyish black)>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<My code is below>
| Turing: |
<var LivingRoom, TVMediaRoom, Bedroom, OfficeRoom, Hallway, Kitchen, DiningRoom, Toilet : boolean := false
setscreen ("graphics:1200;400")
var font : int
font := Font.New ("serif:6")
procedure grid
for x : 10 .. maxx by 10
for y : 10 .. maxy by 10
drawdot (x, y, black)
end for
end for
for x : 10 .. maxx by 20
Draw.Text (intstr (x ), x - 3, maxy - 6, font, red)
end for
for y : 20 .. maxy by 20
Draw.Text (intstr (y ), maxx - 12, y - 3, font, red)
end for
end grid
%To remove this grid, put a percent sign in front of the following line
grid
var option : string := "" %Rep
loop
%Lights
Draw.FillOval (90, 280, 10, 10, yellow)
Draw.FillOval (290, 280, 10, 10, yellow)
Draw.FillOval (530, 280, 10, 10, yellow)
Draw.FillOval (110, 120, 10, 10, yellow)
Draw.FillOval (220, 120, 10, 10, yellow)
Draw.FillOval (490, 120, 10, 10, yellow)
Draw.FillOval (350, 120, 10, 10, yellow)
Draw.FillOval (430, 165, 10, 10, yellow)
%Text
var font3 : int := Font.New ("Copperplate Gothic Bold:12") %FONT
var font1 : int := Font.New ("serif:12") % FONT
Draw.Text ("Living Room", 250, 270, font1, black) % FONT
Draw.Text ("TV/Media Room", 40, 270, font1, black) % FONT
Draw.Text ("Bedroom", 70, 120, font1, black) % FONT
Draw.Text ("Office Room", 190, 120, font1, black) % FONT
Draw.Text ("Hallway", 330, 120, font1, black) % FONT
Draw.Text ("Kitchen", 470, 120, font1, black) % FONT
Draw.Text ("Dining Room", 490, 280, font1, black) % FONT
var font2 : int := Font.New ("serif:8") % FONT
Draw.Text ("Toilet", 420, 165, font2, black) % FONT
%Back Side of House
drawline (30, 360, 270, 360, black)
drawline (270, 360, 270, 350, black)
drawline (270, 350, 320, 350, black)
drawline (320, 350, 320, 360, black)
drawline (320, 360, 600, 360, black)
drawline (600, 360, 600, 350, black)
drawline (600, 350, 610, 350, black)
%Left Side Of House
drawarc (30, 275, 30, 35, 90, 272, black)
drawline (30, 360, 30, 310, black)
drawline (30, 240, 30, 190, black)
drawline (30, 240, 30, 190, black)
drawline (40, 190, 40, 140, black)
drawline (40, 140, 80, 100, black)
drawline (80, 100, 80, 60, black)
%Inside Walls
drawline (30, 190, 120, 190, black)
drawline (160, 190, 320, 190, black)
drawline (380, 190, 600, 190, black)
drawline (150, 360, 150, 210, black)
drawline (150, 210, 130, 210, black)
drawline (130, 210, 120, 190, black)
drawline (120, 190, 130, 170, black)
drawline (130, 170, 150, 170, black)
drawline (150, 90, 150, 170, black)
drawline (150, 170, 160, 190, black)
drawline (290, 190, 290, 40, black)
drawline (410, 40, 410, 190, black)
drawline (450, 360, 450, 190, black)
drawline (460, 190, 460, 160, black)
drawline (460, 160, 440, 140, black)
drawline (440, 140, 410, 140, black)
%Front Side of House
drawline (80, 60, 120, 60, black)
drawline (120, 60, 150, 90, black)
drawline (150, 90, 180, 60, black)
drawline (180, 60, 290, 60, black)
drawline (290, 40, 310, 20, black)
drawline (310, 20, 330, 20, black)
drawarc (350, 20, 20, 20, 0, 180, black)
drawline (370, 20, 390, 20, black)
drawline (390, 20, 410, 40, black)
drawline (410, 60, 570, 60, black)
%Right Side of House
drawline (570, 60, 570, 190, black)
drawline (600, 190, 600, 200, black)
drawline (600, 200, 610, 200, black)
drawline (610, 200, 610, 350, black)
%Doors
drawline (130, 210, 140, 200, black)
drawline (130, 170, 140, 180, black)
drawline (270, 350, 290, 360, black)
drawline (300, 360, 320, 350, black)
drawline (450, 300, 440, 290, black)
drawline (440, 270, 450, 260, black)
drawline (260, 190, 270, 200, black)
drawline (410, 150, 400, 170, black)
drawline (500, 190, 510, 200, black)
drawline (530, 200, 540, 190, black)
drawline (400, 80, 410, 100, black)
drawline (335, 35, 340, 30, black)
drawline (365, 35, 360, 30, black)
% Text in Menu
Font.Draw ("Menu", 700, 370, font3, 21) %Text: Menu
Font.Draw ("To turn on lights in TV/ Media Room, press 1", 630, 350, font3, 21) %Text: TV/ Media Room
Font.Draw ("To turn on lights in Living Room, press 2", 630, 330, font3, 21) %Text: Living Room
Font.Draw ("To turn on lights in Toilet, press 3", 630, 310, font3, 21) %Text: Toilet
Font.Draw ("To turn on lights in Kitchen, press 4", 630, 290, font3, 21) %Text: Kitchen
Font.Draw ("To turn on lights in Bedroom, press 5", 630, 270, font3, 21) %Text: Bedroom
Font.Draw ("To turn on lights in Office Room, press 6", 630, 250, font3, 21) %Text: Office Room
Font.Draw ("To turn on lights in Dining Room, press 7", 630, 230, font3, 21) %Text: Dining Room
Font.Draw ("To turn on lights in Hallway, press 8", 630, 210, font3, 21) %Text: Hallway
locate (14, 90)
get option % Gets the user's input
if option = "1" then % Option for TV/ Media Room
if TVMediaRoom = true then
TVMediaRoom := false
Draw.FillOval (90, 280, 10, 10, 7)
Draw.Fill (90, 260, 7, black)
elsif TVMediaRoom = false then
TVMediaRoom := true
Draw.FillOval (90, 280, 10, 10, yellow)
Draw.Oval (90, 280, 10, 10, 7)
Draw.Fill (90, 260, yellow, 7)
end if
end if
end loop
>
|
Please specify what version of Turing you are using
<4.1.1> |