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

Username:   Password: 
 RegisterRegister   
 Turing chaging screen/clear screen help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
turinguser4000




PostPosted: Wed Dec 11, 2013 1:58 am   Post subject: Turing chaging screen/clear screen help

What is it you are trying to achieve?
<Chaging the room or clearing a screen to start a new one, i want the stickman to enter the house and to make a new screen for the house>


What is the problem you are having?
i don't know how to clear the screen


Describe what you have tried to solve this problem
i have tried using cls, and drawing over the first picture>

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:

View.Set ("offscreenonly")

var keyboard:array char of boolean
var start:int :=500
var start2:int :=1
var trigger:int :=1
var trigger2:int :=1



loop
    Input.KeyDown (keyboard)
    if keyboard ('d') and start < 693 then
    start +=2
    delay(15)
    end if


     if keyboard ('a') and start > -100 then
    start -=2
    delay(15)
    end if
   
     if keyboard ('w') and start2 < 120 then
    start2 +=2
    delay(15)
    end if
   
    if keyboard ('s') and start2 > 1 then
    delay (15)
    end if
     
   
   
   
 
   
%House & Road   
drawbox (10, 160, 230, 300, 3)
drawfill (30, 190, 4, 3)
drawoval (120, 270, 110, 100, 4)
drawfill (150, 300, 9, 4)
drawline (240, 60, 9000, 60, 3)
drawline (190, 160, 240, 60, 3)
drawline (100, 160, 50, 60, 3)
drawline (0, 60, 50, 60, 3)
drawfill (2,2,3,3)
drawfillbox (30, 230, 100, 280, 0)
drawline (65,280,65,230,6)
drawline (29,255,100,255,6)
drawfillbox (120,161,190,250,11)
drawfilloval (180,200,5,5,2)
   



    drawfillbox (trigger+120,trigger2+109,trigger+190,trigger2+160,3)
    drawfilloval (180,200,5,5,2)
    drawfilloval (start+100,start2+125,23,23,8)
    drawfillbox (start+90,start2+102,start+110,start2+45,9)
    drawline (start+90,start2+100,start+70,start2+65,16)
    drawline (start+125,start2+67,start+110,start2+101,16)
    drawline (start+110,start2+45,start+120,start2+1,16)
    drawline (start+89,start2+44,start+80,start2+1,16)
   
 
   
   


     
   
   View.Update
   cls
    if start  - 100 < trigger and start2 - 100 < trigger2 and keyboard ('p') then%If P is pressed at the given parameter the screen will switch to white
    drawfillbox (1,1000,1000,1,9)
    end if

   
end loop



Please specify what version of Turing you are using

4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed Dec 11, 2013 7:21 am   Post subject: RE:Turing chaging screen/clear screen help

You're probably having an issue because you're drawing the new scene, and then drawing the old scene right on top of it. You need a way to keep track of which scene you're drawing, so that you don't draw any others. To make this easy, I recommend moving all of your scenes into their own procedures, and only calling the procedure that corresponds to the scene you want to draw.
turinguser4000




PostPosted: Wed Dec 11, 2013 8:36 am   Post subject: Re: Turing chaging screen/clear screen help

I'm still kind of new to turing can you tell me what you mean by moving all of the scenes to their own procedure?
Raknarg




PostPosted: Wed Dec 11, 2013 10:31 am   Post subject: RE:Turing chaging screen/clear screen help

Sometimes it's easier to encapsulate code snippets inside procedures. What they do is basically whenever you call them, they;ll just perform thecode that's inside them. For instance:

Turing:

procedure hello_world
     put "Hello World!"
end hello_world

hello_world


Now every time you put hello_world in your program it'll just perform the code inside it, which is putting "Hello World" on the screen. Procedures can do more but that should be fie for now. You can look at them more in the Turing Walkthrough
turinguser4000




PostPosted: Wed Dec 11, 2013 4:41 pm   Post subject: Re: Turing chaging screen/clear screen help

