Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / a problem with platform collision, 2D

Author
Message
Pepzi
13
Years of Service
User Offline
Joined: 22nd Feb 2011
Location:
Posted: 29th Oct 2011 13:27
Hi, it's me again. I would like to know how do I fix this problem with my platforms. As seen on this screenshot:

As I collide with the platform's X side(I call it that way), it goes like that, my character can walk and jump through it.

But when I land on it normally like this from its Y side(I call it that way)it goes fine:


My collision code is this..




I hope I'll be saved again!

New to darkbasic
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Oct 2011 14:35
You probably want to set the PlayerY value to the top of the platform sprite instead (PlayerY = sprite y(rock3(s)) if it's pivot point's Y offset is 0).
As you're doing it now you're just setting the player's position to itself, essentially accomplishing nothing :p


"Why do programmers get Halloween and Christmas mixed up?"
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Nov 2011 02:21 Edited at: 1st Nov 2011 02:22
I wrote up a quick platformer demo a while ago here (you'll need to scroll down a bit). I don't think it is well commented but hopefully it will be of some use.

Login to post a reply

Server time is: 2024-05-20 03:47:14
Your offset time is: 2024-05-20 03:47:14