Update #70 - Textures, Pathfinding, & Interfaces

Merry Christmas and Happy New Year! It’s the last update of 2018, and the seventieth at that. Let’s start with the minor changes:

  • Merchantry: Moved render-oriented variables from RenderObject up to WorldObject.

  • Merchantry: Objects can now attach to each other.

  • Merchantry: Added the Calendar class.

  • Merchantry: Added a UI for transitions.

  • Merchantry: Added a matrix to WorldObject.

  • Merchantry: Added ObjectPath to WorldObject.

  • Merchantry: Added DirectionalTile to pathfinding, and changed what class calculates the cost.

  • Aeta UI: SortByRenderOrder() now returns a list of elements.

  • Aeta UI: Added DrawElement method, and another DrawElements method which accepts a list of elements as a parameter.

  • Merchantry: Added worth values to most items.

  • Merchantry: Added six new recipes: Iron pickaxe, axe, hammer, spade, longsword, dagger, wooden bow, iron bow.

  • Merchantry: Fixed a game crashing bug caused by rapidly adding and removing items from the inventory.

  • Merchantry: Inventory bug from above was not fixed, now it is. Events weren't being removed properly.

  • Merchantry: Goals can now contains other goals.

  • Merchantry: New character textures. Child red, child blue, child green, adult red, adult blue, adult yellow, adult white.

  • Merchantry: Added DepthTile. Similar to an object, this sets its depth from the world automatically.


Textures

In this first picture is the current version of what the alpha map will look like. I still need to add in some shelves to place items for sale on, and various decorative objects.

Dirt/grass textures

Dirt/grass textures

New alpha characters, complete with arms and pants.

New alpha characters, complete with arms and pants.

A collection of 14 potions and 2 empty bottles.

A collection of 14 potions and 2 empty bottles.


Pathfinding

An implementation of A* pathfinding with tile costs. In the video above, grass tiles cost 10, whereas path tiles cost 1. This influences characters to stay on the path as opposed to treking through grass. Towards the end of the video are two rows of 5-cost tiles, which are directional. The top row has lower cost if travelling from right to left (1-cost), but higher if travelling the other way (10-cost). The bottom row is the exact opposite. This allows me to easily create two-lane streets.

Rather than specify a “wall” type, I simply don’t add it to the grid. This means that tile will never get searched because it doesn’t exist. My pathfinding grid uses a Dictionary<Point, PathTile> instead of a 2D int[,], so it’s a bit easier to do that.

Here’s a brilliant guide on pathfinding. His examples use C++ and Python, but it’s easy enough to translate to C# (or whatever other language you use!).


Interfaces

I added two UIs: a transitions UI, which I’ll use for fading in/out, company splash screen, etc. A HUD UI, which displays the time of day and the controlled object’s currency to the player. You can see it in the pictures above, but here’s a closer look.

hud.png

The time follows a complete calendar system. Four quarters in a year, thirty days in a quarter, twenty four hours in a day, sixty minutes in an hour, and mostly importantly, two hundred milliseconds per minute (temporary value for alpha). One real-time second equals to five in-game minutes, and about five real minutes per in-game day. Additionally, I can hook-up C# events to specific times (down to the minute), which works perfectly for game events.


Current Goals: Character code, events, crafting recipes, temporary recipe book, flora textures.
Future Goals: Alpha release.

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

Update #69 - Message UI & New Textures

Hello! I hope you’ve been doing well. Even though I took a couple of days off around Thanksgiving, I got a lot done in the past couple of days. First, here are the minor changes:

  • Merchantry: Added "IsEnabled" to shapes. Disabled shapes don’t intersect.

  • Merchantry: Added string Group to shapes. Any two shapes of the same group can intersect.

  • Merchantry: Crafting the same recipe multiple times without removing the output items will now add to the stack. If different output item or max stack, it gets spit out into the game world.

  • Merchantry: Clicking an item on the player will add it to his storage, showing up in the inventory UI.

  • Merchantry: WorldItem is now compliant with LeftClick() standards.

  • Merchantry: The selected object's LeftClick(), RightClick(), and ItemClick() methods are now ignored when the mouse is inside a UI.

  • Merchantry: Crafting an item takes time, and can be queued by clicking the craft button multiple times.

  • Merchantry: Added right click events to world UI elements.

  • Merchantry: Now you can decrease the crafting queue count by right-clicking the craft button.

  • Merchantry: Context UI supports infinite options.

  • Merchantry: Storage objects can be emptied via Context UI.

  • Merchantry: UI click detection functions, and the inventory tabs and BaseUI titlebar have click detection.

  • Merchantry: The game stops when the window is inactive.

  • Merchantry: Added a currency item.

  • Aeta UI: Added key and mouse control delaying to Controls.cs.

  • Aeta UI: Removed the control delaying from UserInterface.cs.

  • Aeta UI: InterfaceManager.cs now passes its Controls instance to added UIs.

  • Merchantry: Added LayerObject, allowing layers to have WorldObject functionality.


Message UI

The Message UI is a multi-purpose screen for displaying character dialogue, random events, or system messages. You can see the first of these in the video above.

Each message packet can contain a custom icon, title, subtitle, description, and unlimited button options.


New Textures

update69Scene.png

The picture above contains most of the art assets completed this week. I’m very happy with how they all look!

Tiles:

  • Wooden fences (16 tiles)

  • House (42 tiles)

  • Stone paths (22 tiles)

Objects:

  • Flowers (3 textures)

  • Mailbox

  • Signs (3 textures)

Items:

  • Token (currency)

  • Coal

Also, here’s a video of a bouncing house. It uses a tile layer and is attached to a LayerObject. This gives it similar functionality as a regular world object. Once I make some changes to collision physics, the house can be allowed to be pushed by other game objects.


Current Goals: A few more object and tile textures, character code, pathfinding, crafting recipes.
Future Goals: Pause UI (simple overlay), escape key UI.

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

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.

potStorage.png

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

spatial.png

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.


ObjectShape

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

Update #67 - Crafting, Chatting & AI

Hey, how’ve you been? As I surge ahead with Merchantry, it’s getting so much better.

  • Merchantry: Fixed the ObjectAnimation states' Initialize action not being called.

  • Merchantry: Changed WorldObject's UseObject() method to LeftClick() and RightClick().

  • Merchantry: Added a basic character class, which all characters (PCs and NPCs) will derive from.

  • Merchantry: AI now makes use of priority checking (as a float). The highest priority goal is the current goal.


Crafting

I’ve got the foundation for crafting in place! It’s very functional, just need to do a little bit of polishing. While I hoped to use Aeta UI for this interface, I ended up coding some new classes just for game world UIs (Element, ButtonElement, ImageElement, ItemSlot). All world UIs derive from UIObject, which then derives from WorldObject. Let me walk you through how crafting in Merchantry works.

craftingZoomedOut.png

Pictured above is the crafting table, as viewed from the perspective of the player (ignore the doggos). Clicking on the crafting table will zoom up really close, allowing you to use it properly.

craftingZoomedInA.png

The UI is intentionally positioned on the right-side of the screen to make room for the inventory, which opens up on the left. Currently, the crafting table has similarities to how Minecraft handles it. Drag your items onto the grid, and if the item placement matches a recipe, the red “X” changes to a hammer. Clicking the button will create the item(s), placing it into the output slots below.

craftingZoomedInB.png

Now you can grab the items and put it into your inventory. Nice job! One important distinction is that the UIObject contains its data, so walking away (exiting) from the UI won’t force the items out like in Minecraft. I’ve placed items in it, exited out, and starting pushing the table around. I really enjoy how connected this UI feels to its world.

Even though its used for crafting, I can easily create different UIs. An anvil for reinforcing/repairing tools and armor, a furnace for smelting ores and baking food, etc. All I need is the object’s texture, position the elements, and set up recipes to match the slots.


Chatting

aarf.png

Nothing too fancy or much to say about it, but it gets the job done. Each object has it’s own ObjectChat class. This is where all of the important chat data comes from. While you can send a string directly, the best way is to add a a string with a key. The key is called, and a random message is sent. Fairly helpful!


AI

In Merchantry, AI is goal-oriented, making use of a float for priority. The highest priority goal is focused on first.

In this example, the dog has two goals: Follow, and Rejoice. Follow’s priority is calculated by the distance from the player, and Rejoice’s priority is at a fixed value. If the player moves too far from the doggo, he’ll move towards the player. When he reaches the player, he celebrates by jumping and barking.

I may need to make some tweaks in the future, but it works well.


Final Words

Current Goals: Polish existing features, various world textures, object selection code, character code, pathfinding code.
Future Goals: Pause UI (simple overlay), escape key UI, message UI, dialogue 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

Update #66 - Context UI, Item Transferring, Tile Layers & More

Hey, how are you? I’m going to be with family on Friday, so this week’s update comes early. As you’ll see, I’ve got quite a bit of small, but important topics. Here are the minor changes:

  • Aeta UI: Renamed "IsMouseHover" to "IsContainsVector", adding a Vector2 as a parameter. More freedom!

  • Aeta UI: Added two useful methods to UserInterface. ContainsElement(Vector) checks for any elements containing the vector, whereas ContainsBackground(Vector) checks if any clickboxes contain the vector but no elements contain it.

  • Aeta UI: Renamed ActionQueue to TimeQueue, and cleaned up the code in that class.

  • Aeta UI: TimeQueue is now public. If you have a sub-class that needs to make use of the instance, it now can!

  • Aeta UI: Removed all methods relating to TimeQueue from UserInterface.cs. It makes more sense to call the class directly (Queue).

  • Aeta UI: Some variables in Camera now have default values.

  • Aeta UI: Added Max*Speed variables to Camera, where * is Move, Scale, or Rotation.

  • Koah Particles: Completely changing everything about how this is structured, replacing "Emitters" in favor of a ParticleManager.

  • Aeta UI: Completely removed the "Clickbox" class used by the UserInterface class to check for mouse clicks, replacing it with good ol' rectangles. Same functionality.

  • Aeta UI: Added OnResize event to the UserInterface class.

  • Website: The Community page now has a working link for the Discord invitation.


Art Assets

DqNwBnxWsAEV0ym[1].jpg

I’ve done a bit of work on textures. Mostly fodder, but it looks great. The blue pots were inspired by the ones found in Wind Waker, with the green being “earth-like” copies. The grass is nice, too!


Context UI

Pictured above, the context menu is opened by right-clicking an element (such as an item). In this case, it lists up to three item-specifc buttons, plus an option to get rid of the entire stack.

Similar to the Tooltip UI, I’ll set up a variety of different layouts for various situations.


Item Transferring

Shown above is the fluid transition of an item from the inventory being dragged into the game world. The improved particle engine and basic object physics are very noticeable, too!


Tile Layers

Tile layers are a simple solution to displaying the game world, primarily images that have little interaction and movement.

Each layer uses it’s own matrix for positioning, as well as it’s own rotation and scale which go into the matrix. This allows all tiles in a layer to move in unison. This functionality is pointless for backgrounds (like a grassy field), but great for things like large gates and towers that need to move.

Also, I’m using sheets for textures instead of individual images like I did in Pilgrimage of Embers. It’s much easier to manage a small collection of logically-named texture sheets (biome*Grass, town*Structures, etc.) instead of a few hundred images for a map region (grassCornerTL, grassEdgeLeft, etc.).


Final Words

Current Goals: Crafting UI, more world textures and code, character art style.
Future Goals: Pause UI (simple overlay), Escape key UI, Message UI. Simple character textures (pre-alpha).

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