Friday, April 26, 2019

RTS_11 "Resource Production Buildings" (Stream - Part 2/2)

Probably one of the most important gameplay features is here! The game now supports resource production buildings. That means I can now get started on all the buildings that produce a resource such as farms or housing or mines.

Right now there are 2 different kinds of resource buildings:

Normal Resource Building
This is a resource building that produces one of the 3 standard resources (Production, Strategic, or Luxury). This includes things like food, wood, or silk.

City Resource Building
This is a resource building that produces a resource that only cities can use such as housing or entertainment.

The reason this distinction is important is because normal resources are added to your city's stockpile every turn whereas city resources such as housing are only added when the building is first built and removed when it is demolished.

Now with that feature here, I've added two official buildings to the game

A farm which produces 2 food per turn:



And peasant housing which provides 2 housing to the city

[Picture of peasant housing]

Another big step forward, I think it'll be a lot of fun coming up with unique buildings for cities and workers in the future. In the next update, I want to try and get to unit spawning!

Sincerely,
Blake Gillman

Monday, April 22, 2019

RTS_10 "New Map Graphics & Features" (Stream - Part 1/2)

The map has come a long way from looking like neon green 2D squares to the polished 3D look it has now and I was actually pretty happy with it. But then I posted it to a discord server for some feedback and boy did I get a ton. The main feedback ended up being just how bland and empty it was, so when I started up my game dev stream I said first and foremost my goal was to work on rendering & graphics, and so I got to work.

First, the camera angle is now 55 degrees instead of 75. This means that the camera is a lot less top-down now giving the world a more 3D look and feel. You'll be able to see this in the screenshots.

Trees have a completely new look and style now. Instead of just being simple dark green triangles like they were before they now have full tree models.



This update has fixed several problems that trees used to have before. If you looked at old updates you'd notice that the trees near rivers were smaller than the ones on grassy tiles, this was due to how the visual had to be scaled. But this new tree model system fixes that so that trees between hexes are completely seamless.



