The Score Var and other HUD stuff is sure Buggy

drexegar

Member
If I change my jump kills to 100 points in the collision script, after I do 2 or them the last digit dispersals, and it looks like I have 20 points,

if I want to make my digits smaller like 3 digits only, that will mess up after a couple points and ill lose a digit and eventually random sprites will replace the last digit.

Sometimes I Iose points for jumping on a character.

If a enemy leaves the bounds and is destroyed by leaving that area where the enemy is at, and moving to the next room, I lose my last digit.

Is their a fix for this? Should I just full around with the asm and find a slightly better way to fool proof writing numbers down?

UPDATE: it seems that when I add my health graphic the score bugs went away, now i need to see what cause my health to be drawing into the background. I'm guessing I have to use or delete anything in the HUD not being used so I don't end up with empty bugs?
 

dale_coop

Moderator
Staff member
There is a "bug", an issue ... with the HUD Variables and the HUD Update code
Everytime your player is hurt, the HUD variable myHealth is modified (decreased), and the HUD myHealth code is executed.
Everytime a monster is killed, the HUD variable myScore is modified (increased), and the HUD myScore code is executed.
Everytime you take a PowerUp "health", the HUD variable myHealth is modified (increased), and the HUD myHealth code is executed.
Everytime you take a PowerUp "key", the HUD variable myKeys this modified (increased), and the HUD myKeys code is executed.
Everytime you take a PowerUp "coin", the HUD variable myMoney modified (increased), and the HUD myMoney code is executed.

AND if those variables are NOT on displayed your HUD... when the an HUD update code is executed, it breaks the HUD (freeze it). The HUD is updated again correctly, when your screen is loaded (when the player comes in another screen)

So a fix would be to comment all the HUD update codes related to HUD variables you don't use/display on the HUD.

For exemple in the increase "myMoney" HUD update code:
Code:
		LDA #$01 ;; amount of score places?
		STA hudElementTilesToLoad
		LDA DrawHudBytes
		ORA #HUD_myMoney
		STA DrawHudBytess
I you don't have that info (MONEY) on your HUD, it will freeze the HUD.
So you have to search in all the scripts, and comment those lines.
 

drexegar

Member
dale_coop said:
So a fix would be to comment all the HUD update codes related to HUD variables you don't use/display on the HUD.

For exemple in the increase "myMoney" HUD update code:
Code:
		LDA #$01 ;; amount of score places?
		STA hudElementTilesToLoad
		LDA DrawHudBytes
		ORA #HUD_myMoney
		STA DrawHudBytess
I you don't have that info (MONEY) on your HUD, it will freeze the HUD.
So you have to search in all the scripts, and comment those lines.

Ahh nice idea! But where is the myMoney HUD code located? I look though all scripts in the project settings of the platform module, and I could only find score and health. Does the platform module even use the myMoney Code?

My Hud is working good now, but the health bar is off (you only updating the life after you get hit so reading is of by 1 and wont empty when you die and wont show full health until you get hit). That has to manually fix right?

Im going to have to force it on one of the collsions tile to force update the health, I already figure out how to make one disable and re enable control functions through a variable I added into the control scripts.
 

Imagaryboy

New member
drexegar said:
dale_coop said:
So a fix would be to comment all the HUD update codes related to HUD variables you don't use/display on the HUD.

For exemple in the increase "myMoney" HUD update code:
Code:
		LDA #$01 ;; amount of score places?
		STA hudElementTilesToLoad
		LDA DrawHudBytes
		ORA #HUD_myMoney
		STA DrawHudBytess
I you don't have that info (MONEY) on your HUD, it will freeze the HUD.
So you have to search in all the scripts, and comment those lines.

Ahh nice idea! But where is the myMoney HUD code located? I look though all scripts in the project settings of the platform module, and I could only find score and health. Does the platform module even use the myMoney Code?

My Hud is working good now, but the health bar is off (you only updating the life after you get hit so reading is of by 1 and wont empty when you die and wont show full health until you get hit). That has to manually fix right?

Im going to have to force it on one of the collsions tile to force update the health, I already figure out how to make one disable and re enable control functions through a variable I added into the control scripts.

Were you able to resolve your problem? I have the same issue where the health is displayed by 1 off.
 

drexegar

Member
Imagaryboy said:
Were you able to resolve your problem? I have the same issue where the health is displayed by 1 off.

Im not fixing it right now, but my solution is to use the tile I made so in the check points when he dies and get back on the screen he will land on a block that will force update his health which should of been updated in the first place.
 

Imagaryboy

New member
Ahhh I'm going crazy with my health display, nothing works as it is supposed to:

