HUD/Key Mapping Help Needed

Started by SolarDreamGames, July 08, 2016, 08:30:58 PM

Previous topic - Next topic
I am wondering if anyone has really done a HUD system and key mapping after watching Christopho's tutorial on the rupee counter? I tried to do the same with thing as the rupee counter with the hearts with no avail. All I need left to finish is the hearts, key mapping for controller use, getting enemies to attack you, and menus. I am patiently waiting for Christopho to redo the French tutorials in English with 1.5 as he stated in these forums. But, I am making this for my daughters who love Zelda games, as I do too, so thanks to anyone with help...

You could post the code you've got so far ;)

Of my game manager script? or every script in the game? Seems like that would be a lot of scripts. And this will help me with the HUD system and stuff?

Quote from: SolarDreamGames on July 08, 2016, 08:30:58 PM
I tried to do the same with thing as the rupee counter with the hearts with no avail.

If I understand this correctly, you've already tried to make a HUD for the hearts. If you show the code of this attempt then maybe I could tell why it's not working.
Have you tried watching the french tutorial video yet? Maybe you would understand it even without the explanations...
Oh, and in case you didn't know: you can access the source code of the games made by Solarus Team. You can find the code for the hearts here: https://github.com/christopho/zsdx/blob/dev/data/hud/hearts.lua. Perhaps this will help you?

I already have a hearts.lua just trying to figure out how to call it and display it like the rupee.lua.

The rupee script is displayed/called like this:

local rupee_icon = sol.surface.create("hud/rupee_icon.png")
local rupee_text = sol.text_surface.create()

function game:on_draw(dst_surface)
 
rupee_icon:draw_region(0, 0, 12, 12, dst_surface, 10, 220)
rupee_text:set_text(game:get_money())
rupee_text:draw(dst_surface, 25, 228)
end

Just thought I should be able to call/display the hearts.lua the same.???

Your rupee script apparently defines a game.on_draw function. If other scripts do the same, then only the last one executed takes effect.

The solution is either to define only one game.on_draw function that calls all hud script, but this is tedious especially because you would need to do the same for game.on_command_pressed, game.on_started, etc. Which is exactly why the menu API exists. You can start/stop a menu and then all its events are automatically called for you. http://www.solarus-games.org/doc/1.5/lua_api_menu.html

Sounds right, maybe. I don't know very much about coding. Tried to learn it for the last 4 years and still can not code (Java, C++, C#)(Using Unity and Unreal). I am a game designer, not programmer unfortunately. I can show you very nice and detailed level designs, but that seems to be it for me. And I have apparently messed up my project_db so I will have to start all the way over again. Sorry...