Today’s post is about adding health-indicator hearts to my game Splungeon (working title).

  1. The first job was to add the concept of health to the game. As it is you can run around and bump into enemies, but nobody loses health.
    Here I have a “State” class, that holds the state of the game (who would have guessed it!). Lately I’ve been making all of my game state classes have public members by default, unlike the normal convention I follow in the rest of my code. Maybe I’ll find a good enough reason to use accessors here, but today is not the day.
  2. Instead of making a heart by scratch (not that hard really) I’m going to use the icon font, Font Awesome. I already had the font installed, but you can download it from their site.
  3. I created a new file in Blender (version 2.77) add added a Text object to the scene.
    I picked the font, aligned it to the centre, and entered the Unicode character for the heart, #F004. I actually had to copy it from an application that lets you enter Unicode, and then I just pasted it in Blender.
  4. I then turned the resolution down until there weren’t too many faces, and converted the object to a Mesh.
    Then I named the Mesh “Heart” and exported it as an OBJ file (and kept an original .blend file)
  5. I saved the file to the raw resources folder of my android app. I’ve been prefixing mesh/model files with “m_” as you can’t have subfolders, and I have other files like shaders and textures in there.
  6. I have some code already to load OBJ files. This one doesn’t have texture coordinates, so I did a little tweaking for that.
  7. Then I added it to my HUD rendering code (it was empty). The position is based on the aspect ratio so it is in the top-left, scaled at 10% of the size

Leave a comment

Your email address will not be published. Required fields are marked *