Categories
Game Design Game Development Geek / Technical

Freshly Squeezed Progress Report: Distributing Sandwiches

In last week’s report, I made it possible to see furniture inventory previews such as Snacks on the Kitchen Counter and started the work of handling quantified inventory items in The Dungeon Under My House, my non-violent, first-person role-playing game and my second Freshly Squeezed Entertainment project.

I finished the quantified item work this week.

Sprint 2024-30: Giving quantified items

Planned and complete:

  • Allow player to give/take arbitrary number of multi-quantity item

Unplanned and complete:

  • Defect: Items added to inventory by command go missing after load
  • Defect: Inventory preview renders in same spot on screen despite room transition animation
  • Defect: Dungeon won’t render upon first entering
  • Defect: Loading in dungeon seems to use previous move/turn state instead of latest

Sometimes seemingly simple things take quite a bit of effort to make happen.

In this case, I already had a way to transfer quantified items such as Snacks from furniture to the party’s inventory. I wanted to reuse the interface to give an item to another character, but it required a lot more work to make happen.

The Dungeon Under My House - moving quantified items between inventory slots

As I said last time, giving items is a two-step process.

First you select what you want to give. Then there is an attempt to give the item, and the receiver either accepts it or rejects it, currently based on their own Inventory’s capacity.

So unlike swapping out an item from a Furniture’s Inventory, which is immediate, there are edge cases to handle with giving quantified items.

For example, let’s say I have an Inventory slot with six sandwiches. I could give a character all six of the sandwiches I have in my Inventory. In that case, if they reject the gift, then I get all of the sandwiches back.

I could also give only one sandwich, keeping the rest myself. If they reject that gift, then the sandwich should be returned to the same slot that has the other five sandwiches. However, if I had my sandwiches split across two slots, then which slot does the sandwich get returned to? Ideally it would be returned to the slot that I swapped it out from originally.

And there are similar Inventory management concerns for other cases.

All this is to say that it took me some effort. I had to make changes to the Inventory and Item code to help make it easier, plus some code related to the menus involved with giving and swapping Items. Then testing to make sure I didn’t miss any edge cases and solving for the ones I discovered I had missed.

And of course, not introducing new problems, such as discovering that I accidentally made it possible to either completely lose the sandwiches or duplicate them. There should only be six total sandwiches in the game:

The Dungeon Under My House - duplicating sandwiches

But once I got it all working, I could hand out snacks to the Explorer’s Club, which finishes the Snack Quest (official quests aren’t in the game yet):

The Dungeon Under My House - snacks for everyone!

One thing I did discover is that handing out individual sandwiches to everybody was tedious. I need to eventually look into a “Divvy it up” command to split things up faster.

Otherwise, I fixed a number of defects, the trickiest of which was finding out why entering the dungeon the first time would show a black screen instead of the inside of the dungeon. I thought it was an order of operations problem in that the dungeon was rendering before lighting was calculated or something like that.

It turned out that the player’s position upon entering the dungeon was initializing to position (0, 0), so that’s what would be rendered. In the map, that position is out of bounds at the moment, so there is no lighting, no walls, nothing. So the dungeon renders, and then to be efficient, it won’t rerender until something changes.

But the problem was that right after the dungeon renders, my code sets the position properly to the location of the ladder leading back into the house, but it does so in a way that bypasses the “something has changed” logic.

The problem is that player’s the initial dungeon location depends on the dungeon being loaded to find that ladder’s location, which did, in fact, require changing the order of operations for loading a game so that the dungeon was loaded first, then the game’s variable data (such as the party’s dungeon position) is initialized, then if the game needs to overwrite that data from a save file, it does so.

Anyway, I’m glad that issue is fixed. It was annoying.

Thanks for reading!

Want to learn when I release The Dungeon Under My House, or about future Freshly Squeezed games I am creating? Sign up for the GBGames Curiosities newsletter, and download the full color Player’s Guides to my existing and future games for free!

One reply on “Freshly Squeezed Progress Report: Distributing Sandwiches”

Comments are closed.