[4.1] Icarus Sprite HUD [BROKEN!]

chronosv2

New member
After a little more time (and a video re-edit) than I expected, it's finally ready!

This is a basic sprite HUD that you can use for your games, and an included plugin to make setting it up simple! The only code you'll have to write is anything custom you want the bars to do.

Features
  • Simple HUD - Numeric Display with optional icon and Dynamic Bar (set a current/maximum)
  • Easy to set up and use
  • Conditional Assembly - If you have a feature turned off it doesn't get assembled into your ROM!
  • An (optional) AI Action + HandleHurtMonster modification for Boss Health Bars

I plan on taking this HUD much further. My hope is to rebuild it to be much more flexible, but that will take some time. Thankfully thanks to the plugin system you won't have to change anything. Once the new version comes out when you load your project it will automatically set things up to just work.

Update Overview video (Watch this before the tutorial, it goes over new features)
[media]https://youtu.be/AM0MWEUA5WY[/media]

Tutorial Video (with fixes) here:
[media]https://youtu.be/bMl8vsfnE34[/media]

Download Removed as the plug-in is broken and I don't know when/if it will be fixed.

As always if anyone has any comments, constructive criticisms or questions, feel free to ask and I'll do my best to support you all as best I can.
 

Mugi

Member
That's some pretty heavy stuff going on there, awesome work !
makes my potato hud look really crappy now :p
i love the small digits thing with the score!
 

chronosv2

New member
Your "potato" HUD is probably way more efficient though.
My HUD follows the NESMaker mantra -- things are kept generic to make it as capable for a large group of people as possible.
You're always going to have a better, smoother running system with an smaller, more optimized code.

For instance, the Dynamic Bar is designed to allow you to expand it, and since I don't know what kind of values the user is going to plug in I support many different levels and use math and conditional statements to figure out how many segments I need to draw. If you know your maximum is always going to be 8 you don't need to do that math and conditional work, and that saves both CPU cycles and ROM space.

I try to make up for that in my HUD by using conditional assembly to figure out what work the game engine needs to do. For instance, if you're going to use a 2-step bar, I know I don't need to include the code for calculating how many segments are going to be drawn for a 4 and 8-segment bar. If you uncheck an option, I simply skip assembly for that code so it doesn't end up in the ROM.

So the flexibility comes with the cost of CPU cycles and ROM space.
 

Mugi

Member
that will propably be the deciding factor for me.
My hud only counts HP up to 8, in one exact way, using a total of 4 sprites to draw it (including the optional health icon) it's pretty compact as far as that kind of code goes.
i do need a money counter so i might peek into how you pulled off the "score" counter and adapt it though :p
 

chronosv2

New member
Here's the code for you so you don't have to go fishing through the Zip files.
You'll see some of the conditional compilation stuff in there, as well as some sanity checking I did with the ASM6 pre-processors.

Constants:
Code:
    CURRENCY_VARIABLE = #playerScore
    SPRITE_HUD_NUMBER_0 = $76       ;;The number 0 on your GameObject Sprite Sheet - all numbers must be in order (012..789)
    SPRITE_HUD_SCORE_START_X = $08  ;;The starting X coordinate (in pixels) for "hearts"
    SPRITE_HUD_SCORE_START_Y = $08  ;;The starting Y coordinate (in pixels) for "hearts"
    CURRENCY_NUMBER_OF_DIGITS = $03 ;;The number of digits in the Currency display
    NUMBER_SPACING = $08
    NUMBER_Y_OFFSET = $00

