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 Detection issue with sprites?

Author
Message
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 20th Sep 2011 20:40 Edited at: 20th Sep 2011 20:56
Hi all!

I've been working on a 2D RPG and thusfar it's been going rather well.

However, I have come to a bit of a stalemate: I currently have a player character, and an NPC on a map. I've been able to successfully detect collision with surrounding water sprites on the map layer and with the NPC. I have successfully come up with an event system for my game (if I press the space key next to my character, it starts a conversation with him which ends with him making a treasure chest appearing). Now, the problem I'm having is the treasure chest is not colliding with the character when he walks up to it. The sprites are at the same priority, so that shouldn't be an issue.

I put some text in my game to see what my collision variable values are. They are consistent when I walk into water or the NPC. But when I walk into the treasure chest sprite the variables remain at zero (which indicates nothing's been collided.

Here's the NPC/item collision code:



Any help would be greatly appreciated. I'm at a loss here with this, I've gone over my code at least three or four times trying to find where there could be a discrepancy and I'm coming to the conclusion that this may be an internal issue with how the underlying code under the commands is set up.

Thanks!

EDIT: In case you may be wondering, the variable "chest1" is being set when the player talks to the NPC, which in turn makes the chest appear on the screen as well, so it's not an issue with chest1 being not set either.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Sep 2011 21:21
Well the error isn't in that part. The chest might be going back to 0 after you show it.

Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 20th Sep 2011 21:29
Do you mean the chest1 variable? It's a steady 1 after it is switched that one time.

In fact, give me a minute and I'll put together an attachment with the code.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 20th Sep 2011 21:31
Attached is the code.
Da_Rhyno
15
Years of Service
User Offline
Joined: 25th May 2011
Location:
Posted: 20th Sep 2011 21:52
Alas! I figured it out. I already had that sprite set up as a map sprite... I feel stupid. >_< I need to organize stuff better. ^_^'

Thank you all!

Login to post a reply

Server time is: 2026-07-10 10:20:31
Your offset time is: 2026-07-10 10:20:31