I posted a question for archmage, but I am curious if someone else has worked out the math for this...
http://scratch.mit.edu/projects/archmage/72848
Let's say you have 2 cat sprites, how would you modify the script to make the cats bounce off each other as if they are solid?
Nothing I try works out the way it should.
Offline
alrighty well then we can have several methods for this
-the first is simple and can just seem stupid at sometimes, but here goes...
[forever]
[if <touching [cat sprite2]>]
[point in direction (direction) - (180)]
-since the cat is outlined with black we can use that a base for color detection, this technique could be done in two ways, but I am demonstrating the form that allows you to control the areas that turn that cat if the cat isn't completely covered in the detection color
[forever]
[if <color [chosen detection color] is touching [black]>]
[point in direction (direction) - (180)]
-I could go on for days showing different techniques, but most are obsolete, these two are the easiest and best, you can change the turning amount in various ways, some can be more complex so you can create realistic pyshics
Offline
Here, if this is what you meant http://scratch.mit.edu/projects/keroro645/510107
Offline
keroro645 wrote:
Here, if this is what you meant http://scratch.mit.edu/projects/keroro645/510107
Not bad, but you have removed too much of the script. I still want to have jumping. And, the cat is moving way too slow.
Last edited by BoltBait (2009-05-01 18:39:25)
Offline
dingdong wrote:
alrighty well then we can have several methods for this
-the first is simple and can just seem stupid at sometimes, but here goes...
[forever]
[if <touching [cat sprite2]>]
[point in direction (direction) - (180)]
-since the cat is outlined with black we can use that a base for color detection, this technique could be done in two ways, but I am demonstrating the form that allows you to control the areas that turn that cat if the cat isn't completely covered in the detection color
[forever]
[if <color [chosen detection color] is touching [black]>]
[point in direction (direction) - (180)]
-I could go on for days showing different techniques, but most are obsolete, these two are the easiest and best, you can change the turning amount in various ways, some can be more complex so you can create realistic pyshics
This was the first thing I tried but it doesn't really work. There are cases where the sprites just start flipping out... left/right/left/right/left/right really fast.
Last edited by BoltBait (2009-05-01 18:42:59)
Offline
BoltBait wrote:
keroro645 wrote:
Here, if this is what you meant http://scratch.mit.edu/projects/keroro645/510107
Not bad, but you have removed too much of the script. I still want to have jumping. And, the cat is moving way too slow.
Ok I'll add some more to it.
Offline
I'd totally forgotten about this post I'd made here:
http://scratch.mit.edu/forums/viewtopic.php?id=5326&p=3
I bet I can get this to work in that scenario...
Both sprites should point away from each other and move until they no longer touch.
Last edited by BoltBait (2009-05-01 20:11:49)
Offline
yeah i tried to do that too it would be great for games and i bet you are looking for a way that uses the least sripcts right?
Offline
One of Paddle2See's projects might help you out: (http://scratch.mit.edu/projects/Paddle2See/446524). Admittedly, the movements are not too entirely accurate, but maybe you can utilize the code as a way to figure out your dilemma.

Offline
I developed a project some time ago to do exactly what you are trying (for ball-shaped sprites):
http://scratch.mit.edu/projects/s_federici/155861
The author of the script is Colkadome. Let me know how this works for you.
Offline
This seems kinda difficult to do in scratch
Usually when programming these kinds of thing I refer to newgrounds
http://www.newgrounds.com/bbs/topic/398295
That is a topic explaining how to bounce off of uneven surfaces such as sprites. Unfortunately it uses Atan2 which scratch doesn't have.
If you don't really care for accuracy you could make the sprite point to your other sprite then move away from it.
Offline
Well, I got it to work. It's not perfect, but very servicable...
http://scratch.mit.edu/projects/BoltBait/513961
I chose to use the
<point towards( other sprite )>
<turn cw( 180 )degrees>
because the sprite is probably pointing toward the other sprite anyway, so this was less complicated than using the math method.
Offline