Storage solutions

Right – time to drag myself a little more up to date here. In the last post I’d introduced my “Harvest-A-Moon” game and basically said how I’d realised the game seemed a lot smaller than I first feared, and that the major issues were things like animated characters and enormous amounts of GUI. In this part I start by trying to tackle that second bit.

So, I’d made a start on the inventory system with the quick inventory (the bar of heads-up display that sits at the bottom of the screen and lets the player select what they currently have equipped easily). This is just the beginning. I also need a main inventory (what the player can carry essentially), a storage inventory (often dealt with by crafting storage chests and the like in games like this), and a shipping inventory where you can put all the things you want to sell.

I decided I’d try to work towards getting these up and running ASAP, but then there comes the realisation that this involves actually having stuff to put in the various inventories. This is actually kind of annoying. Here I was trying to get the dull stuff out of the way instead of creating lots of fun content, when it turns out I actually need the content, to do the dull stuff properly.

So I decide to quickly cobble up a load of tools for the player to use. I’ve got so very many ideas for the game at this point, it’s quite tricky to decide which tools I actually need in some cases, but after a bit of deliberation I decide upon the following roster: mattock, shovel, axe, scythe, water and fishing rod.

There are a few things to note here. First and foremost I’m picking tools that will probably be needed without really knowing what the full scope of the game is. I’m unsure about the axe right now, because at this point I’ve not got space-trees in what I’ll laughingly refer to as my game design (not ones that need axes anyway) and don’t know if lumber will figure in any way at all. I’m also choosing tools that have good, and properly agricultural, names. I could refer to the mattock as a pickaxe, and the shovel as a spade if I wanted, but the words I’ve used have a weight and heft to them that I much prefer (I’ve avoided Hoe because it’s not that useful, and also a fairly cheap homophone gag that I don’t really need).

Also, and this is something that may or may not happen (because I have two conflicting ideas for how the game should “feel” right now) – these names conflict amazingly with one idea for an upgrade path. Historically, Harvest Moon style games always allow you to upgrade your tools – copper axe, iron axe, steel axe etc. But my game is set in space, so I’ve got great options. So by picking properly rural, down-to-earth, names for my tools I can slam them against an upgrade path of things like “laser” and “plasma”. “Laser Mattock”. “Plasma Shovel”. Those are tools that will get the job done! As I said – this bit’s not definite, but I like the names – and that massive contrast is a part of this.

Finally on this point, I referred to the watering can object (very traditional in HM-style games) as simply “water” above. As much as I like the contrast, as much as I like the idea of this being a mid-west farm in space, I cannot reconcile the idea of humans having colonised other worlds and yet them still using watering cans. Axes, yes. Watering cans no. So for now it is just called “water” (at the moment I’m thinking it might be a water tank backpack with spray gun thing, but haven’t got a name for that yet).

So with the tools in place I then look to adding just enough items to stress test the quick inventory bar (it can hold 8 items, so I need 9 or more). The planting of the space radish mentioned in the previous post was fudged in before, done on a key press – so I make the seed bag a proper object, and then make the harvested space radish another. We’re almost there. To expand my crop-growing script I decide to introduce a crop that can be harvested multiple times too, so add a space bean seed item and also a crop item too. I then implement that re-harvestable mechanic as well, because it’s really quick and easy. Now I have enough items to be problematic, so I just need to crack on and get the inventories sorted. And I kind of do – a bit.

I knock up another inventory system first – the player’s backpack essentially – what they can carry on them. In most games of this type this will start off small and be upgradeable to a bigger size (possibly several upgrades). This seems – hmmm – contrived, to me. Here’s the thing. I started playing video games before upgrades and power-ups had been invented. The one thing that’s really easy to spot for me is when you’ve been started off in a game under-powered or under-equipped simply because the designer wants to palm off something you should have had from the start as an upgrade. It’s like the first speed pick up you collect in Gradius – “Gee! Thanks! My ship now almost moves at a speed that allows me to play the game properly. Thanks for nothing.” So basically I’m thinking your backpack stays the same size, and right now this is it (could get larger if I think you need it):

