Discuss Scratch

ItBeJC
Scratcher
1000+ posts

Slow Position Updates in Platformer

I'm making a scrolling platformer here- https://scratch.mit.edu/projects/1009216044
My first try with slope physics I made them work, but I encountered a new problem when incorporating another new feature for the first time: zooming. I thought the concept was simple, just multiply the coordinates by the zoom (Ex: 200 zoom = multiply coordinates by 2).

But when you look in the project you'll see that when the zoom variable (slider) is below 100, I find 40-50 to be suitable to find the glitch, you can see the player moving out of the ground. I'm not sure why this happens, because when the zoom variable is 100+ the collisions work perfectly.

I have a feeling that the slope detection may be part of the problem, but I'm not sure…its been a while since I made a platformer. I'd appreciate help asap, as this must be done by Friday and I still have a lot to do.

EDIT: Since I'm on a deadline, I've started to build my game around the bug, but I would really like it if somebody could help me fix the original bug.

Although all of the blocks are pretty self-explanatory, I put all of their functions below:

define Position: Costume (Costume)
This block appears in both the player and level sprite. All it does is position the sprite where its supposed to be with the correct costume. It multiplies the current coordinates by (zoom * 0.01) which is equivalent to (zoom / 100). So if zoom is 200, the coordinates will be multiplied by 2.
define Change x by (value)
Changes the PX variable & the x position of the sprite in the motion category. Made because I was too lazy to keep copy and pasting the code.
define Change y by (value)
Changes the PY variable & the y position of the sprite in the motion category. Made because I was too lazy to keep copy and pasting the code.
define Tick;
This custom block has a lot of custom inputs, but I didn't feel like copying it all into the forums. It runs 1 game tick for the player sprite, handling movement, collisions, and positioning/costume setting.
define No Clip X
Was originally part of the Tick custom block, but I made it a separate custom block that runs without screen refresh to try and fix the problem I'm having.
define No Clip Y
Was originally part of the Tick custom block, but I made it a separate custom block that runs without screen refresh to try and fix the problem I'm having.

Last edited by ItBeJC (April 30, 2024 01:35:16)


Game Is Game.

My King Message:
King like Kendrick, Drake took the L;hotline bling I'm like Rod Wave cuz I sing but I'm black yea we got a brotha as a king I needa queen like elizabeth can't be broke or else I might choke yea I'm with the times I'm woke yea I speak and I spoke I'm Light Yagami cuz' I write a note yea my life is an anime, spiderman and aunt may, this ain't no game no I do not play yea like the mando this is the way and I could freestyle like this all day cuz i got that crown and this golden ring cuz I'm king. –>–>–>–>–>–>–>–>–>–>–>–>–> {Shift + Down Arrow To See The Gang}

Da Gang: (There's no order, just a list so don't take any offense)
@OneTapTK
@kanomaster
@Mrhaxalot123
@depresso-boiyo
@-YourLocalPhantom
@TheGl1tchedDrag0n
@-GaIaxy_cat- (spelled with capitol i and not a lowercase L)
@glitcX
@MistaLOD
@TeslaDummy
@-cloudcoding-
@kinosaurs515
@semisupervised
@-The_Destroyer-
@iiucandyfloss
@xxxxxxx-70
@just-a-hriday
tank401
Scratcher
61 posts

Slow Position Updates in Platformer

It probably has something to with the multiplying the relative coordinates of sprites in the game vs multiplying the absolute coordinates on the screen. Try setting it so things at the center of your screen have another variable for cords and use that to zoom

Powered by DjangoBB