Extra life every 100 points?

PewkoGames

Member
So I'm currently refining my Tomb Gator game.

Dale Coop helped me with some code that every 100 points, you get an extra life and it resets to 0.

However, I'd like it to not reset the score and rather have the traditional "high score" that you'd normally see.

Any ideas on how this can be achieved?
 

Dirk

Member
I don't know how your solution looks, but you could make a second invisible counter that gets reset every 100 points and simply not reset your score.
 

dale_coop

Moderator
Staff member
Dirk is right, if you still have a hud variable available, it could be an easy way to do it.
 

dale_coop

Moderator
Staff member
For eample, if you name a new hud varaible "myTokens"... modify the script that deals with your tokens collecting (scoring)...
And where in script you have:
Code:
	AddValue #$08, myScore, #$01, #$00
Change it for something like :
Code:
	AddValue #$08, myScore, #$01, #$00
		AddValue #$08, myTokens, #$01, #$00
(to also increments your tokens count... at the same time than your score)

Then some lines below (sill in the script) inside the bloc of code checking the myScore value to gain a life... replace the every "myScore" by "myTokens".

Now, your score should not reset... and each time you collect 100 tokens, you have +1 life.
 

Jonny

Active member
I saw the title for this topic and thought YES! thats exactly what I want to do. Then realised Dales code you mention above isn't here and I couldn't find it in search either.
Was it on facebook? Discord?

Anyway, instead of asking for the code I decided to not be lazy and try to figure it out for myself. I'll leave the code here incase someone else is searching for this too.

This is what I came up with and it works (for my game anyway). I only have 3 digits and am increasing by 5 for Diamond pickups. When score gets to 100, it resets and gives the player some health. Is this similar to the code you used for yours ??
Code:
;;; CHECK FOR PICKUPS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    LDA Object_type,x                 ;; COMPARE TO THIS  ;;
    
;;; DIAMOND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
    
    CMP #$07                          ;; DIAMOND OBJECT ? ;;
    BNE +notDiamond                   ;; NOT DIAMOND >    ;;
    AddValue #$03, myScore, #$05, #$00;; ADD 5 TO SCORE   ;;
    LDA myScore+2                     ;; LOAD SCORE       ;;
    CMP #1                            ;; COMPARE WITH 100 ;;
    BNE +dontResetScore               ;; NOT 100 >        ;;
    LDA #0                            ;; RESET SCORE TO 0 ;;
    STA myScore+2                     ;; RESET SCORE TO 0 ;;
    JMP +healthStuff                  ;; ADD TO HEALTH    ;;
+dontResetScore                       ;; NOT 100 YET      ;;
    JMP +endPickups                   ;; PICKUPS DONE     ;;
+notDiamond                           ;; NOT DIAMOND NEXT ;;

;;; HEALTH ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    CMP #$03                          ;; HEALTH PICKUP ?  ;;
    BNE +notHealth                    ;; NOT HEALTH       ;;   
+healthStuff                          ;; DO HEALTH THING  ;;
    INC myHealth                      ;; INCREASE BY 1    ;;
    LDA myHealth                      ;; LOAD HEALTH      ;;
    CMP #$04                          ;; COMPARE TO MAX   ;;
    BNE +dontNormalize                ;; NOT OVER 3       ;;
    LDA #$03                          ;; NORMALIZE        ;;
    STA myHealth                      ;; STORE AS 3 (MAX) ;;
+dontNormalize                        ;; DONT NORMALIZE   ;;
    JMP +endPickups                   ;; PICKUPS DONE     ;;
+notHealth                            ;; NOT HEALTH NEXT  ;;

;;; FINISHED WITH ALL PICKUPS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+endPickups
 
Top Bottom