Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Collision on my 2 Dimension game
- xenlande
-
Scratcher
9 posts
Collision on my 2 Dimension game
Hi ! I have a problem, I have a map for my game and there is some walls on it, how can i do collisions with my wall ? thx and sorry for my bad english !
- EDawg2011
-
Scratcher
1000+ posts
Collision on my 2 Dimension game
1. This belongs in Help with Scripts. 
2. Can you please share the project and give us the link so that we can help better?
3. Here's a basic (and bad) one.
Here's a better one.
Here's an even better collision system. (Scroll to the right in the editor a bit in the “Player” sprite.)

2. Can you please share the project and give us the link so that we can help better?

3. Here's a basic (and bad) one.

move (10) steps
if <touching [Map v] ?> then
move (-10) steps
end
Here's a better one.

move (10) steps
Collision :: custom // This needs to be run without screen refresh.
define Collision
repeat until <not <touching [Map v] ?>>
move (-1) steps
end
Here's an even better collision system. (Scroll to the right in the editor a bit in the “Player” sprite.)

Last edited by EDawg2011 (Feb. 4, 2024 21:56:17)
- xenlande
-
Scratcher
9 posts
Collision on my 2 Dimension game
Hi again, I've done it and it's on the link below. It's just a rough draft and at least 95% of the game is missing, but it'll help you understand the concept. It's a 2 player game, players can't cross to the other side of the screen, can't walk on the water (so I'd like there to be collisions with the water, just that for now) which is on the second map (if you go left). In short, I've only mentioned a small part of the game so far, but in any case it's going to be my most ambitious game yet. I'm going to bed, I won't be able to answer until tomorrow unless you ask me some questions now ^^. cya
https://scratch.mit.edu/projects/961173809/
https://scratch.mit.edu/projects/961173809/
- EDawg2011
-
Scratcher
1000+ posts
Collision on my 2 Dimension game
You could switch the costume to a rectangular hitbox and check collisions from there, then you switch the costume back. 

hitbox (plural hitboxes) (computer graphics) An invisible shape bounding all or part of a model (in a video game, etc.) used in collision detection to determine whether another object collides with the model.
- xenlande
-
Scratcher
9 posts
Collision on my 2 Dimension game
yes, but I know how to do that the question is more how to make it prevent my character from moving in a certain direction. if you have time and if you accept it could you either send me a message to explain or make a remix that I will analyze pls?
- EDawg2011
-
Scratcher
1000+ posts
Collision on my 2 Dimension game
yes, but I know how to do that the question is more how to make it prevent my character from moving in a certain direction. if you have time and if you accept it could you either send me a message to explain or make a remix that I will analyze pls?idk if this fits your needs.
3. Here's a basic (and bad) one.move (10) steps
if <touching [Map v] ?> then
move (-10) steps
end
Here's a better one.move (10) steps
Collision :: custom // This needs to be run without screen refresh.define Collision
repeat until <not <touching [Map v] ?>>
move (-1) steps
end
Here's an even better collision system. (Scroll to the right in the editor a bit in the “Player” sprite.)
- Discussion Forums
- » Help with Scripts
-
» Collision on my 2 Dimension game

