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:
_npccollide:
REM Use this to check for collisions with sprites
IF (SPRITE COLLISION(player_sprite, npc1_sprite))
IF SPRITE Y(npc1_sprite) <= SPRITE Y(player_sprite) THEN upcol = 2
IF SPRITE Y(npc1_sprite) >= SPRITE Y(player_sprite) THEN downcol = 2
IF SPRITE X(npc1_sprite) <= SPRITE X(player_sprite) THEN leftcol = 2
IF SPRITE X(npc1_sprite) >= SPRITE X(player_sprite) THEN rightcol = 2
ENDIF
IF chest1 = 1
IF (SPRITE COLLISION(player_sprite, chest1_sprite))
IF SPRITE Y(chest1_sprite) <= SPRITE Y(player_sprite) THEN upcol = 2
IF SPRITE Y(chest1_sprite) >= SPRITE Y(player_sprite) THEN downcol = 2
IF SPRITE X(chest1_sprite) <= SPRITE X(player_sprite) THEN leftcol = 2
IF SPRITE X(chest1_sprite) >= SPRITE X(player_sprite) THEN rightcol = 2
ENDIF
ENDIF
Return
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.