Discuss Scratch

SuperWolf64
Scratcher
100+ posts

Collision detections; HOW??

Is there a way to make collision detection? I've attempted and the following is what happens:
1. Normally it works fine.Touching the color sends the plays back a little.
2. But if you go up to a wall, press L and R, you get sent through the wall like in the Super Mario Bros. Minus World glitch.
Since the game I'm making is a maze game, this easily allows cheating…

I've seen how to make collision in side-scrollers, but my game don't fit that category. In this game, when your reach a certain point, the level cycles in that direction, like in Nintendo's Metroid games. If you go to my game, then it'll show you the problem.
Click here to go to my game!

If you can find a solution, then help!
drmcw
Scratcher
1000+ posts

Collision detections; HOW??

The game doesn't work at all. Collision detection is no different to any other, in fact should be the easiest type as there is no jumping or gravity to worry about.
Sssspppuud
Scratcher
20 posts

Collision detections; HOW??

Does anyone know how I could stop my sprite (square) getting stuck in the platforms!

https://scratch.mit.edu/projects/104278034/
Paddle2See
Scratch Team
1000+ posts

Collision detections; HOW??

Sssspppuud wrote:

Does anyone know how I could stop my sprite (square) getting stuck in the platforms!

https://scratch.mit.edu/projects/104278034/
It's best to make your own topic for your own issues. Look for the “New topic” button at the top of the “Help With Scripts” section
Starblox77
Scratcher
8 posts

Collision detections; HOW??

The best way to detect a collision between two sprites is to have speed variables attached to each sprite, for example
ifBlueCarSpeed>20andRedCarSpeed>20andtouchingRedCar?thendostuff

This is from the point of view of the Blue Car.

Last edited by Starblox77 (May 11, 2016 22:38:55)

SuperWolf64
Scratcher
100+ posts

Collision detections; HOW??

Starblox77 wrote:

The best way to detect a collision between two sprites is to have speed variables attached to each sprite, for example
ifBlueCarSpeed>20andRedCarSpeed>20andtouchingRedCar?thendostuff

This is from the point of view of the Blue Car.
It's not the detecting i'm having trouble with, it's what happens when the collision is detected. Nice idea, though.
SuperWolf64
Scratcher
100+ posts

Collision detections; HOW??

SuperWolf64 wrote:

Is there a way to make collision detection? I've attempted and the following is what happens:
1. Normally it works fine.Touching the color sends the plays back a little.
2. But if you go up to a wall, press L and R, you get sent through the wall like in the Super Mario Bros. Minus World glitch.
Since the game I'm making is a maze game, this easily allows cheating…

I've seen how to make collision in side-scrollers, but my game don't fit that category. In this game, when your reach a certain point, the level cycles in that direction, like in Nintendo's Metroid games. If you go to my game, then it'll show you the problem.
Click here to go to my game!

If you can find a solution, then help!
Well, my game is more along the lines of Legend of Zelda in screen scrolling/collision terms.
_Cookinator924_
Scratcher
1 post

Collision detections; HOW??

Okay, so I think I know what you are saying, but forgive me if this doesn't help you at all.

You probably have a code like “Forever: If right arrow pressed then move right, if left arrow pressed then move left, etc. Well, to make your character not pass through walls, you should add a piece of code after each ”move“ block: If touching wall then move negative the distance you moved first. For example, if you change x by three each time the right arrow key is pressed, then the sprite touches a wall, it should change x by -3. Remember to keep that code in the ”if right arrow key pressed". This gives it smooth movement against walls and happens so fast nobody will notice it. I hope this helps (because I'm horrible at explaining things), and you can always reply if you still don't understand.
-XPT-
Scratcher
4 posts

Collision detections; HOW??

_Cookinator924_ wrote:

Okay, so I think I know what you are saying, but forgive me if this doesn't help you at all.

You probably have a code like “Forever: If right arrow pressed then move right, if left arrow pressed then move left, etc. Well, to make your character not pass through walls, you should add a piece of code after each ”move“ block: If touching wall then move negative the distance you moved first. For example, if you change x by three each time the right arrow key is pressed, then the sprite touches a wall, it should change x by -3. Remember to keep that code in the ”if right arrow key pressed". This gives it smooth movement against walls and happens so fast nobody will notice it. I hope this helps (because I'm horrible at explaining things), and you can always reply if you still don't understand.

Another simple way you could do this is with something like this:
whenWkeypressedrepeatuntilnotkeyWpressed?ifnottouchingSprite?thenchangeyby10

Hope this helps

Last edited by -XPT- (May 13, 2016 02:44:39)

Starblox77
Scratcher
8 posts

Collision detections; HOW??

iftouchingCar?thenblarpbloop
SuperWolf64
Scratcher
100+ posts

Collision detections; HOW??

_Cookinator924_ wrote:

Okay, so I think I know what you are saying, but forgive me if this doesn't help you at all.

You probably have a code like “Forever: If right arrow pressed then move right, if left arrow pressed then move left, etc. Well, to make your character not pass through walls, you should add a piece of code after each ”move“ block: If touching wall then move negative the distance you moved first. For example, if you change x by three each time the right arrow key is pressed, then the sprite touches a wall, it should change x by -3. Remember to keep that code in the ”if right arrow key pressed". This gives it smooth movement against walls and happens so fast nobody will notice it. I hope this helps (because I'm horrible at explaining things), and you can always reply if you still don't understand.
Okay, I'll try this

Last edited by SuperWolf64 (May 14, 2016 19:46:32)

SuperWolf64
Scratcher
100+ posts

Collision detections; HOW??

SuperWolf64 wrote:

_Cookinator924_ wrote:

Okay, so I think I know what you are saying, but forgive me if this doesn't help you at all.

You probably have a code like “Forever: If right arrow pressed then move right, if left arrow pressed then move left, etc. Well, to make your character not pass through walls, you should add a piece of code after each ”move“ block: If touching wall then move negative the distance you moved first. For example, if you change x by three each time the right arrow key is pressed, then the sprite touches a wall, it should change x by -3. Remember to keep that code in the ”if right arrow key pressed". This gives it smooth movement against walls and happens so fast nobody will notice it. I hope this helps (because I'm horrible at explaining things), and you can always reply if you still don't understand.
Okay, I'll try this
It works! It sticks a little sometimes, but rarely. Thanks

Powered by DjangoBB