Making Dropped Object Collectible Score work with Extra Life Code

vanderblade

Active member
I'm using the 2-player platformer module.

I already have tiles that are collectible for score, and when players collect 10, they get an extra life.

I'm trying to apply this same logic to an object that drops after killing a monster.

I imagine I can take a version of the collectible tile code and apply the "extra life part" to the Increasescore object script.
Here's the tile code:

Collectible Script for Tiles

Code:
	JMP ++
isPlayerForCollectableScore:
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+
	LDA #$01
	STA tileCollisionFlag
	ChangeTileAtCollision #$00, #$00
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	TXA
	STA tempx	

	AddValue #$03, myScore, #$01, #$00
	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	PlaySound #SND_GET
	
	
	;; extra life stuff:
    LDA myScore	;; checking the current unit digit of the score is "0" (it means 10, 20, ... 90)?
    BNE +		;; if not "0" we skip
    AddValue #$02, myLives, #$01, #$00 
    ;; update the count in hud
    UpdateHud HUD_myLives

    ;; play 1UP sound:
    PlaySound #SND_GET	; (add a new "SND_1UP" sfx)
	+


    LDX tempx
	++

Script for Increase Score for score object:

Code:
;;; Increase Score
;;; works with variable myScore
;;; works with HUD variable HUD_myScore.
	TXA
	STA tempx
	
	AddValue #$08, myScore, #$01, #$00
	
	

	;;; we also need to set up the routine to update the HUD
	;; for this to work right, health must be a "blank-then-draw" type element.
	;STA hudElementTilesToLoad
	;	LDA #$00
	;	STA hudElementTilesMax
		; LDA DrawHudBytes
		; ora #HUD_myScore
		; STA DrawHudBytes
	UpdateHud HUD_myScore
	
	PlaySound #SND_CART
	LDX tempx

I tried copying and pasting the section on "extra life stuff" from the first script but am so far getting an error on this line:

"BNE + ;; if not "0" we skip"

Says it's out of range. What's a fix on this?
 

dale_coop

Moderator
Staff member
You need to add the whole, code:

Code:
	;; extra life stuff:
    LDA myScore	;; checking the current unit digit of the score is "0" (it means 10, 20, ... 90)?
    BNE +		;; if not "0" we skip
    AddValue #$02, myLives, #$01, #$00 
    ;; update the count in hud
    UpdateHud HUD_myLives

    ;; play 1UP sound:
    PlaySound #SND_GET	; (add a new "SND_1UP" sfx)
    +

WITH the "+", else the code can't branch out to that label.
 

vanderblade

Active member
Doh. After this project wraps, I'm going to sit down and actually learn the basics of asm scripting for the nes. Thanks, Dale.
 
Top Bottom