Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits)

Days 6 to 10

What I've done

  • Player and enemies can now take damage, and die.
  • Collectibles and Materials classes and scenes.
  • Enemies can now drop materials, I added a drop table on my Enemy base class.
  • Dropped materials can be picked up by the player.
  • Inventory on Player class added, it's updating when a material is picked up. A HUD representing the player's inventory has been added too.
  • Health bar for the player.
  • Enemies on stage are now disabled by default (all non relevant nodes attached to it are not processing), to save resources. They are enabled when they enter the screen.
  • Some refactoring, and comments added.

Player's health bar

It's a simple bar made in Hexels. For now, it's only updating his value and go up or down without any animation. I'll add animations, and color modulation depending on the health value (green when full, to red when low).

Collectible and Material

Collectible is a simple class that check for collisions with entities that are in "player" group, if it collide with the player, "collect" abstract method is called. His scene is holding a sprite that is defined by the classes that is extending this one. Material class has an id representing an in-game material (I don't feel the need to have a name for each material, their "name" will be a visual representation of the material). The sprite is loaded with a Resource manager class, which returns the correct sprite for the material id. Dropped material "float" in space, with a random direction, speed, and rotation.

Drop table

Drop table is a Dictionary attached to BaseEnemy class with a helper class to parse it. I did not want to make a class for the drop table it self, since I wanted to easily edit an enemy drops in the editor. The Dictionary is formatted as below.

drop_table = {
    "nb_of_drops":[
        {"quantity": 0, "random_weight": 1},
        {"quantity": 1, "random_weight": 1},
        {"quantity": 2, "random_weight": 1},
        {"quantity": 3, "random_weight": 1}
    ],
    "drops":[
        {"material": 1, "random_weight": 1},
        {"material": 2, "random_weight": 1},
        {"material": 3, "random_weight": 1},
        {"material": 4, "random_weight": 1},
        {"material": 5, "random_weight": 1},
        {"material": 6, "random_weight": 1},
        {"material": 7, "random_weight": 1},
        {"material": 8, "random_weight": 1},
        {"material": 9, "random_weight": 1},
        {"material": 10, "random_weight": 1},
        {"material": 11, "random_weight": 1},
        {"material": 12, "random_weight": 1}
    ]
}
# nb_of_drops dictionaries represent the quantity of materials that can be dropped.
# drop_table["drops"][i]["material"] returns a material id,
# and drop_table["drops"][i]["random_weight"] returns the random weight for this id.
#
# random_weight is used as:
# (random weight for an entry) / (total random weight) = (chance to drop)
# e.g.
# [...]
#     drops:[
#         {"material": 1, "random_weight": 2},
#         {"material": 2, "random_weight": 3},
#         {"material": 3, "random_weight": 7}
#     ]
#}
# Total weight = 12
# Material 1 has 2/12 chance to drop
# Material 2 has 3/12 chance to drop
# Material 3 has 7/12 chance to drop
#
# *Quantities follow the same idea. 

I could have simplified the structure and get rid of "quantity", "material", and "random_weight" keys, But I wanted to make it clear, and well formatted in the editor.

Enemies

Now, they are disabled when they're not visible in screen. Disabled means that all their children nodes are not processing, I still keep a visibility notifier node processing to know if the enemy is visible on screen, when it is, I reactivate the processing of children. When enemies are disabled, they still move in the background, they move toward the viewport and "spawns" when it enters the screen, so I can build levels in the editor and have a visual representation for each level.

What I want to do next

  • Animate player's health bar.
  • A BaseRecipe class, used as a base for crafting recipe.
  • First recipe to craft a weapon, and attach it to the player.
  • A crafting menu in the HUD.