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

#1 2010-12-09 12:56:06

rep353
Scratcher
Registered: 2010-03-22
Posts: 40

How to make set coordinates

I have a car that I want to make 2 separate wheels for. The wheels hae to be separate for adding code onto. Is there any way so that the car will stay in the same distance from the wheels at all times?

I know that there is a centre point on the car but maybe it is possible to add more points onto the car???

Offline

 

#2 2010-12-09 13:07:15

ob6160
Scratcher
Registered: 2010-10-10
Posts: 500+

Re: How to make set coordinates

First you need the following sprites : One car and two wheels

I solved the problem by using the following code:

Stage:
<when green flag clicked>
<forever if><key[ right ]pressed?>
<broadcast[ goright
<end>

Code for:  Wheel 1 , Wheel 2 and car :

<when I receive[ goright
<point in direction( 90 )
<move( 3 )steps>
<end>

This will make the car and wheels move at exactly the same speed all in the same direction. Now drag and drop the wheels into the right position and run your program.

Now all you need to do is do the same for going left (but just change the broadcast to goleft and  <point in direction( 90 ) to <point in direction( -90 ).

I hope this helps.

OB6160

__________________________

See ALL my projects at: http://scratch.mit.edu/users/ob6160
See my blog at: oliverspcpages.blogspot.com


http://i45.tinypic.com/2jcygsy.gif

Offline

 

#3 2010-12-09 13:08:52

ob6160
Scratcher
Registered: 2010-10-10
Posts: 500+

Re: How to make set coordinates

ob6160 wrote:

First you need the following sprites : One car and two wheels

I solved the problem by using the following code:

Stage:
<when green flag clicked>
<forever if><key[ right ]pressed?>
<broadcast[ goright
<end>

Code for:  Wheel 1 , Wheel 2 and car :

<when I receive[ goright
<point in direction( 90 )
<move( 3 )steps>
<end>

This will make the car and wheels move at exactly the same speed all in the same direction. Now drag and drop the wheels into the right position and run your program.

Now all you need to do is do the same for going left (but just change the broadcast to goleft and  <point in direction( 90 ) to <point in direction( -90 ).

I hope this helps.

OB6160

This was my first ever post on the forums  smile

Funnily enough I was awnsering exactly the save question  big_smile

Last edited by ob6160 (2010-12-09 13:09:07)


http://i45.tinypic.com/2jcygsy.gif

Offline

 

#4 2010-12-09 13:25:27

rep353
Scratcher
Registered: 2010-03-22
Posts: 40

Re: How to make set coordinates

That seems good but in the game im designing the wheels will probably have to calculate the angle for which the car should face (depending on hill).

Essentially from what I understand from your code is that you are telling all 3 pieces to go in the same direction and at the same speed. This sort of code could have unpredictable results perhaps??? I was looking for more of a way that the car would fix its position directly based on the position of the wheels.

Offline

 

#5 2010-12-09 20:03:23

Ratty1967UK
Scratcher
Registered: 2007-05-16
Posts: 88

Re: How to make set coordinates

I started making a version of the old arcade game "Moon Patrol" - Never finished it, but the buggy and the three wheels are separate sprites - the wheels follow the rough terrain and the buggy itself rocks as the wheels move up and down.

Check out the parallax scrolling too  big_smile

http://scratch.mit.edu/projects/Ratty1967UK/1469982

one day I may even finish the game!  smile

Last edited by Ratty1967UK (2010-12-09 20:05:28)

Offline

 

Board footer