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

#1 2012-03-31 20:46:18

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

how to make sprite bouncy?

Could someone help me get it so that the sprite will bounce off of solid walls and also bounce off the mouse pointer? No, I am not making a platformer, but I'm making a "bounce maze" where you bounce the bubble off the mouse pointer and the bubble pops when it's touching the wall. I want it to bounce off and have a sort of "gravity" so that it will fall to the ground unless you bounce it back up. Help would be appreciated  smile

Last edited by Mokat (2012-03-31 21:32:17)


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#2 2012-03-31 21:26:16

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: how to make sprite bouncy?

anyone?


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#3 2012-03-31 21:30:27

SilverDomination
Scratcher
Registered: 2011-11-23
Posts: 500+

Re: how to make sprite bouncy?

Mokat wrote:

Could someone help me get it so that the sprite will bounce off of solid walls and also bounce off the mouse pointer? No, I am not making a platformer, but I'm making a "bounce maze" where you bounce the bubble off the mouse pointer and the bubble pops when it's touching the wall. Help would be appreciated  smile

Try this for an example!

when gf clicked
forever if <touching [wall v]>
move [-5] steps


Sooner or Later. Or sooner. Not much, except for a lot. In a way. But it will come no matter what.

Offline

 

#4 2012-03-31 21:31:38

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: how to make sprite bouncy?

SilverDomination wrote:

Mokat wrote:

Could someone help me get it so that the sprite will bounce off of solid walls and also bounce off the mouse pointer? No, I am not making a platformer, but I'm making a "bounce maze" where you bounce the bubble off the mouse pointer and the bubble pops when it's touching the wall. Help would be appreciated  smile

Try this for an example!

when gf clicked
forever if <touching [wall v]>
move [-5] steps

What I'm needing help with is so that it bounces, but still has gravity and falls to the ground.


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#5 2012-03-31 22:36:41

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: how to make sprite bouncy?

 
when gf clicked
set [xv v] to (0)
set [yv v] to (0)
forever
 if <key [right arrow v] pressed?>
  change [xv v] by (1)
 end
 if <key [left arrow v] pressed?>
  change [xv v] by (-1)
 end
 if <touching [wall v]?>
  set [xv v] to ((xv) * (-1))
 end
 set [xv v] to ((xv) * (0.87))
And do the same with yv except put a:
change [yv v] by (-1)
in the forever loop.

Last edited by chanmanpartyman (2012-03-31 22:37:44)

Offline

 

#6 2012-04-01 19:52:30

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: how to make sprite bouncy?

chanmanpartyman wrote:

 
when gf clicked
set [xv v] to (0)
set [yv v] to (0)
forever
 if <key [right arrow v] pressed?>
  change [xv v] by (1)
 end
 if <key [left arrow v] pressed?>
  change [xv v] by (-1)
 end
 if <touching [wall v]?>
  set [xv v] to ((xv) * (-1))
 end
 set [xv v] to ((xv) * (0.87))
And do the same with yv except put a:
change [yv v] by (-1)
in the forever loop.

But it's not moving!


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#7 2012-04-01 20:04:40

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

Re: how to make sprite bouncy?

Mokat wrote:

But it's not moving!

Stick this in the x-script:

change x by (xv)
and this in the y-script:
change y by (yv)
Additionally, I find it better to put both the x and y velocity script in the same loop, but if this works for you, great!


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

Offline

 

#8 2012-04-01 20:58:13

Mokat_Test
Scratcher
Registered: 2012-04-01
Posts: 16

Re: how to make sprite bouncy?

That worked! Thanks  big_smile 
(p.s. This is me from my test account)


i dont know what to put here

Offline

 

#9 2012-04-01 21:00:25

AgentRoop
Scratcher
Registered: 2012-02-11
Posts: 1000+

Re: how to make sprite bouncy?

MoreGamesNow wrote:

Mokat wrote:

But it's not moving!

Stick this in the x-script:

change x by (xv)
and this in the y-script:
change y by (yv)
Additionally, I find it better to put both the x and y velocity script in the same loop, but if this works for you, great!

and of course, you have to put both of those scripts in a forever sign.  wink
like this:

when gf clicked
forever 
  change y by (yv)
  change x by (xv)
[/scratchblocks

Last edited by AgentRoop (2012-04-01 21:00:52)


La La
I wrote an album.

Offline

 

#10 2012-04-01 21:03:34

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: how to make sprite bouncy?

Mokat_Test wrote:

That worked! Thanks  big_smile 
(p.s. This is me from my test account)

tongue  Hi me! xD


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

Board footer