so in my situation where and how should i add the procedure command?
Insectoid




PostPosted: Wed Dec 11, 2013 4:55 pm   Post subject: RE:Turing chaging screen/clear screen help

Ideally, you'll have a procedure for each scene. for example,

code:

procedure drawHouse
    %put all commands to draw a house here.
end drawHouse

procedure drawLivingRoom
    %put all commands to draw the living room here.
end drawLivingRoom

%You might need some way to keep track of which scene you're trying to draw. How about using an integer?

var scene : int := 0

loop
    if scene = 0 then
        dawHouse
    else if scene = 1 then
        drawLivingRoom
    end if
end loop

%Now to change the scene, you just change the value of scene.
turinguser4000




PostPosted: Wed Dec 11, 2013 10:38 pm   Post subject: Re: Turing chaging screen/clear screen help

Sorry if my question is already answered in any of the previous posts but after using procedure i now have something like this :

Turing:

View.Set ("offscreenonly")

var keyboard:array char of boolean
var start:int :=500
var start2:int :=1
var trigger:int :=1
var trigger2:int :=1
var scene :int := 0
var scene2 :int :=1

procedure house
drawbox (10, 160, 230, 300, 3)
drawfill (30, 190, 4, 3)
drawoval (120, 270, 110, 100, 4)
drawfill (150, 300, 9, 4)
drawline (240, 60, 9000, 60, 3)
drawline (190, 160, 240, 60, 3)
drawline (100, 160, 50, 60, 3)
drawline (0, 60, 50, 60, 3)
drawfill (2,2,3,3)
drawfillbox (30, 230, 100, 280, 0)
drawline (65,280,65,230,6)
drawline (29,255,100,255,6)
drawfillbox (120,161,190,250,11)
drawfilloval (180,200,5,5,2)
end house

procedure livingroom
drawfillbox (1,1000,1000,1,40)
end livingroom

loop

    if scene = 0 then
    house
    end if
   
    if scene = 1 then
    livingroom
    end if
   
    if start  - 100 < trigger and start2 - 100 < trigger2 and keyboard ('p') then
    livingroom
    end if
   
   
    Input.KeyDown (keyboard)
    if keyboard ('d') and start < 693 then
    start +=2
    delay(15)
    end if


     if keyboard ('a') and start > -100 then
    start -=2
    delay(15)
    end if
   
     if keyboard ('w')and start2 < 120 then
    start2 +=2
    delay(15)
    end if
   
    if keyboard ('s') and start2 > 1 then
    start2 -=2
    delay (15)
    end if
     
   



    drawfillbox (trigger+120,trigger2+109,trigger+190,trigger2+160,3)
    drawfilloval (180,200,5,5,2)
    drawfilloval (start+100,start2+125,23,23,8)
    drawfillbox (start+90,start2+102,start+110,start2+45,9)
    drawline (start+90,start2+100,start+70,start2+65,16)
    drawline (start+125,start2+67,start+110,start2+101,16)
    drawline (start+110,start2+45,start+120,start2+1,16)
    drawline (start+89,start2+44,start+80,start2+1,16)
   
 
 

   
   
   View.Update
   cls
 



unfortunately i still have the same problem when i press p to enter the house the screen only flickers. I'm also not sure what you mean by : %You might need some way to keep track of which scene you're trying to draw. How about using an integer?

var scene : int := 0

how do i call which scene goes in which?



Mod Edit:
Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code:

[syntax="turing"] ... code ... [/syntax]

[code] ... code ... [/code ]
Raknarg




PostPosted: Thu Dec 12, 2013 10:32 am   Post subject: RE:Turing chaging screen/clear screen help

Yes, an integer would do fine. Good thinking.

It looks like you've got an if to tell you when you've entered the house. You also have an integer that keeps track of whether or not you have entered the house. What should happen when you enter the house, code wise? (hint: it's something to do with these two ideas, you almost have it)
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  [ 8 Posts ]
Jump to:   


Style:  
Search: