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.

DarkBASIC Professional Discussion / Collision and stopping question

Author
Message
SlimPockets Joe
15
Years of Service
User Offline
Joined: 2nd Jan 2011
Location:
Posted: 2nd Jan 2011 10:39
so my friend and I have been learning DarkBASIC for literally almost a week straight. We decided to start working on small silly projects, to get some experience under our belts. We have code we're working on right now to get collision working, and we have the collision check working, but every time our stick man sprite gets close to the platform sprite, it stops, but refuses to move. That tells us the collision IS working, but we can't get the sprite to start moving again.

Now, I've tried writing some code to counter the whole stopping and not moving thing, but i'm becoming stumped. Here's our current code:

SlimPockets Joe
15
Years of Service
User Offline
Joined: 2nd Jan 2011
Location:
Posted: 2nd Jan 2011 14:03
I've actually solved my problem of being able to bounce off, but now my keys get all screwed up. When I collide with the platform, the sprite bounces off, but then my directions are reversed when I use the keys (up = down, left = right, etc etc)

So my question is now... with the code I've included below, how do I fix this problem?

Vax Tracker
20
Years of Service
User Offline
Joined: 24th Jul 2005
Location:
Posted: 3rd Jan 2011 14:43
Well your problem is you're negating th human.speed constant here:


This effectively reverses your controls until you collide again. One possible solution is to take your previous position before the collision and returning the sprite to that position if a collision is detected at the current coordinates.

Login to post a reply

Server time is: 2026-07-18 03:15:45
Your offset time is: 2026-07-18 03:15:45