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

Username:   Password: 
 RegisterRegister   
 Floorplan in Turing- Need Help!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chinfin




PostPosted: Fri May 28, 2010 10:49 am   Post subject: Floorplan in Turing- Need Help!

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?




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>
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri May 28, 2010 12:19 pm   Post subject: RE:Floorplan in Turing- Need Help!

...and what's the problem you're running into, and what have you tried to solve it?
chinfin




PostPosted: Fri May 28, 2010 1:38 pm   Post subject: RE:Floorplan in Turing- Need Help!

I'm not sure how to put lights and make a menu to turn them on and off in each room.. I am a beginner... if someone could help me that would be great.
BigBear




PostPosted: Fri May 28, 2010 1:49 pm   Post subject: RE:Floorplan in Turing- Need Help!

Alright so you have the drawing all done.

I would make a drawFloorPlan procedure, to take all of that clutter out of your main loop.

Does a yellow circle in each room mean the lights are on?

If so you could just accept input then if they want to turn the lights on draw a yellow circle at a certain spot.

You might need to redraw your title or grid over top of the yellow but that's OK if it is in a function
chinfin




PostPosted: Fri May 28, 2010 2:00 pm   Post subject: RE:Floorplan in Turing- Need Help!

can you do it for me?
BigBear




PostPosted: Fri May 28, 2010 4:06 pm   Post subject: RE:Floorplan in Turing- Need Help!

get input
if they say they want it on in room #1 draw it here
if they want room#2 draw it here

etc

you already got a procedure so you should know how to put the drawing in one
chinfin




PostPosted: Sat May 29, 2010 9:17 am   Post subject: RE:Floorplan in Turing- Need Help!

oh man im not sure how to do this
BigBear




PostPosted: Sat May 29, 2010 12:25 pm   Post subject: RE:Floorplan in Turing- Need Help!

Did you write that code, it is all in that program.
Sponsor
Sponsor
Sponsor
sponsor
supaphreek




PostPosted: Sat May 29, 2010 12:26 pm   Post subject: RE:Floorplan in Turing- Need Help!

Its as big bear said.

Now im assuming that if there is a yellow light, it means the light is on.

So what you have to do is create the floorplan without the yellow circles which would be your basic thing. Then you have

get input
if input = "1" then
drawfilloval ...
elsif input = "2" then
drawfilloval ...

and so on.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: