Update #68 - Storage UI, Spatial Grid & ObjectShape

Hey, how have you been this week? I’ve been working hard on Merchantry. I’m amazed at the quick progress I’m making, and even more incredible that I’m not spending much time solving bugs, errors, or re-writing code.

Anyway, here are the minor changes:

  • Aeta UI: Added a minumum move distance variable to the Camera class. Moves if the distance from TargetPosition to Position exceeds the value.

  • Merchantry: The camera now can focus on WorldObjects, adding a stronger gamefeel and flexibility.

  • Merchantry: Added proper object selection. If the mouse is hovering over two objects, the one with higher depth is selected.

  • Merchantry: Added storage grid using the world-based UI framework.

  • Merchantry: Improved how world UI item slots handle drag-to-UI transitions. More shortcuts such as LMB+CTRL allow more control.

  • Merchantry: Added text above StorageObjects, telling the player how many items are in the storage.

  • Merchantry: Added trajectory and "per second" calculations to ObjectPhysics.

  • Merchantry: Objects now have mass. Low-mass objects are easily pushed around by high-mass objects.

  • Merchantry: Removed temporary code in the Inventory, and hooked up the controlled object's storage.

Storage UI

Making use of the same UI framework for crafting, I’ve added in another UI: Storage! You can see most of its functionality in the video above.


Width and height variables are passed to the Storage UI through thr constructor, so it can be easily fit to any other object. In this case, a pot and a barrel.

Spatial Grid


This is a non-recursive spatial grid designed to optimize how objects interact with other objects. Let’s look at this in the context of collision detection. Without, each object would check with collision with all other objects in the map. With, they only need to check in their sector plus neighbours.

The sectors use a lazy approach, only being created when an object steps into where a new sector should be. If the sector no longer contains objects, it is added to a recycled list after a small duration. If another object steps into it, the sector is recycled back instead of being created again.

When an object moves into a new sector, it removes itself from the previous sector’s list of objects and adds itself to the new one.


With this, any object can have a shape used for collision detection. I’ve created the Shape class which has the basic functionality (Offset, Contains, Intersects, etc.), and two classes which derive from it (Box and Circle).

The only parameters I need to focus on is the Shape’s offset (automatically relative to the Object’s offset), and it’s size. Circle is radius, box is width/height. If I want an object to take on a complex form, simply add more shapes.

Final Words

Current Goals: Object textures, tile textures, character code, pathfinding, crafting recipes, dialogue UI.
Future Goals: Pause UI (simple overlay), escape key UI, message UI, professions.

If you have any support, ideas, constructive criticism, or just want to tell me how much you dislike my creations, you can:

  1. Send me an email.

  2. Tweet to @Soestae.

  3. Gab to @Soestae.

  4. Toot to @Soestae.

  5. Comment below.

Do you want to support my projects? Here's what you can do:

  1. Become a Patron here!

  2. Tell your friends and family about my projects!

  3. Retweetrepost, retoot, and share!

Thank you for reading!
Soestae, Emberium