I can see my player respond to collision in real time, instead of it being instant

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
101Corp
Prole
Posts: 1
Joined: Tue Jan 02, 2024 10:07 pm

I can see my player respond to collision in real time, instead of it being instant

Post by 101Corp »

I can see my player respond to collision in real time, instead of it being instant. I don't want the player bouncing, I want the player to collide with the chunk and instantly move out to the top of it. I made a custom algorithm for detecting collision on images and it is what I use. How do I fix my issue? (game .love included in attachments)
Attachments
game.love
(21.44 KiB) Downloaded 172 times
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: I can see my player respond to collision in real time, instead of it being instant

Post by DaedalusYoung »

I'm guessing it's because you run the loop 8 times. It will check if mainY is on a non-zero alpha channel and it will move the playerY up 1 pixel. That doesn't change mainY in that loop, so as it runs 8 times, mainY doesn't change, but playerY moves up 8 pixels. On the next frame, it will move playerY down 1 pixel once, because that's before the loop. So for 8 frames or so, it will move the player down 1 pixel each frame, then when it hits the floor, it will move the player up 8 pixels and that's how it bounces.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 7 guests