Anyhow, implementing this makes me realise that you obviously need to swap items from your quick inventory to the main inventory, and that will be easier if the quick inventory is directly underneath the main one. I dismiss out-of-hand the idea that the quick inventory should move into place, and simply make a new one that sits underneath the main menu. When you open your inventory the code hides the original quick inventory, moves everything from it to this new temporary copy, and then lets you use that instead. Much easier. (One thing to note at this point is that I’m using keyboard/pad controls – I’m going to have to do this all over again with mouse controls which sounds like a royal pain-in-the-arse and something I suspect I’ll be dodging for a long time to come).

Next I wanted to add a storage inventory. Again, often these are a bit arse-y in these games. You usually have to craft chests to store things in, and then slap them all around your home to hold all the stuff you’re accruing, and when you run out of space you have to find the bits you need to build a new one, and then find somewhere sensible to place it, before you can do anything. I’m thinking one central storage facility that will hold absolutely everything you could ever possibly own is a good start point. I can foresee issues with it, but they seem minor compared to the alternatives.

But to have a storage inventory I need somewhere to place it, and right now I want that to be in the players house (because they need to access it for cooking and crafting and when they can’t go outside, which are all things I have plans for). So then I make a quick room out of blocks and cylinders that holds the things I currently think the player wants (from left to right – a computer (comms), a workbench, a kitchen, the ladder to the surface, the storage unit and a bed). I then quickly make it so you can go from the surface to the bunker and back again, and then also make it so that you can use the “storage” object to access a new inventory, and start implementing that.

This inventory is slightly different again, because now you need to be transferring between the storage inventory and both the other inventories. So this will work the same as the main menu only more so. It has copies of both the main and quick menus in it, so when you access it, it will copy the content from the real ones into its temporary ones. And this is where I got to on this. The menu is laid out and ready for me to finish off the code. It looks like this, so far (not sure what’s going on with the lighting here – the light in the scene seems to be affecting the GUI):

And now I’m much closer to being up to speed on this blog. Writing it has made me realise that I got a bit more side-tracked than I’d hoped and there’s loads more stuff still to do to get the inventories up to even basic functionality still, and that will have to become a priority once more. My next post will start off being about writing a fishing mini-game though, because that’s what I was doing just before I wrote this. Space fishing! Something I’ve wanted to make an entire game about before now. Now I’m just adding it in as a mini-game.

And Now For Something Completely Different

Hello. It’s been a while – and to be honest I’m forcing myself to write this now, because otherwise I’ll have too much catching up to do. First up – as the title suggests, I’ve moved on to a new project. I did do some more work on International Road Bastard, but hit a point where I wasn’t sure about it. I added physics to all the other cars for starters (which they needed if they were going to fly up in the air and get pushed off cliffs etc.), but that stopped them doing their nice “spinning wildly out of control” thing which made the game much less fun. I’d need to code that back in, and that’s part of the issue. Things were starting to look like a lot more work (the player’s car needed to be done properly too for example), and at the end of it all I could see is a silly little game – fun, but ultimately quite throwaway, and that didn’t appeal.

Whilst this was happening I’d been playing My Time At Portia – a nice (if unfinished) Harvest-Moon-ish game with a focus on building, rather than farming – and it got me thinking about something I’ve had at the back of my mind for a long time now. Harvest Moon in space (very literally Harvest A Moon). Before now I’d always dismissed this out-of-hand as being too big, but I had a few days off and didn’t fancy trying to wrangle Road Bastard into shape, so I thought I’d just have a pop at it, to see where it went. I had a head start from another work-in-progress project – a moon base simulator – which gave me a curved world (which I wanted) and a nice little landing pad with rocket that would set the scene nicely.

So I copied this project, ripped out a few bits that weren’t needed, and then knocked up a crude astronaut character from Unity’s spheres and cylinders. Then I also knocked up some crude models of several stages of growth for my first crop – space radishes. I quickly implemented this, which gets us to here (those radishes grew from a planted seed, and through 4 stages of plant before fruiting):