-My player has 8 HP
-When the player dies, the last HP never disappears
-The player then starts with the last HP again
-If the player then gets hit again, the HP bar is full again and depletes normally with each hit
-again: the last HP never disappears
-health pickup works only when the player has less than 3 HP (I can't replenish beyond the 3 HP mark with health pickup)

It's such an important thing in my game and it's really frustrating that I can't get this to work properly. Am I the only one who has these problems?
Hope you can help me out :|
 

dale_coop

Moderator
Staff member
For your player death and when he restart with the last HP problem, you need to modify the "HurtWinLoseDeath\Adventure_HandlePlayerDeath.asm" script, to refill your HP when he dies... like this (line 22):
Code:
	TXA
	STA tempx
	TYA 
	STA tempy
	
	;;;;;;;;;;;;;;;;;;;
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$08, #$00
	;; need to do this redundantly, otherwise, the death object will be in same slot as player
	LDX player1_object
	DeactivateCurrentObject
	;;;;;;;;;;;;;;;;;;;
	;;StopSound  ;;<<-- don't want the music stop after the player dies
	
	LDA #$FF
	STA player1_object
	
	;; HERE: when player dies, we give back his HEALTH :
	LDA #$08	
	STA myHealth
	
	LDX tempx
	LDY tempy

For your Hp can't be more than 03 when getting a PowerUp, you need to modify your "PowerUp_IncreaseHealth.asm", like this (line 7):
Code:
;;; Increase Health code for player.
;;; works with variable myHealth
;;; works with HUD variable HUD_myHealth.
	LDA myHealth
	CLC
	ADC #$01
	CMP #$09	;;<<-- HERE: the limit max (the myHealth can NEVER be)
	BCS skipGettingHealth
	
	TXA
	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
	
	LDX tempx
	
skipGettingHealth:
	PlaySound #SFX_INCREASE_HEALTH

Note: I suggest you to use custom scripts: copy the original scripts and make your modifications . Then assign the custom scripts in the "Project settings > Script settings" for your project (instead of the originals).
Doing that, when you will make a new project, yoru new project will use the original scripts... not your modified ones (what if, in your next project you don't use 08 HP, ...)
 

Imagaryboy

New member
Thank you so much, that really works! :D

The only thing that's left now, is the last HP that won't disappear. Hope there is also a solution for that^^
 

dale_coop

Moderator
Staff member
Ok, your "last HP that won't disappear"... when doing what?
If it's after the player death, the modification of the "Adventure_HandlePlayerDeath.asm" should set it back (to $08 in your case, cf my script)
 

Imagaryboy

New member
dale_coop said:
Ok, your "last HP that won't disappear"... when doing what?
If it's after the player death, the modification of the "Adventure_HandlePlayerDeath.asm" should set it back (to $08 in your case, cf my script)

When the player takes his 8th hit, the last health point should also show an empty tile instead of a full tile before resetting the game.
 

dale_coop

Moderator
Staff member
Oh that always has been like that (cf all Joe's videos).
When the player takes his last (8th) hits, it directly resets the game.

But you could try (at line 6):
Code:
	TXA
	STA tempx
	TYA 
	STA tempy
	
	;; UDPDATE the health HUD a last time before die :
	LDA #$00
	STA hudElementTilesToLoad
	STA hudElementTilesMax
	LDA DrawHudBytes
	ora #HUD_myHealth
	STA DrawHudBytes
	;; TURN ON handling the hud
    
	;;;;;;;;;;;;;;;;;;;
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$08, #$00
	;; need to do this redundantly, otherwise, the death object will be in same slot as player
	LDX player1_object
	DeactivateCurrentObject
	;;;;;;;;;;;;;;;;;;;
	;;StopSound  ;;<<-- don't want the music stop after the player dies
	
	LDA #$FF
	STA player1_object
	
	;; HERE: when player dies, we give back his HEALTH :
	LDA #$08	
	STA myHealth
	
	LDX tempx
	LDY tempy
 

chronosv2

New member
All the code referencing myMoney is in Routines\UserScripts\AdventureGame_Base\PowerUpCode\
My advice to anyone looking to work with code is to get Notepad++ (or even better if you can afford it, Sublime Text 3) because you can find in files in folder to find all the references to a thing.
Also worth noting in the modules a lot of script is loaded whether you use those items or not -- in the Project Settings -> Script Settings tab you should set any tile types or power ups you're not using to their Blank equivalents in the same folder (i.e. "ROUTINES\UserScripts\AdventureGame_Base\PowerUpCode\Powerup_Blank.asm").
 

Imagaryboy

New member
dale_coop said:
Oh that always has been like that (cf all Joe's videos).
When the player takes his last (8th) hits, it directly resets the game.

But you could try (at line 6):
Code:
	TXA
	STA tempx
	TYA 
	STA tempy
	
	;; UDPDATE the health HUD a last time before die :
	LDA #$00
	STA hudElementTilesToLoad
	STA hudElementTilesMax
	LDA DrawHudBytes
	ora #HUD_myHealth
	STA DrawHudBytes
	;; TURN ON handling the hud
    
	;;;;;;;;;;;;;;;;;;;
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$08, #$00
	;; need to do this redundantly, otherwise, the death object will be in same slot as player
	LDX player1_object
	DeactivateCurrentObject
	;;;;;;;;;;;;;;;;;;;
	;;StopSound  ;;<<-- don't want the music stop after the player dies
	
	LDA #$FF
	STA player1_object
	
	;; HERE: when player dies, we give back his HEALTH :
	LDA #$08	
	STA myHealth
	
	LDX tempx
	LDY tempy

Thanks again! it worked but I had to drop some other code because I ran out of space xD
 
Top Bottom