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

#1 2011-05-04 10:57:28

Duning
New Scratcher
Registered: 2011-04-24
Posts: 6

How to bounce an object if it's touching other object

Now I'm doung a RPG game, and I want that the hero don't touch the houses an other thing, in photoshop I clear the walkable part to have the part that you cant walk trought.
I want to put at the if condition "Bounce"


thx

Offline

 

#2 2011-05-04 13:57:39

Duning
New Scratcher
Registered: 2011-04-24
Posts: 6

Re: How to bounce an object if it's touching other object

19 visits, no replay

Offline

 

#3 2011-05-05 11:31:22

Duning
New Scratcher
Registered: 2011-04-24
Posts: 6

Re: How to bounce an object if it's touching other object

33 visits, no replay

Offline

 

#4 2011-05-05 12:09:23

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: How to bounce an object if it's touching other object

Depends on what you mean by "bounce".  If you want to fake it a bit, you can just have the other sprite change direction by 180 degrees, maybe add in a little random variation just to keep it interesting.  It won't look very realistic at low angles but it might do the trick.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#5 2011-05-05 12:44:52

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: How to bounce an object if it's touching other object

If you mean that you don't want the player to run into walls, you can use sensing:

Have four sprites that follow the player, but are slightly above/below/left/right. Each one of them has to report back to the player whether they are touching a wall, and the player then decides whether to move in that direction or bounce off it.

Offline

 

#6 2011-05-05 13:03:14

Wman3
Scratcher
Registered: 2011-02-09
Posts: 86

Re: How to bounce an object if it's touching other object

I've got an idea on how to do that:
1) Drag on an "If Green Flag clicked" block and then you snap on a
"Forever" block.
2) Drag an "if" block into the forever block and then drag a "if touching color {}" block. Put the color of that sort of "object".
3) Then put on a "go to x: y:" block and snap on two "pick random from whatever to whatever" block. It's pretty straitforward from there. Good luck with the programming!  big_smile


http://i1241.photobucket.com/albums/gg513/Wman3/Wman3.png
Click the Image Above for my profile! // Penguin Town Collaboration Project!

Offline

 

#7 2011-05-06 10:33:30

Duning
New Scratcher
Registered: 2011-04-24
Posts: 6

Re: How to bounce an object if it's touching other object

ok thanks evrybody...
To myschool i'm doing a scratch projet in rpg, a game, and i dont want to walk in the walls, i can't use colors, becouse there are very diferents, i mean samething like this but less complicate,
http://scratch.mit.edu/projects/Duning/1767878

Offline

 

#8 2011-05-06 11:47:03

Wman3
Scratcher
Registered: 2011-02-09
Posts: 86

Re: How to bounce an object if it's touching other object

Duning wrote:

ok thanks evrybody...
To myschool i'm doing a scratch projet in rpg, a game, and i dont want to walk in the walls, i can't use colors, becouse there are very diferents, i mean samething like this but less complicate,
http://scratch.mit.edu/projects/Duning/1767878

Oh, ok. So you cant't use colors. hmm  Hmm... *light bulb* I got it! You just make the color in the script thing gray, or black or maybe even white if the backround is like black or something.

Last edited by Wman3 (2011-05-06 11:47:36)


http://i1241.photobucket.com/albums/gg513/Wman3/Wman3.png
Click the Image Above for my profile! // Penguin Town Collaboration Project!

Offline

 

#9 2011-05-06 18:12:52

Duning
New Scratcher
Registered: 2011-04-24
Posts: 6

Re: How to bounce an object if it's touching other object

ok, and with colors how do i should do it?

Offline

 

#10 2011-05-06 23:20:53

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How to bounce an object if it's touching other object

Duning wrote:

ok, and with colors how do i should do it?

There are multiple ways to go about it, some rather simple and some more complex. If you have flat, 90 degree walls and floors, you could make a sensor sprite to detect what type of wall (horizontal/vertical) that the player is touching, and react accordingly.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#11 2011-05-07 06:30:01

Duning
New Scratcher
Registered: 2011-04-24
Posts: 6

Re: How to bounce an object if it's touching other object

ok thanks everybody

Offline

 

#12 2011-05-07 07:58:53

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

Re: How to bounce an object if it's touching other object

Look at this script: here.

This uses only the sprite you're moving, no sensor sprites or sensor colors needed.


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

Offline

 

Board footer