Posted: Sun Nov 06, 2011 11:49 am Post subject: I need help finding out how to alter the code in the following way : Within the thread
What is it you are trying to achieve?
I am trying to find out the answer as to what i had wrote below.
What is the problem you are having?
I am trying figure out how to change the code so that after it finishes scene 1, it will switch to scene 2.
I am also trying to figure out how to make it so that when the green light goes on, the car will drive, but when the red light comes it will stop.
Describe what you have tried to solve this problem
I have tried altering the code in many ways, and have tried to find tutorials around this forum for help.
I could not find any tutorials. I have also tried to delete some of the code to possibly make it work, but i am now stumped, and have no clue how to fix either of them.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using
I am using 4.11a, but i also need it to run on my school computer which is turing 4.01a
Sponsor Sponsor
Velocity
Posted: Sun Nov 06, 2011 12:39 pm Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread
I will give 3 bits <<<< LOL to the answer-(er).
Velocity
Posted: Sun Nov 06, 2011 12:57 pm Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread
Bump - Still looking for answer... Thanks to anyone who is trying.
Aange10
Posted: Sun Nov 06, 2011 1:00 pm Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread
Velocity wrote:
What is the problem you are having?
I am trying figure out how to change the code so that after it finishes scene 1, it will switch to scene 2.
I am also trying to figure out how to make it so that when the green light goes on, the car will drive, but when the red light comes it will stop.
Okay so lets go one at a time.
Velocity wrote:
I am trying figure out how to change the code so that after it finishes scene 1, it will switch to scene 2.
So how would we let the computer know that we've completed the scene? How about something like
Turing:
var scene :int:=1 var counter :int:=0
loop% A loop containing the scenes if scene =1then loop% Scene one
counter +=1 % Coding if counter =200then
scene :=2 endif exitwhen scene not=1 endloop elsif scene =2then
counter :=0 loop% Scene two
counter +=1 % Coding if counter =300then
scene :=3 endif exitwhen scene not=2 endloop else% If scene isn't 1 or 2 % Program complete! exit endif endloop
Now, lets tackle your second problem:
Velocity wrote:
I am also trying to figure out how to make it so that when the green light goes on, the car will drive, but when the red light comes it will stop.
Okay, so how could we tell the computer that the light is green or if its red ? Once we tell the computer it's red, how do we stop the car? Or make it stop moving?
Turing:
var red_light :boolean:=false if red_light =truethen
car_velocity :=0% Stops moving elsif red_light =falsethen
car_velocity :=5% Keeps going endif
Velocity
Posted: Sun Nov 06, 2011 1:13 pm Post subject: Re: I need help finding out how to alter the code in the following way : Within the thread
Turing:
View.Set("graphics:800;700,offscreenonly,nobuttonbar") var keyinput :string(1):="x" var scene :int:=1 var counter :int:=0 var red_light :boolean:=false var car_velocity :int if red_light =truethen
car_velocity :=0% Stops moving elsif red_light =falsethen
car_velocity :=5% Keeps going endif
process playstuff
loop sound(160, 516) delay(100) sound(270, 200) delay(100) sound(230, 230) delay(100) sound(476, 520) delay(100) sound(236, 250) delay(100) endloop end playstuff
fork playstuff
loop for i :1.. 800 delay(10) cls loop% A loop containing the scenes if scene =1then loop% Scene one
counter +=1 % Coding if counter =200then
scene :=2 endif exitwhen scene not= 1 endloop elsif scene =2then
counter :=0 loop% Scene two
counter +=1 % Coding if counter =300then
scene :=3 endif exitwhen scene not= 2 endloop else% If scene isn't 1 or 2 % Program complete! exit endif endloop
I added in the code like you said. The program runs, but it doesn't do anything :O
<h1>Im sorry if my inexperienced self did not put it in the correct spots</h1>
Aange10
Posted: Sun Nov 06, 2011 1:23 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
Hmm, do not copy and paste the coding I gave you; the code is written for you to understand it, not to copy and paste it - it doesn't work because it doesn't do anything.
Try looking at the coding, one line at a time.
Turing:
if scene =1then loop% Scene one
counter +=1 % Coding if counter =200then
scene :=2 endif exitwhen scene not= 1 endloop
We are saying here that if the scene variable is set to the value of 1 , then we will execute the scene. Which I made a little scene there. We also have something telling us when to exit the scene. Right now It's set to change the scene to 2 when the counter reaches 200. Then I tell the computer to exit when scene is not = to 1 . .. Meaning we are no longer on the first scene.
Make sense?
Velocity
Posted: Sun Nov 06, 2011 1:33 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
ooooh, okay thanks alot! that helped.
Aange10
Posted: Sun Nov 06, 2011 1:53 pm Post subject: Re: RE:I need help finding out how to alter the code in the following way : Within the thread
Velocity @ 6/11/2011, 12:33 pm wrote:
ooooh, okay thanks alot! that helped.
No problem.
Sponsor Sponsor
Velocity
Posted: Sun Nov 06, 2011 4:58 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
okay, i got it too work thanks alot.
Velocity
Posted: Sun Nov 06, 2011 4:59 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
but wait, one more thing. What about the red light - stop, green light - go, thing?
Aange10
Posted: Sun Nov 06, 2011 5:34 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
Analyze the code step by step again.
Turing:
var red_light :boolean:=false if red_light =truethen
car_velocity :=0% Stops moving elsif red_light =falsethen
car_velocity :=5% Keeps going endif
I declared a boolean named red_light. I then set the booleanred_light to false. Now I tell the computer ifred_light = true then it stops the car's velocity. After that I said if red_light is false then make the car's velocity to 5.
Tony
Posted: Sun Nov 06, 2011 6:25 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
I don't remember, does Turing typecast boolean values into integers?
Posted: Tue Nov 08, 2011 6:51 pm Post subject: RE:I need help finding out how to alter the code in the following way : Within the thread
This may be more off topic than on topic, but...
Tony you work for or host the DWITE contest right? cause im going there first time this year for my school, is it worthwhile?