The focus of the last couple of weeks development for The Alchemist has been inventory management - toolbar, player backpack, planting seeds and harvesting crops. Though farming is not a large part of my plan for the game, developing this now does give me the experience I will need for other, more core game mechanics.
This has been quite a challenge. First I created a Toolbar view, with ten slots. I've faked some data, so the player always has a couple of different seeds to plant, and a tool to harvest with. Clicking on an icon in the toolbar selects the item; as does pressing the appropriate numbered key.
Then I started working on drag-and-drop functionality, so the player can reorder the toolbar as they wish. This has been a big challenge for me, as I learned how to handle KorGE's draggable component. There's a lot of logic to determine what can be dragged, and where. A bigger issue I had was with z-ordering - because each icon is drawn in turn, dragging the icon in the first slot would put it behind the images for the subsequent slots. I've had to split the KorGE views into a number of different containers. This means, programmatically, things are a little less organised than I would like. But I'm coming round to it.
I've also added a Backpack, and when the player harvests a crop, the backpack fills up with the right items. Crops can be stacked.
Once both those features were basically working, I then had to rationalise them - there was a lot of code duplication. So now Backpacks and Toolbars are instances of a more generic Bag
class, and the icons are BagIcon
s, rather than ToolBarIcon
and BackpackIcon
.
I've started to look at transferring items between the Backpack to the Toolbar, but I've decided to put that on hold. I am not sure if that is functionality I want or need. In the game Factorio, the toolbar is not an inventory, but a view on the players inventory. In Factorio, a toolbar slot may contain a pointer, essentially, to something the player has none of. I might want to do a similar thing. I may even consider shrinking down the toolbar, as I am not sure how many things would be useful for the player to have quick access to. The toolbar might then just become a selector between main-and-offhand tools/weapons.
I don't know, and I don't think I will know until I have played more of the game. And for that, I need to write more of the game.
Next step, I think, is to start work on the core mechanics of processing herbs and ingredients to create potions and lotions. The alchemy part of The Alchemist. It's a big job, and I'll need a new scene in which to do it.