Smalltown Grocery – DevLog 2

This week I’ve managed to come closer to terms with my limitations.

While trying to prototype grid-based pathfinding (using the gamemaker mp- and path functions) I have realized I will not be able to use small sized walls (4 x 4) in conjunction with larger objects (32 x 32).  When I tried it, the customer would travel too close to objects, overlapping them.  Plus, it causes major headaches when trying to map out a grid, having to adjust for the 4 pixels of the wall then start counting by 32′s again.  It’s probably do-able, but not by me!  No, thank you!  So I’ve determined/decided that a 32 x 32 square will be my grid cell size.  Thereafter, all objects will need to be placed so that the unused cells will allow for pathfinding.

Many of my shelves (Produce, Cold Cases, Freezers, Dairy Coolers) are 32 x 32 and they will work fine, as long as I don’t double park these on two or four different grid cells.  I must make sure they line up with the grid cells perfectly when I create the store layout for the game.

The regular store shelves are 32 x 16.  These are a little tricky.  I need to make sure the fronts of these shelves are adjacent to an open cell, otherwise they won’t be reachable by the pathfinding.  This leaves me with a slight dilemma of unused space behind the shelf if I want to put these against a wall. (You can see what I mean in the gif below.)

I found some graph paper and began scrawling out a level.  This was a good move on my part because it helped me begin to visualize what I was wanting to accomplish a bit better.  On graph paper, I mapped out an entire store.  But right now, I just wanted to figure out pathfinding from shelf to shelf.  A small prototype room of walls and shelves and a customer is what I need.

So, after throwing out a bunch of code and starting over, I was able to make a small (un-animated) prototype of a customer wandering to randomly chosen shelves, grabbing an item, then moving on.  Not great progress, but progress nonetheless.  Baby steps, man, baby steps.

The numbers on the shelves represent the amount of items on that shelf.  The black dot is a debug item I made to show the intended destination of the current path. (The coordinates were off a bit at first, so this was how I helped myself to see it better, along with the debug text at the top-left.)  The way it works is — it finds all the available shelves, randomly chooses one of them, finds the grid cell coordinates of the open grid cell in front of the chosen shelf, and then creates the path to those coordinates.  There’s a delay between paths with a toggle to grab an item from the shelf at that location.

After putting this together, I’m contemplating how to give different shelves (items) popularity factors.  With a high popularity factor, that item has more of a chance to be chosen as the next path destination.  I’m debating whether to give the shelves item types also (canned food, baking goods, pet food, etc).  This also gave me other insights as to what sort of stats I’ll need for the customer.  Stuff like:  number of items needed, perhaps types of items (produce, dairy, meat, etc), and customer satisfaction (if a desired item is unavailable).  I’m really going to have to give this a good, healthy think.  I don’t want to get bogged down in a bunch of unnecessary features, but I don’t want it to be too generic, either.

Looks like I’m going to have to get serious about writing out some game design elements and features on paper.  I’m pretty sure that is my next step, as I can’t really write code for features and ideas that are not fully formed.  :P


Leave a Reply