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.
;;; 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
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
Did the Legend of Zelda use both sprites and background tiles for their hud?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.
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?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
Did the Legend of Zelda use both sprites and background tiles for their hud?
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
;;; DIAMOND ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CMP #$07
BNE +notDiamond
INC myScore
LDA myScore
STA myScore
JMP +endPickups
+notDiamond:
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 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.
Thank you for this, I'll look into that macro's arguments and try to figure it out how to use it.You need to use the AddValue macro to update the score digits properly.
;;; 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