At this point I came to a realisation about the game – it doesn’t seem anywhere near as big as I’d assumed. I mean – there’s a lot of peripheral stuff in most HM-style games, but when you cut to the chase it’s largely inventory management over time. You have stuff in your inventory (seeds and tools etc.). You use tools to prepare the ground, then plant seeds. Then you wait for a while, before harvesting them to get crops in your inventory. Then you store them, or sell them, or combine them with other things to create different items in your inventory. That’s the core. Add in animals which are similar, mining, foraging and fishing and you’ve got most of the good stuff. Then it’s just a case of what else you add to bulk out the package. This realisation gave me renewed interest in carrying on with the game and the ideas came thick and fast (it’s genuinely one of the most fun things I’ve worked on – so many neat ideas…).

At this point I took stock though, and tried to think what the big issues would be. Clearly, the fact that the game revolves heavily around inventory management means that there’s going to be a lot of GUI work, which is something I try to do as little as possible of. There’s a lot of learning needed here, and that’s not something I take to well (I love accruing knowledge, I hate having to sit and read documentation or watch over-long tutorial videos for hours when I could be making cool stuff instead). The other major issue is going to be character work – I need animated 3D models for the player, livestock and any other NPCs I use. This is stuff I’ve done passably in the dim and distant past, but again – there’s a lot of learning involved, including finally using Blender (which I’ve had installed for ages, but have been trying my best not to go near wherever possible – hence using Unity’s primitive shapes for everything so far). However it’s certainly doable, and if it turns out I’m not up to it, I could always consider getting a decent character modeller/animator to do these bits for me (I’d be reluctant though – I really like being a one-man team).

So, to cut to the chase the game seems pretty achievable, and I’ve got more ideas than I know what to do with, so I just crack on. And because I’ve identified inventory is the key to the game, I’m forced to address this right away. I’ve never incorporated a proper one in a project before now, so I have a quick google, and find a Unity tutorial that gives me a good start point on both how to manage an inventory, and also some pointers on working with the GUI for it. So I quickly cobble together a makeshift quick inventory for the player, with some very rough placeholder artwork:

And then I immediately decide that I’m an idiot, and should replace the artwork for something that won’t make me hate the game. So I redraw the item slots as something halfway competent, if a little bland, and that looks – if not good – then a lot less rubbish:

And on that note I decide to have a crack at changing the way the game looks, because this is straight from my moon base prototype. I’ve not got a clear idea in my head yet of an art style, but I know what mood I’m after, so I have a pop at pushing it that way. I also add a few basic buildings to set the scene – which is basically an American mid-west vibe, but in space, so there’s a windmill and a water tower. The player’s house I decide is going to be a bunker under the ground, so that little cube is just the entrance. Which brings us to here (this is by no means final, but it’s much closer than old pink-world up there):

The final thing I’ll cover in this post is the curved world thing. The way it was implemented in the moon-base prototype was as an actual curved world – the map was actually part of a sphere. I soon realised that this is a horrible way to do it (unless I’m missing something obvious – which isn’t unlikely, admittedly). But basically I found that the easiest way to move the player’s character around on the outside of a sphere is to simply rotate the sphere (and everything on it), whilst keeping the player stationary. If they move forward you rotate the sphere toward the screen, if they move right you rotate it to the left etc. This seems simple enough, but doesn’t work for other entities though. So if you want an NPC to move between two arbitrary locations on the surface of the sphere it’s a right palaver. What I ended up doing was temporarily rotating the entire world so that the NPC was at the top, then spinning everything around the vertical axis so that the NPC was facing the thing they wanted to move towards. Then I could set them to rotate forwards around the sphere toward the target using the sphere’s centre as the pivot. Then I’d rotate the sphere back to its original orientation, with no-one any the wiser. It’s one of those things that you realise is utterly insane whilst you’re doing it, but then follow it through to the bitter end out of morbid curiosity.

Basically, that had to go, so I had a quick search on the Unity asset store and found a nice shader that performs some kind of wizardry to create the effect for me. The world now is actually perfectly flat, everything works as if the world is flat, it just ends up looking curved in-game. This is what the place looks like with the curvature set to zero:

The other benefit to doing it this way (other than not being hideously-unworkable obviously) is that I can alter the curvature without having to change, you know, almost everything else in the game (seriously, you’d have to remodel everything for starters, and then all rotation speeds would change and, crikey… it would be a nightmare. Whereas with this I can just type in the figure “30” to make it do this:

Right, that’s the lot for now. I am playing catch up with the blogging, so the next post hopefully won’t be too far off.