baardbi
Well-known member
If you want to have a score in your sprite HUD then there are a few steps we need to do before it can be displayed.
1. Create the following User Variables (make sure you create them in this order):
score000001
score000010
score000100
score001000
score010000
score100000
This will give you a score that can have a max value of 999999. Technically you can have two more values, but then you use all the sprite slots for that scan line, so if any sprite is on the same scan line they will disappear.
2. Copy these tiles from the HUD graphics (in the tutorial graphics folder), or make your own number graphics. Make sure the numbers are the first tiles in your GameObjectTiles.bmp file.
3. Put this code in your doDrawSpriteHud file:
%00000000: Sprite palette 0
%00000001: Sprite palette 1
%00000010: Sprite palette 2
%00000011: Sprite palette 3
4. Now your score will be displayed in the sprite HUD. To add a value to the score just use the AddValue macro:
AddValue arg0, arg1, arg2, arg3
;arg0 = how many places this value has.
;arg1 = home variable
;arg2 = amount to add
;arg3 = what place value is receiving the addition?
;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
This can be a little tricky at first, but here's an example of adding 100 to the score:
AddValue #6, score000001, #1, #2
You can put this code wherever you want. For example you could add it in the pickup script when you pick up a certain pickup object, or you could use it in the monsterHurt code (when a monster is killed).
5. Remember to reset the score when it's game over (or whenever you want to reset the score). You do this simply by adding this to (for example) your hurtPlayer file after +playerHealthIsZero:
6. That's it.
1. Create the following User Variables (make sure you create them in this order):
score000001
score000010
score000100
score001000
score010000
score100000
This will give you a score that can have a max value of 999999. Technically you can have two more values, but then you use all the sprite slots for that scan line, so if any sprite is on the same scan line they will disappear.
2. Copy these tiles from the HUD graphics (in the tutorial graphics folder), or make your own number graphics. Make sure the numbers are the first tiles in your GameObjectTiles.bmp file.
3. Put this code in your doDrawSpriteHud file:
Your can adjust the position of the score by changing the first two numbers after DrawSprite. The first number is the X position and the second number is the Y position. The last part of the DrawSprite macro decides what palette to use:;; Draw score
DrawSprite #16, #8, score100000, #%00000000
DrawSprite #24, #8, score010000, #%00000000
DrawSprite #32, #8, score001000, #%00000000
DrawSprite #40, #8, score000100, #%00000000
DrawSprite #48, #8, score000010, #%00000000
DrawSprite #56, #8, score000001, #%00000000
%00000000: Sprite palette 0
%00000001: Sprite palette 1
%00000010: Sprite palette 2
%00000011: Sprite palette 3
4. Now your score will be displayed in the sprite HUD. To add a value to the score just use the AddValue macro:
AddValue arg0, arg1, arg2, arg3
;arg0 = how many places this value has.
;arg1 = home variable
;arg2 = amount to add
;arg3 = what place value is receiving the addition?
;;; 0 = ones place, 1 = tens place, 2 = hundreds place, etc.
This can be a little tricky at first, but here's an example of adding 100 to the score:
AddValue #6, score000001, #1, #2
You can put this code wherever you want. For example you could add it in the pickup script when you pick up a certain pickup object, or you could use it in the monsterHurt code (when a monster is killed).
5. Remember to reset the score when it's game over (or whenever you want to reset the score). You do this simply by adding this to (for example) your hurtPlayer file after +playerHealthIsZero:
;; Reset score
LDA #0
STA score000001
STA score000010
STA score000100
STA score001000
STA score010000
STA score100000
6. That's it.