Light Trees
Light trees are the first in a new category I call Hex Visual Features. Normal hex features are things that affect gameplay like a forest or a hill, but visual features are just things that are there to add detail. Light trees can spawn on grassy tiles (that don't already have a forest), and serve to add detail to the otherwise plain hexes.



The next thing I did for map features was something that I had been planning to do for a while but didn't expect to do this early on: Mountains.



I'm really happy with how the map is looking now, and I think it's definitely looking a lot closer to how it'll look finished.

Also, side note: I believe I fixed all currently known bugs in regards to map culling, so chunks should no longer disappear/reappear while still within sight like they did during the stream

Sincerely,
Blake Gillman

This update was broken up into 2 parts because it was done over a single stream of non-stop intense development, and I'm on burnout so I need some time to recover. To give myself that time I decided to break the update into 2 parts so that it's spaced out. I also will probably be extending my schedule to post an update every 4 days instead of every 3 since work has kept me a bit busy to be able to push an update every 3 days.

Friday, April 19, 2019

RTS_9 "Building inside of cities & Map Culling"

Optimization has been one of the biggest priorities for me when making this game. Freeing up GPU & CPU allows for more advanced AI, more units, more cities, more complex maps, just more and better stuff in general. That's why it took me reprogramming the map render/generate system 5 times to get it to where it is now.

As it already stands the game is well optimized with my GTX 970 running at 95FPS on a 128x128 map. But that's still not good enough so I decided to implement more optimization: Map Culling.

Something you may not realize is that by default your graphics card wants to render everything in a scene, which is obviously bad since there's no reason to render something going on a mile away. This is why modern games use occlusion culling to inform the camera what the player can see so that they only have to render that and not the objects behind them. This is great for games with pre-built levels, but I wrote my own system for generating & rendering the world which means I don't get the luxuries that pre-built systems have.

So I wrote my own version of occlusion culling for the world that tells the camera to only render chunks it's looking at, here it is in action:



I'm absolutely thrilled with how this turned out, it's got a few bugs but overall it definitely helps improve the performance of the game. By how much is debatable since it depends on the map size you're playing on as well as where on the map you're looking, but multiple tests on it have determined that it reduces the number of vertices the camera is drawing by 6~40%. That's a big range I know but given how many different map sizes and ways maps can look it's understandable that it can't just be a simple answer.

Now a 6~40% reduction in the number of vertices the camera has to draw is significant but that doesn't necessarily mean 6~40% more frames. As for how much it actually helps your overall FPS, I've been unable to accurately determine, but it's definitely lightening the load of the GPU and that's what matters.

Now with all of that optimization mumbo-jumbo out of the way, let's talk about gameplay.

In the last update, I introduced a ton of information all at once such as stability and different happiness factors like crime or housing. Allow me to expand on these concepts a bit here and to explain a couple things I hadn't before.

Building Slots
Land is limited and hexes can only support so many buildings. You can only build so many buildings on a single hex which means that you have to use your space wisely. Right now the rule is 3 buildings per hex but this may change in the future.

Expanding a city
The spot you found your city is only the main grid of the city, everything you build is built on the hexes around that city. However you can expand your city by building more city blocks on hexes, but those hexes can't already have a building on them whatsoever. This means that in order to expand your city outward you'll have to set some land aside with expansion in mind.

Food Consumption VS Food Stockpiling
I had forgotten to mention the little slider below the main city UI. This slider determines how much of the food a city produces should go to consumption or stockpiling. Consumption means that the produced food instantly is consumed and goes toward increasing the population of the city, while food stockpiling is food that is stored to feed the currently existing population.

In my formula about stability, you'll notice that food happiness means that you need to have food stockpiled for your citizens to eat instead of having it all go toward more population. But having food stockpiled isn't just good for happiness, but if you have too low of food your population can actually start to starve and you can lose population.

More importantly, you can be cut off from your production of food. If for example your city is under siege by enemies your city could end up being cut off from its farms, so having a large stockpile is smart otherwise an enemy army could end up starving your city out resulting in its surrender.

This means that food is not only important for city micromanagement but as a war tactic as well. Your city can only hold so much food though, which means you'll also have to build stockpiles which take up precious building slots, so it's definitely a balancing act.


Wow, that is a lot of information to drop on you suddenly but it was necessary for you to understand in order for future updates to make sense. A lot of this is planned and not implemented (For example that slider doesn't yet actually effect stockpiling or anything) but it's just important to note.

And so now finally, all concepts and everything aside here is the main gameplay feature of this update: You can now build buildings on the hexes around a city:



Currently, there's only one test building that's being used for this, but with this feature, it means I can now start getting to main feature buildings like resource production (farms) or unit spawners. Right now you can only build 2 buildings at a time, which I don't know if I'll keep or not.

This is a big step forward for future updates. I hope it wasn't too much to take in!

Sincerely,
Blake Gillman

Not so fun fact:
I have to actually edit a cursor on to the image when showing the user hovering over something because pressing "PRT SC" (Print Screen) doesn't capture your cursor.

Tuesday, April 16, 2019

RTS_8 "Cities, Workers, and UI"

Believe it or not, half the time I spent on this update has been on the UI. Determining what the City UI & other UI will look like has been a big part of this game with many many hours spent designing and getting rid of various designs. I find that it's very vital that in order to work on something that I'm able to visualize it or have a general sense of what it'll feel/look/play like. With city's, this was very difficult because I hadn't exactly pinned down how I wanted them to operate, and after I did, I find it even more difficult to determine how that information would be displayed.

The best UI design I have found are systems that work off of a max of 2 clicks to do what you need to do, otherwise, it begins to feel cluttered. I learned this from playing different games and trying to determine what made some games feel more complicated than others, and it usually ended up being that standard actions took more than 2 clicks to do. Even if the systems themselves were less complicated than other games this gave the feeling of complexity.

Some examples of this smart design in some RTS games that I play are:
StarCraft II
Planetary Annihilation: Titans
Sid Meier's Civilization V

In all of these games, the user is generally only 2 clicks away from most core actions. Want to build something? In all of these games, you select the worker, then select what you want to build. The same goes for attacking, moving, and building units from buildings. This smart UI is extended even further with most information being displayed by placing your cursor over things rather than having to select them.

So with this newfound observation in mind, I decided to make sure that my game follows it. First and foremost that means that units no longer can select tiles in every direction. Selecting the tile, then the hex, then the building broke the 2-click rule. Now the buildings available to a unit display on the tile they're standing on as icons, and if you hover over them you can read the info on each one.



But with this new system brings up a question: Okay but rivers can't be walked on by land units, so how can workers build bridges? The solution was very straightforward, the worker can still build bridges on surrounding tiles, and the icon for doing so will show up on said tiles:



Hooray! So now workers fit within the 2-click system, which means that the game is once again simple and user-friendly. With that out of the way, I was able to continue my working on cities.

As I had said, the UI for cities is what took the longest as most of the code for cities I had already written, so here it is!



As you can see there are some systems in there that I have not yet explained.

Stability
The stability of a city is essentially the happiness of the city, the happier the citizens are the higher the stability the city has. Stability is based on 4 factors: Housing, Entertainment, Crime, and Food.

Housing
Citizens need somewhere to live, and unlike civilization new houses don't just appear out of nowhere! You have to make sure that you have at least as much housing available as population in order to keep happiness up.

Entertainment
Believe it or not, citizens like to do things other than work and serve you. An entirely work-based civilization tends to overthrow its leadership more often than not.

Crime
Pretty self-explanatory, unhappy people with no hope can turn to crime, and crime makes people unhappy with no hope. It's a vicious cycle. The best way to avoid crime is to keep your citizens happy in the first place, but if crime is already a problem then building things to stop it is a good choice.

Food
Although food is used to increase the population of a city over time, it also has to be abundant enough to feed the citizens who are already there. The happiness of food will be at 100% if you have at least half the food required to get to the next population.

With all of that in mind, I created a formula that is used at the end of every turn to determine the stability of every city:



Great! Right now there are no effects from having high or low stability but in the future, there will be such as increased production times as well as possibly spawning riot units.

As you can see, buildings will now also play a very important role in doing more than just spawning units or gathering resources. Having a large productive city also means you have to invest in a larger infrastructure for keeping your citizens happy. This gameplay element was inspired by Stellaris, and I think that'll help make cities feel more alive.

As for building inside of cities, it's not currently in the game but it's what I'm aiming to have finished in the next update, so stick around!

Sincerely,
Blake Gillman

P.S
This update is coming after 7 days instead of the usual 3~4 because it took so long to do that I needed some extra time to catch up and write more posts. But after this, it's back to a regular schedule!

Wednesday, April 10, 2019

RTS_7 "New Terrain Feature & Weather"

Well well well, I said that I would work on military units or roads, but...


First of all, in my quest to continue to make the game more detailed and polished, I've added a new terrain feature: Hills.



Hills are just land ridges. I had actually intended for them to be in the ridges update but the visuals weren't rendering correctly so I had to hold it off until later.

But that's not the real meat of this update. No by far that would be the feature that no one (not even me) expected: Weather!



For balancing weather doesn't appear until turn 9 so that players have the opportunity to settle cities & start work before being affected by it. Then every 4 turns it moves so one person's storm could very well move and hit another player.



This feature will add a *TON* of new gameplay opportunity. It helps to add that bit of randomness to the game that I think will help keep players on edge. Because of the moving weather system, it also means that players (if they have sight) will have the opportunity to see weather coming in-advance and brace for it. This will help make it a bit better to know that it's coming.

Sadly, however, the weather system so far has been a bust. I'm including it in this update because I may eventually bring it back, but for now, it's too expensive on CPU & GPU to be worth adding. When the weather is generated players see generally a 50% frame decrease which is far too steep for me to be comfortable making it a core feature. So until I can solve this, it may or may not be in the final game.

That's all for this one, I'm hoping to get something bigger to you guys soon, I promise!

Sincerely,
Blake Gillman

Sunday, April 7, 2019

RTS_6 "Workers, Buildings, New Terrain Feature & UI Improvements"

First of all, I noticed in the last update that trees were floating over shores, but I'm gonna go ahead and add that to the "So minor, I need to focus on other stuff" pile next to the cracks near rivers lol.


In the last update, I added bridges & trees which looked really nice but I made a very bad mistake in doing so. You see I added both as being a 'feature' of a tile, but that was silly because a bridge isn't a feature it's something someone has to build. So I've reworked the system so they are now separated, features include things like trees or if the tile is a hill, whereas buildings are additions to the tile that has to be built.

With that distinction, I've added bridges to the game but now as a building and not a feature. And what better way to test out this new improved system than by having our newest unit be a worker?



Right now bridges are treated like any other building (given a random position in the tile), but I'll eventually change that. It'd be reasonable to ask how this worker was able to build a bridge on a hex that it's incapable of going on. Well, that's because in this game workers can build hexes on the tiles around it, not just the ones they are on. I think this will add a new interesting aspect to building in general.

I've also added a new visual for the city & reduced the size of the city bubble above it:



Now, I really want to continue to polish and add detail to the map so I've added a new feature to the map: Ridges.




Not only will this help add visual detail to the map but it will also serve a good gameplay purpose. A ridge will give defensive buffs to units on them and also cost extra movement to move on to. This is how hills will also act (but on land) when I get around to adding them.

Next, I want to work on roads and maybe even adding in a military unit, we'll see!

Sincerely,
Blake Gillman

Wednesday, April 3, 2019

RTS_5 "Forests, Bridges, Cities"

In the last update, I updated the engine to a new polished look and so I thought I'd keep that train moving! First thing I wanted to work on was trees:


You'll also notice the map is brighter! 50% brighter to be exact. I think this increased look will help reduce the melancholy feeling that the map used to give off as well as exaggerate the colors for a more cartoony look.

Next up I wanted to work on bridges:



Unlike in Sid Meier's Civilization V rivers aren't between tiles but instead take up entire tiles. This means that units can't cross rivers without a bridge. This is now also reflected in pathfinding where units will avoid rivers entirely now.



As you can see the unit will only cross where there is a bridge, and if there's no bridge the unit won't be able to cross at all. I've also slightly changed the way the unit icon renders.

That's already a lot to take in, but I'm all about rapid progress so I've got even more up my sleeve! This first unit was a settler because I wanted to be able to work right away on: Cities!



Right now cities have a visual, a UI which displays their name, health, and defense, and claim the territory around them when they are placed. They don't do anything more than that at the moment, but it's a great start!

In the next update, I want to work on creating a worker unit, so we'll see how that goes!

Sincerely,
Blake Gillman