This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-12-31 11:09:00

DaPoliteSniper
New Scratcher
Registered: 2012-12-31
Posts: 6

Turning and going

So I am pretty new to scratch and the reason I got into it was because it is on my rasberry pi I just got...
I have been working on this race program for some time now and I want to make it if I press the up arrow key and the left arrow key then the car will turn 5 degrees to the left and go forward but it only goes left once after that it just goes strait it the direction it was put (5 degrees)
I have looked at several sources and haven't found anything. Thanks to whoever can help me!

Offline

 

#2 2012-12-31 11:20:04

DaPoliteSniper
New Scratcher
Registered: 2012-12-31
Posts: 6

Re: Turning and going

I forgot to say when u let go of the arrow keys it must stop...

Offline

 

#3 2012-12-31 13:38:30

DaPoliteSniper
New Scratcher
Registered: 2012-12-31
Posts: 6

Re: Turning and going

Bump

Offline

 

#4 2012-12-31 13:46:29

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Turning and going

Since your car is turning and moving, I think that instead of giving you entire scripts, I might be able to help by fixing what you already have. So could you show your scripts or upload your project? Remember, if you don't want to do this, just say.  wink

Anyway, hello DaPoliteSniper and welcome to Scratch! I wish you an easy path to learning how to program!

Last edited by ErnieParke (2012-12-31 13:46:38)


http://i46.tinypic.com/35ismmc.png

Offline

 

#5 2012-12-31 13:56:50

DaPoliteSniper
New Scratcher
Registered: 2012-12-31
Posts: 6

Re: Turning and going

I am very sorry I can't upload them my raspberry pi doesn't have an Internet connection yet
(Don't have the parts) and I don't have the program for this turn I deleted the 5 or more tries that failed

Offline

 

#6 2012-12-31 15:29:55

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Turning and going

Were you using the

when [right arrow v] key pressed
hat blocks?
Those blocks only work one at a time, and cannot be active simultaneously.  Because of this, your scripts would make the car turn left once, stop using that script, and start using only the move forward scripts.

Instead of those blocks, try using
when gf clicked
forever
if <key [right arrow v] pressed?>
turn cw (10) degrees
end
end
This kind of scripting can work with other scripts at the same time.

Last edited by Kileymeister (2012-12-31 17:06:07)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#7 2012-12-31 16:33:22

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Turning and going

Kileymeister wrote:

Were you using the

when [right arrow v] key pressed
hat blocks?
Those blocks only work one at a time, and cannot be active simultaneously.  Because of this, your scripts would make the car turn left once, stop using that script, and start using only the move forward scripts.

Instead of those blocks, try using
when gf clicked
forever
if <key [right arrow v] pressed?>
turn cw (10) degrees
end
end
This kind of scripting can work with other scripts at the same time.

I think that you meant [turn (10) degrees] and not [move 10 steps], though other than that, you've got everything correct.


http://i46.tinypic.com/35ismmc.png

Offline

 

#8 2012-12-31 17:05:36

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Turning and going

ErnieParke wrote:

Kileymeister wrote:

Were you using the

when [right arrow v] key pressed
hat blocks?
Those blocks only work one at a time, and cannot be active simultaneously.  Because of this, your scripts would make the car turn left once, stop using that script, and start using only the move forward scripts.

Instead of those blocks, try using
when gf clicked
forever
if <key [right arrow v] pressed?>
turn cw (10) degrees
end
end
This kind of scripting can work with other scripts at the same time.

I think that you meant [turn (10) degrees] and not [move 10 steps], though other than that, you've got everything correct.

Blar, the move 10 steps was supposed to signify general script goodness, but I agree that could cause some misinterpretation.  Good call.


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#9 2012-12-31 19:09:16

DaPoliteSniper
New Scratcher
Registered: 2012-12-31
Posts: 6

Re: Turning and going

Sorry if you didn't unberstant my fault...
When the up arrow and left arrow key is pressed I want the car to turn 5 degrees to the left and then go forward untill the keys are released.
Thanks if anyone can help
Sorry for the trouble!

Offline

 

#10 2012-12-31 19:26:48

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: Turning and going

If I understand you correctly, the block you are looking for is the wait until block. Does this sample script achieve your goal?

when gf clicked
forever
wait until <key [right arrow v] pressed?> 
turn cw (5) degrees
wait until <not <key [right arrow v] pressed?> >
end
This script will control the turning, and the wait until blocks will ensure that it never turns more than 5 degrees from a single press of the right arrow.

This second script will control the movement
when gf clicked
forever
move (10) steps
end
EDIT: It seems time atrophies my skill with scratch blocks. I fixed the trouble I was having.

Last edited by demosthenes (2012-12-31 19:30:15)


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#11 2012-12-31 19:38:23

DaPoliteSniper
New Scratcher
Registered: 2012-12-31
Posts: 6

Re: Turning and going

The problem is I am making a really simple race game and little cars go around the track.
I do not only have this I have a lot of other things so I am not sure it is a simple as this.
This is not my only task...I have a number of other things that do along with this.
I am sort is this seems stupid in any way again I am new

Offline

 

#12 2012-12-31 19:43:12

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: Turning and going

Don't hesitate to ask questions! We love when you do. Did my post help?

If you need more help or if my answer didn't work, just ask!


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

Board footer