[4.5.6] Make you unable to kill certain enemies

Hector Valle

New member
Hello Guys! I'm trying to implement "spike enemies" in my platform game, but obviously I can beat them if I jump on them because that's how it is set in the hurtPlayer_PlataformerBase.asm Try placing this little piece of code on top:

LDA Object_type, x
CMP #$12 (that's the number of my enemy)
BNE + skipDoingThis


Now what happens is that if I jump on any enemy, I die as if it were the enemy with spikes. Can someone help me fix this please?
 

Pauldalyjr

Active member
Take that added bit of code out, In your monster object settings put the monster life at 0. Not sure this is exactly what you are looking for, you'll have an invincible monster.
 
I think this is your answer :
BNE will branch out if not equal. so when you compare with object #$12, if it is any other object, it will branch out to +skipDoingThis. What you want is BEQ instead of BNE. It will branch out if equal. We compare with 12, it is equal, we skip the stuff. if it's not 12, we don't skip, we actually do the jump on stuff.

Code:
LDA Object_type, x
CMP #$12 (that's the number of my enemy)
BEQ + skipDoingThis
	;;here we do the stuff if it wasn't object #$12
+ skipDoingThis
 

TolerantX

Active member
I just make the enemies I don't want to kill into a different type.. primarily monster weapon and remove the destroy object from it in my collisions. it's a simple workaround.
 
Top Bottom