Discuss Scratch

EAE_animator
Scratcher
52 posts

The Character freezes when touching the level

dem_bot
Scratcher
500+ posts

The Character freezes when touching the level

A part of the problem probably is that it doesn't take in account that the level moves after or before the collision checks, so changing scroll x and y only has an effect on the script the next frame.
HexxWizard
Scratcher
1 post

The Character freezes when touching the level

I know I'm being a weirdo, and I've been on Scratch for about 5 years now, but do you know how to create a new post/question through forums?
dem_bot
Scratcher
500+ posts

The Character freezes when touching the level

HexxWizard wrote:

I know I'm being a weirdo, and I've been on Scratch for about 5 years now, but do you know how to create a new post/question through forums?
If it's a HwS question, you can make a new topic with the big purple button top right somewhere in the menu where you can see the other topics.
If it's for a different forum, you should go to that forum's page where you can make a new topic the same way.
FLAMINFOX711
Scratcher
76 posts

The Character freezes when touching the level

https://scratch.mit.edu/projects/1279702446/ perhaps this can help? The code is simple, and if you have any other questions, just let me know
EAE_animator
Scratcher
52 posts

The Character freezes when touching the level

dem_bot wrote:

A part of the problem probably is that it doesn't take in account that the level moves after or before the collision checks, so changing scroll x and y only has an effect on the script the next frame.

So… is there a specific order that'd work?
FLAMINFOX711
Scratcher
76 posts

The Character freezes when touching the level

Basic steps
*Note: this is for a scrolling engine that is solely operated by the level*
1. Change the y scroll
2. Check if the level is touching the player
-if it is, then we have to move the player out of the level
3. Change the x scroll
4. Check if the level is touching the player (like if the player is in the wall)
-if it is, then move it out of the wall

This doesn’t really cover all the actual coding that would need to be done, but it’s just a general outline for collisions code
dem_bot
Scratcher
500+ posts

The Character freezes when touching the level

EAE_animator wrote:

dem_bot wrote:

A part of the problem probably is that it doesn't take in account that the level moves after or before the collision checks, so changing scroll x and y only has an effect on the script the next frame.

So… is there a specific order that'd work?
The best option is to use maths for collisions such as in my 2D map engine. This allows you to also have some visual effects such as making the camera smooth instead of the player locked in one place, is very reliable and often less laggy.
An easier, but often buggier option is for the player to not do the movement, but the level instead. As FLAMINFOX711 described.
A third option is to have the player sprite move during the frame (so when you change scroll x also change x) and move back after calculating the collisions, but that is prone to float roundoff error and requires some handling for when the player starts the frame in the ground.

Last edited by dem_bot (March 2, 2026 08:04:01)

CodeSprinter123
Scratcher
67 posts

The Character freezes when touching the level

define Try Move (X) (Y)
change x by (X)
if <touching [wall v] ?> then
change x by ((0) - (X))
end
change y by (Y)
if <touching [wall v] ?> then
change y by ((0) - (Y))
end
taggeditag
Scratcher
27 posts

The Character freezes when touching the level

https://scratch.mit.edu/projects/1285638430/

or try this:

https://scratch.mit.edu/projects/1251730435/



change x by (() - (speed_x))

Last edited by taggeditag (March 2, 2026 19:35:55)

EAE_animator
Scratcher
52 posts

The Character freezes when touching the level

dem_bot wrote:

EAE_animator wrote:

dem_bot wrote:

A part of the problem probably is that it doesn't take in account that the level moves after or before the collision checks, so changing scroll x and y only has an effect on the script the next frame.

So… is there a specific order that'd work?
The best option is to use maths for collisions such as in my 2D map engine. This allows you to also have some visual effects such as making the camera smooth instead of the player locked in one place, is very reliable and often less laggy.
An easier, but often buggier option is for the player to not do the movement, but the level instead. As FLAMINFOX711 described.
A third option is to have the player sprite move during the frame (so when you change scroll x also change x) and move back after calculating the collisions, but that is prone to float roundoff error and requires some handling for when the player starts the frame in the ground.

It would've been nice if I could understand it (T_T) My impatient brain can't process all that math

btw, since you know a lot more about scratch than me, i'd like to ask a question: is my engine even viable? or should i just give up and use other people's engines?

Powered by DjangoBB