Problems with default health powerup

Post Reply
Posts: 1
Joined: Fri Feb 14, 2020 4:13 pm

Problems with default health powerup

Post by timmythetrtl » Fri Feb 14, 2020 4:26 pm

I'm currently trying to get more familiar with the program, and right now I'm working with the 20 minute adventure tutorial. I tried using the Powerup_IncreaseHealth script that is found in Basic\ModuleScripts\PowerUpCode in order to create a health pickup, and for the most part it works, however when I'm at full health it reverts my health back to 1.

I tried messing with the script and found that the code that is supposed to skip process that increases health only works with values less then 5 (my max health for my game). I've also tried decreasing max health to 4, but it didn't solve anything.

Has anyone else had these issues?
User avatar
Posts: 78
Joined: Sun Jul 07, 2019 2:28 pm
Location: Norge

Re: Problems with default health powerup

Post by baardbi » Sat Feb 15, 2020 1:14 pm

Yes. I had this issue as well. I had to modify the default script. Since it adds 1 before it checks max value, I changed it to check the max value (8 in my case) before it does anything else. So if the health in my game is already maxed out (8), I skip the increase health code.

My script looks like this:

Code: Select all

;;; Increase Health code for player.
;;; works with variable myHealth
;;; works with HUD variable HUD_myHealth.
    LDA myHealth
    CMP #$08 ;<----- Compares to max health value
    BEQ skipGettingHealth

    ADC #$01
    STA tempx
    ;;;you may want to test against a MAX HEALTH.
    ;;; this could be a static number in which case you could just check against that number
    ;;; or it could be a variable you set up which may change as you go through the game.
    INC myHealth
    LDA myHealth
    LDX player1_object
    STA Object_health,x

    ;;; 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_myHealth
        ; STA DrawHudBytes
    UpdateHud HUD_myHealth
    LDX tempx
User avatar
Posts: 17
Joined: Wed Apr 24, 2019 4:48 pm

Re: Problems with default health powerup

Post by NeoBenj » Sat Feb 15, 2020 8:16 pm

Hey there,

Also compare the value baardi refered to, with the value you entered in the HUD section of the engine. (HUDElements => Max Value)
Post Reply