Gamedev blog 4: The world

in #gamedev7 years ago (edited)

It's time to get down the business. As I progress, I'll talk more about technical stuff. I'm not going to teach any actual coding here, but I'll gloss over some technical concepts as I tackle them myself. I will link to any material I use to learn, so you can too!

The birth of a world

Well, ya, that title is a bit bombastic for what I'm doing, after all I'm simply going to generate a bunch of connected rooms. Still, it's the world in which the player character is going to live, so it is very important.

During the incubation period of this game, I already had some ideas about how the world would look. I know the world will be split into rooms. I know that more that one entity can be in a room at any given point. I immediately thought about a grid, and then naturally concluded some rooms may be bigger than 1x1. Furthermore, I thought it would be interesting if some rooms could connect through shortcuts rather than doors, allowing the player extra maneuverability.

Here is a sketch of what a world might look like:

As I start thinking about generating a map like that, I immediately realize this is too much for such an early stage in the project. This requires procedural generation, and storing all this information. I decide to make something much simpler, and develop it further at a later stage.

I opt to have a fully connected grid, which only the outer wall completely blocked off. Since I already need to make up a few tiles, top-left corner, top, rop right corner, etc. I decided I might as well get a full tile and pick the tile using bitmasking. Bitmasking is a neat way to store a tile atlas, and you can find countless tutorials on the subject, here is the one I happened to stumble upon.

I generate my tile atlas, based on the article, which is much faster than figuring it out on my own, and then store the grid in an array, simply checking if for edges and marking them as such, storing the tilemap value in each spot in the array. Not the prettiest code, but we want quick and dirty at this stage.

After that, it is simply a matter of adding a player sprite, and running the script. Since I used my roguelike core as the basis, it works out of the box.

World - Done.
Player - Done.
Controls - Done.

Next on the list, add enemies, so we'll have something to do!

If you missed the previous posts:
Gamedev blog 1: Brewing an idea
Gamedev blog 2: Birthing pains
Gamedev blog 3: It’s checklist time

Sort:  

nice gamedev post :) was actually nice to read and its alsoo nice to see some more unity users here on steemit. Got my like :P unfortunately i dont have enough steem power to affect your payout :o

Thanks.
This is also a post from a month ago, so the payout has already popped and you can't add to it anyway.

Welcome to the fold.

Though it's been somewhat abandoned, what did you mean by shortcuts? I only see doors in the original image.

And now our grid only has all the rooms be equal size. Hm. Is it actually easier to work and then rework the prior setup, or do you just go forward and the "rooms can be larger" just got axed for now?

Shortcuts are a way to move between rooms that are farther apart, like a trapdoor and a tunnel or something. It can be added later if I choose to, though it might cause a mess with the pathfinding.

Making rooms of various sizes requires quite a bit of code, and what I did right now barely requires any. What I have now is a 2d array that stores the bitmask, though it could just as easily be just 0 no room, 1 room. It is a nice feature to have, and may really upgrade the look of the world, but it is not necessary for gameplay, so it's pushed down the the bottom of the feature list.

Though it might cause a mess with the pathfinding.

Considering how often pathfinding woes are brought up as an issue, even in AAA games, I can only imagine.

Can more than one entity be on a cell?

Yup, that's why they are room.

Great gamedev post~ RT'd

Coin Marketplace

STEEM 0.15
TRX 0.12
JST 0.026
BTC 56787.81
ETH 2507.96
USDT 1.00
SBD 2.24