[4.5.6] Warp Tile with Conditions

offparkway

Active member
I'm trying to create a new tile type (warp) that will only work if health = 8 (or more... not sure how to do "more").

So if you have 8 health, and touch the warp tile, you'll advance to the next level.

(03 is my health object)

My code compiles and runs, but has no effect. Can't figure out what I'm missing. Here it is:

Code:
	CPX player1_object
	BNE notForWarpTile
	
LDA Object_type,x
CMP #$03
	BNE notForWarpTile
LDA myHealth
CMP #08
	BNE notForWarpTile 

WarpToScreen #01, #10, #$01
		;; arg0 = warp to map.  0= map1.  1= map2.
		;; arg1 = screen to warp to.
		;; arg2 = screen transition type - most likely use 1 here.
			;; 1 = warp, where it observes the warp in position for the player.


notForWarpTile:
 

CutterCross

Active member
Why are you checking if the object type is a health object? The tile script already checks if the object overlapping it is the player. And anything that isn't the player object is just going to branch right to the end of the script.

If it is the player object, it's also not going to be Object Type #$03. The object type for the player object will always be #$00. So right after it successfully checks the player, it's always going to branch to the end of the script and the check for myHealth will never occur.
 

offparkway

Active member
I JUST figured that out and came to change my post, lol. It warps now if my health = 8. I was overthinking the process.

Follow up question: what if the player has 9 health? or 10? or 15? it won't equal 8... is there a good way to include this to make the tile still warp once health = 8 or higher?
 

CutterCross

Active member
offparkway said:
I JUST figured that out and came to change my post, lol. It warps now if my health = 8. I was overthinking the process.

Follow up question: what if the player has 9 health? or 10? or 15? it won't equal 8... is there a good way to include this to make the tile still warp once health = 8 or higher?

BCS or BCC.

BCS = Branch if Carry Set. Basically it means to branch if greater than or equal to.

BCC = Branch if Carry Clear. Basically branch if less than.
 
Top Bottom