Sprite HUD score.

PewkoGames

Member
Anyone know how to make the sprite hud in the scrolling platformer keep a score like in the arcade platformer ? I think that would be a helpful tutorial.
 

CutterCross

Active member
Look at doDrawSpriteHud_L2RPlatformer_prizeValues.asm in the MOD_PlatformerBase folder. A counter-based sprite HUD like that is actually pretty straightforward given that the numbers in your GameObjects tileset are contiguous. Doesn't even really need a macro.
Code:
;;; Here, we are going to draw a sprite, followed by a little x, followed by numbers representing a quasi-score value.
;;; We are doing this all with sprites so that it can follow our hud more easily. 
;;; To do this, our game object tileset has numbers, 0-9, located at 40-49, and 4A represents the X.
;;; The identifier for the type of thing we're drawing is at 22.

    DrawSprite #16, #26, #$22, #%00000001 ;; draws the "carrot"
    DrawSprite #24, #26, #$4a, #$00 ;; draws the x 8 pixels to the right of it.
    
    LDA myPrizes
    CLC
    ADC #$40
    ;; now we have the number 40 + how many prizes we have.
    ;; so the resulting graphic will be 0-9.
    STA temp
    DrawSprite #32, #26, temp, #$00
 

PewkoGames

Member
I'm confused.

I want my hud to show lives and 6 "0's" for the score instead of the lives increase counter. I have no idea how to do that. I'm not good with code at all.
 

dale_coop

Moderator
Staff member
Like CutterCross wrote you could use that kind of code, but for your Score variable...
You need to have your numbers in your GameObjectTiles.bmp

For example if 0 is the first tile of your last row... the code could look something like:
Code:
    TXA
    PHA
    LDA #$70    ;; horizontal Y position
    STA tempA
    LDA #$10    ;; horizontal X position
    STA tempB
    LDX #$06    ;; your myScore variable Bytes
    -:
        DEX
        LDA myScore,x
        CLC
        ADC #$70    ;; the tileID of the "0" in your tileset
        STA tempC
        DrawSprite tempA, tempB, tempC, #$00
        LDA tempA
        CLC
        ADC #$08
        STA tempA
    CPX #$01
    BCS -
    PLA
    TAX
 

PasseGaming

Active member
Mouse Spirit has put together a fantastic little I introduction to AMS in the community tutorial sections. I highly suggest checking it out. It'll give you a better understanding of what your looking at and how to go about making changes to better suit your needs or even eventually write your own simple code.
 

kevin81

Member
Also, as a side note, be aware of the sprite limitations. The NES can draw only 8 sprites per (horizontal) scanline. So, for example, you can't show three hearts for lives and six digits for score on the same hoizontal line in a sprite HUD.
 

PasseGaming

Active member
Also, as a side note, be aware of the sprite limitations. The NES can draw only 8 sprites per (horizontal) scanline. So, for example, you can't show three hearts for lives and six digits for score on the same hoizontal line in a sprite HUD.
Did the Legend of Zelda use both sprites and background tiles for their hud?
 

PewkoGames

Member
Like CutterCross wrote you could use that kind of code, but for your Score variable...
You need to have your numbers in your GameObjectTiles.bmp

For example if 0 is the first tile of your last row... the code could look something like:
Code:
    TXA
    PHA
    LDA #$70    ;; horizontal Y position
    STA tempA
    LDA #$10    ;; horizontal X position
    STA tempB
    LDX #$06    ;; your myScore variable Bytes
    -:
        DEX
        LDA myScore,x
        CLC
        ADC #$70    ;; the tileID of the "0" in your tileset
        STA tempC
        DrawSprite tempA, tempB, tempC, #$00
        LDA tempA
        CLC
        ADC #$08
        STA tempA
    CPX #$01
    BCS -
    PLA
    TAX
I do have numbers in my game objects BMP. I'll give this a whirl. This code would go in my doDrawSpriteHud.asm? or do I make a new script?
 

kevin81

Member
Did the Legend of Zelda use both sprites and background tiles for their hud?

That's correct; the map indicator and the active B and A objects are sprites, everything else (including heart containers and coin, key and item counts) are background tiles.
 

Jonny

Active member
Like CutterCross wrote you could use that kind of code, but for your Score variable...
You need to have your numbers in your GameObjectTiles.bmp

For example if 0 is the first tile of your last row... the code could look something like:
Code:
    TXA
    PHA
    LDA #$70    ;; horizontal Y position
    STA tempA
    LDA #$10    ;; horizontal X position
    STA tempB
    LDX #$06    ;; your myScore variable Bytes
    -:
        DEX
        LDA myScore,x
        CLC
        ADC #$70    ;; the tileID of the "0" in your tileset
        STA tempC
        DrawSprite tempA, tempB, tempC, #$00
        LDA tempA
        CLC
        ADC #$08
        STA tempA
    CPX #$01
    BCS -
    PLA
    TAX

I just wanted to confirm something. Does this example update the last digit only? Or am I doing something wrong...?

I've created a variable 'myScore' with 3 bytes (I only want 3 digits), changed LDX #$06 to 3.

The code I put in pickups script is this...

Code:
;;; DIAMOND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
    
    CMP #$07
    BNE +notDiamond
    INC myScore
    LDA myScore
    STA myScore
    JMP +endPickups
+notDiamond:

A bit bamboozled at the moment! All 3 sprites draw but only the last one changes.
 
I just wanted to confirm something. Does this example update the last digit only? Or am I doing something wrong...?

I've created a variable 'myScore' with 3 bytes (I only want 3 digits), changed LDX #$06 to 3.

The code I put in pickups script is this...

Code:
;;; DIAMOND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
   
    CMP #$07
    BNE +notDiamond
    INC myScore
    LDA myScore
    STA myScore
    JMP +endPickups
+notDiamond:

A bit bamboozled at the moment! All 3 sprites draw but only the last one changes.
Numbers like that are hexadecimal by default. I'd watch the beginner maze tutorial where Joe talks about myScore to understand how to fix this.
 

Jonny

Active member
Numbers like that are hexadecimal by default. I'd watch the beginner maze tutorial where Joe talks about myScore to understand how to fix this.

I didn't literally mean I put a '3'. I should have said that I put #$03. Is that what you're referring to?
 

Jonny

Active member
Thanks again @TakuikaNinja
I only had to change 1 line of code in my pickups script to include AddValue instead of INC. It would have taken me a lot longer to figure out / over think if you hadn't ponted that out for me.
Code:
;;; CHECK FOR PICKUPS ;;;;;;;;;;;;;;;;

    LDA Object_type,x
  
;;; DIAMOND ;;;;;;;;;;;;;;;;;;;;;;;;;;
  
    CMP #$07
    BNE +notDiamond
    AddValue #$03, myScore, #$05, #$00
    LDA myScore
    STA myScore
    JMP +endPickups
+notDiamond

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

+endPickups
 
Top Bottom