Posted June 24, 2024 by HexTree
#learn you a gamejam 2024
This is a Blog daily update for Learn You a Game Jam 2024
Goal of Day: Ability to 'pick up' an item and have it go into HUD slot
Video footage: https://www.twitch.tv/videos/2178763323
I created an item lying on the ground, which was just a Sprite2D. The script for the level itself holds an 'item_map' variable, keeping track of what items lie in which grid coordinates. The idea is that this would circumvent the need for collision objects, as a more efficient way to see if you 'collide' with an item is just to check that your coordinates match.
Upon standing in the item's tile, I copy the sprite image into a space on the HUD, then destroy the item altogether.
if grid_position in get_parent().item_map: print("found item") var item = get_parent().item_map[grid_position] hud.add_item(item) item.queue_free() get_parent().item_map.erase(grid_position)
It's a very rudimentary proof-of-concept, and clearly I haven't used any properties of the item other than its sprite. Since the 'inventory slot' will be a core mechanic, I intend to develop on this, and create some sort of efficient data structure to store items with their properties.