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

#1 2012-05-25 12:47:48

scratchU8
Scratcher
Registered: 2009-09-08
Posts: 100+

Velocity collison

I'm helping a friend make a Marble game. You know, like that Marble Racer, only with a Super Monkey ball twist. Anyway, I was wondering how you could make collision to a color if the x and y velocity gets changed by 0.1 when arrow keys are pressed.

Offline

 

#2 2012-05-25 16:39:53

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Velocity collison

If all your angles are 90 degrees:

when gf clicked
set [x-vel v] to (0)
set [y-vel v] to (0)
forever
if<key [up arrow v] pressed?>
change [y-vel v] by (0.1)
end
if<key [down arrow v] pressed?>
change [y-vel v] by (-0.1)
end
if<key [right arrow v] pressed?>
change [x-vel v] by (0.1)
end
if<key [left arrow v] pressed?>
change [x-vel v] by (-0.1)
end
change x by (x-vel)
if<touching [color]?>
set [x-vel v] to ((-1)*(x-vel))
change x by (x-vel)
end
change y by (y-vel)
if<touching [color]?>
set [y-vel v] to ((-1)*(y-vel))
change y by (y-vel)
end


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-06-17 20:07:56

bballluke
Scratcher
Registered: 2012-06-17
Posts: 13

Re: Velocity collison

I'm the person he's helping, and not all my angles are 90 degrees.

Offline

 

#4 2012-06-19 10:33:39

pipercubjl
Scratcher
Registered: 2010-05-20
Posts: 73

Re: Velocity collison

On collision, make your velocity a negative, than move it. Than set it to 0.


http://scratch.mit.edu/static/projects/pipercubjl/2621398_med.png  http://scratch.mit.edu/static/projects/pipercubjl/2634368_med.png
        Crypt            Pixel Lands

Offline

 

#5 2012-06-20 12:52:50

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: Velocity collison

I made a project that should help you. Just read the notes and do as they say. It can be found here. Good luck with your project.

Offline

 

Board footer