Displaying Level # in HUD

vanderblade

Active member
I'm using Dale Coop's 2-player module and have created a 100-level Bubble Bobble-esque game that uses single-screen levels.

As I finish up the project, I was hoping to add a feature where the HUD displays the number of the current level, just like Bubble Bobble.

I am attaching a screenshot of my levels and how they are ordered. Essentially, I have levels 1-10 in a column, levels 11-20 in the column to the right, and so on and so forth until an ending sequence of levels.

I imagine tying the HUD display to the screen type number might be a solution, since sometimes players die and go back a few levels, and I don't want to use a counter that might mess up.

What's the easiest way to accomplish what I want to do?

Screenshot (91).png
 

dale_coop

Moderator
Staff member
Nice, if you set the screen type as the level number, it would make it even easier. You would need some code to display that screen type value on your HUD.
How is your HUD? do you have unused ones that you could use to display the Level?

For example, you could :
1/ rename the "UserVar_4" to "myLevel", display it on your HUD as a number '3' (will be "000").
2/ modify the HandleScreenLoads.asm script that is in your "Routines\Basic_NoScroll_TwoPlayers\System" folder, around line 426, you should see:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; ALL GRAPHICS ARE LOADED.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Just after those lines, add this block of code:
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; loads the screenType value into the myLevel hud variable (number 3):
	LDA #$00
	STA myLevel
	STA myLevel+1
	STA myLevel+2
	LDA screenType
	STA temp
-
	CMP #10
	BCC +
	AddValue #$03, myLevel, #10, #$00
	LDA temp
	SEC
	SBC #10
	STA temp
	JMP -
+
	AddValue #$03, myLevel, temp, #$00
	; UpdateHud HUD_myLevel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Now, myLevel should display the current screen type value in your HUD.
 

baardbi

Well-known member
That's genius Dale! I had done something like this with a lot of User constants (to keep track of the levels) in a testgame I made. But this is a thousand times better, as long as you don't need to trigger the screens :) I had to try this solution in my testgame, and it worked perfectly.
 

vanderblade

Active member
baardbi said:
That's genius Dale! I had done something like this with a lot of User constants (to keep track of the levels) in a testgame I made. But this is a thousand times better, as long as you don't need to trigger the screens :) I had to try this solution in my testgame, and it worked perfectly.

It still works after triggering the screen. One of the bugs I have to fix -- and I'll make a help post about it -- is that if I die after collecting the key but before using it on the lock tile, the screen triggers. When players load from death, the lock block is gone.

BUT...at least the level number (screen type) still displays correctly. :)
 

dale_coop

Moderator
Staff member
If you collect a key, the current screen (the one where the key was) is triggered. When you die, the triggered screens remain triggered.

But, it's like that, because you set your locked room and your key room with the same screenType value, right?
In your game, if you design the screens that you can only collect 1 key before opening a lock door... you can set differnt screenType for each room... when you collect the key, the (key) room is triggered... and then when you go to your locked room and touches your locked door, it will be opened (and the screen will be triggered at that moment). The locked door tile checks if you have a key to open or remains solid (when colliding with the player).
This behaviour requires that you have only 1 key & 1 door to unlock, at the time (because here, there would be no "link" between the key and the door... any key would open any door).
 
Top Bottom