I'm progressing in third level theme of Teemu. I needed something new for items: duration and a flag telling if the item is active. Adding something like this in object class is very easy, but when your engine doesn't support them it's time for good old refactoring.
The problem in this case was that items in inventory are not real objects. When you pick up an item it becomes just an int variable in inventory list, and is then re-created when you toss it back in the gameworld. This all changes when you have things like duration to store. You could, in theory, refactor inventory so that it has the copy of object's duration. In fact there is one that kind of variable already: the amount of items. However the amount is something that can be controlled quite easily. Duration is different story, because it's natively controlled inside the object class. So, in order to proceed in level theme three I have to refactor inventory to store objects instead of ints.
While I'm at it, I could unify the inventory and new tool inventory with one base solution. The inventory was kind of braindead from the beginning, but I think it was the fastest way to produce something playable. I blame the old school roguelike programming now biting me on the leg like a grid bug.
No comments:
Post a Comment