Code:
Code:
        LDX #CURRENCY_NUMBER_OF_DIGITS
        currencyLoop:
            DEX
            LDA CURRENCY_VARIABLE,x ;;We need to draw a digit. Grab each one in descending order (Thousands, hundreds, tens, etc)
            CLC               ;;Clear carry
            ADC #SPRITE_HUD_NUMBER_0 ;;Add the address of our "0" number and we have the number ready to draw!
            STA temp                 ;;Just gotta' store it in a variable for the DrawSprite macro.
            IFNDEF NUMBER_Y_OFFSET_MINUS
                IF (#SPRITE_HUD_SCORE_START_Y + #NUMBER_Y_OFFSET) > 255
                    ERROR "Offset causes Number Y Position to overflow! Please correct this in the IcarusHUD Plugin."
                ENDIF
                DrawSprite temp2, #SPRITE_HUD_SCORE_START_Y + #NUMBER_Y_OFFSET, temp, #NUM_PALETTE, spriteOffset
            ELSE
                IF (#SPRITE_HUD_SCORE_START_Y - #NUMBER_Y_OFFSET) < 0
                    ERROR "Offset causes Number Y Position to underflow! Please correct this in the IcarusHUD Plugin."
                ENDIF
                DrawSprite temp2, #SPRITE_HUD_SCORE_START_Y - #NUMBER_Y_OFFSET, temp, #NUM_PALETTE, spriteOffset
            ENDIF            
            inc spriteOffset
            inc spriteOffset
            inc spriteOffset
            inc spriteOffset
            LDA temp2 ;;Increasing X by NUMBER_SPACING again.
            CLC
            ADC #NUMBER_SPACING
            STA temp2
            CPX #$00
            BEQ doneCurrency
            JMP currencyLoop
        doneCurrency:

After re-reading all this I noticed this part isn't as well commented as I had hoped. I'll have to fix that for any subsequent release.
 

Mugi

Member
if you want to add it as an option to your hud base, my hud went through a slight modification couple days ago that gives it a timed effect when picking up a health object, it's a pretty neat little visual detail.

https://www.youtube.com/watch?v=eEjMU4RQ1d0

My hud operates on the macro written by jorotroid, but essentially what happens at the end, is that it just sets Object_health,x into temp3 then uses temp3 as an argument when drawing the hud in predraw.

the code i use for it is as follows:

Code:
    LDA Object_health,x
    CMP HudHealth
    BCC hudhealthstore
                        ;If here, player Health is greater than or equal to HudHealth
    BEQ hudhealthstore  ;If equal, we don't want to add to HudHealth, it already matches
                        ;If here, player Health is greater than HudHealth. Our player (probably) picked up health recently.

    INC HudTimer
    LDA HudTimer
    STA HudTimer
    AND #%00000111      ;Will only add every 8th frame.
    BNE skipaddhud
    LDA HudHealth
    CLC
    ADC #1
hudhealthstore:
    STA HudHealth
skipaddhud:
    LDA HudHealth
    STA temp3

this requires an extra variable to tbe set in user variables for the "hudhealth" but it has adjustable timing per tick, and is foolproof in a way that it only delays the drawing on the hud, not the actual HP value of the object, so it's not abusable for infinite HP.

since your hud is so comprehensive to begin with, it could be added as an extra option if the user so wishes.
 

chronosv2

New member
That's a really cool feature! I'll have to see if I can adapt it to the health bar code for a future version. Thanks for sharing!
 

TolerantX

Active member
Nice HUD! This looks ideal for fighting that big boss battle. :) I hope to see the gradual timed feature in the next release. Thank you
 

chronosv2

New member
I'll see what I can do! Might require a little work Plugin-side but I'll definitely look into it since people are interested in it.
 

dale_coop

Moderator
Staff member
Didn’t have time to test the updates version of the Icarus HUD. But I loved the previous version, and your new video shows very exciting things!
Can’t wait to use it!
 

Mugi

Member
chronosv2 said:
I'll see what I can do! Might require a little work Plugin-side but I'll definitely look into it since people are interested in it.

the basic implementation shouldn't really be hard at all, set up the necessary variables (hudhealth and hudtimer) and then just point out the value that you use to draw the end result (temp3 in my code) and route your parameter though the timer.
now testing all that with all the other things you have going on is a whole different story... Especially if you intend to also implement this for monster hp bars et cetera. Good luck with that :p

im not too familiar with the plugin coding but i did take a look at the basic "instructions" that were posted about it and it should be rather straightforward to implement (pay attention to the fact that the bits controlling the delay are per-frame, and are offset by 1 frame (0 = 1 frame delay, a.k.a. draw every frame ))
 

chronosv2

New member
Plugin-side I can create any variables the plugin needs, but the problem I have right now that's making me hold off is if the user enables the feature and turns it off later there are manual steps to be taken to clean up their project. I'm trying to design my plugin so that the end user has to do very little to "maintain" their project in regard to the sprite HUD's functionality, so any way I can allow the user to spend less time poking around in Project Settings the better. :)

As for monster HP bars, etc, there's only ever going to be one bar, one number and one icon in the basic version of the plugin (what people have now) so it could work as a boss HP bar or whatever you want to make it fairly easily and once I add the functionality it'll "just work".

I'm not sure if people will still be able to use this in the eventual rewrite I plan to do to make it more flexible like the Tile HUD is. So people might have to decide "Basic Version with bells and whistles" or "advanced version with more flexibility".
 

Tishero

New member
I ran into a small problem with the Icarus Hud on version 4.1.4.. whenever I go to set up everything, the elements, empty bat location ect... and click on another tab, everything returns to default settings..
 

chronosv2

New member
Tishero said:
I ran into a small problem with the Icarus Hud on version 4.1.4.. whenever I go to set up everything, the elements, empty bat location ect... and click on another tab, everything returns to default settings..

I'll look into that and see what I can do!

Edit: After some investigation I've discovered that it happens on all versions 4.1.1 and up. Further investigation is required.
 

Tishero

New member
I've ran into another problem.. after installing Icarus on 4.1.4 and run a test I get these errors
Plugins\IcarusHUD_Constants.asm(10): Unknown label.
Plugins\IcarusHUD_Constants.asm(11): Unknown label.
Plugins\IcarusHUD_Constants.asm(12): Unknown label.

I tried to add them to the user variable and its saying its already there
 

chronosv2

New member
Lines 10, 11 and 12 are pointing to the variables you have set for the Bar's value, bar's maximum and score variable. The variables it expects are exactly the ones you type into the text box. So if the text box has "myHealth" as the bar's value variable, you need "myHealth" (spelled exactly the same) in any of the variable spaces (HUD, User, ZP, Overflow).
I'm already in the code so I'll see if there's anything I've missed.
 

chronosv2

New member
Uninstall is simple enough:

  1. In your NESMaker folder, go into the Plugins folder and remove IcarusHUDInterface.dll
  2. In your project settings go into Script Settings tab.
  3. Scroll to the bottom and remove "IcarusHUD Constants" and "IcarusHUD Base"
  4. Scroll up and find "Handle Sprite Pre-Draw" and in the right pane, navigate to Basic -> ModuleScripts -> MainScripts. If you're making a game using just the Base or Maze Game modules use the PreDraw.asm from that folder. Otherwise double-click the folder for the game you're making and use the PreDraw.asm from there.

Sorry you're having trouble. I'm looking into this as quickly as I can.
I'll also remove the link from the forums to make sure nobody else runs into this issue until it's fixed.
 

chronosv2

New member
I'm glad you're excited!

This problem is really strange, because I know it worked before.
Visual Studio is updating (and I'm on a slow internet connection) so I'll try to find out what I can and keep things updated. Maybe when the update is released I should post a new version of the thread in the main part of the forums so people don't have to go looking here! Haha
 
Top Bottom