mandag den 29. oktober 2012

Water!

So I finally came around to doing water... This was quite the battle, but I consider the results a success. I still haven't decided if the results will be the final version that will be kept in the game, but for now I will keep it there.

What's New?

Here's the list of changes since last time:
- Water has been added.
- Hunger and thirst has been added (Currently only affects the indicators on the GUI)
- Save/load algorithm updated to support water.
- Stone and stone wall has been added (Though the stone wall graphics are temporary)

Water

So the biggest thing added this time is water. Adding water was a long battle, but the end results are satisfying.
My first attempt, which was decent for a first attempt, worked out okay, but the water just wouldn't even out proberly. Even after several minutes of waiting the water would most of the time be leaning in one direction.
At other times the water would just flow uncontrolled into the air.
I actualyl created a small video showing the issues I had, take a look if you want:


The method I used at first was very simple, I checked all the water tiles from the bottom and moved upwards, for every water tile I checked if there was room to dump water below, and if so, dump all the water possible. If there were still water remaining in the tile it would then dump 1/4 of the remaining value to the left tile and 1/4 to the right tile. This process was repeated for every water tile.
I did actually create a whole new tile for handling water, but this ended up giving me some gamebreaking problems. See when the water flooded the ground and hit any passable tiles, it would merely overwrite them. Since water was a tile, in order to spread I had to overwrite the old tile with the new water tile. Figuring this wouldn't work I decided to add a variable to the base tile class, where the water value was kept, thus removing the need of a water tile, and making it possible for every tile in the game to contain water. Although this fixed my problems with the tiles, and saved me a few checks in the algorithm it still didn't bring me closer to a solution.
Then one night just before I was heading to bed I found this article. The article describes how to make water using Cellular Automata. I gave it a quick read, and found it interesting, although I was too tired to grasp it all.
So the next day I looked it up and decided to give it a go. About an hour and a half later, plus twenty minutes of tweaking I ended up with the system I have now. How it looks you can see in the video at the end of this post.

Hunger and Thirst

Eventually I want the game to be more than just killing and mining to get better gear. I also want the player to have to deal with simple things like hunger and thirst. While this is not very complicated to add, it does add a lot of changes to the general gameplay. The player now has to keep in mind that he needs food and water to stay alive. Currently only the graphical implementation is done, but the rest isn't that hard to code, balancing it might be quite harder though. I want hunger and thirst to be an extra challenge for the player, but I don't want it to make exploration and leaving the comforts of your own base too difficult. On the other hand I don't want it to be an insignificant element of the game. I look forward to balancing this in the future.

Stone and Stone Wall

Stone has finally been added to the game. It is minable, and stone wall can be crafted. The graphics for the stonewall is temporary though, since I want the stone wall you build from raw stone to have a more raw and natural look. You will then be able to craft the stone into chiseled stone, or something similar. Building walls from those stones might get the current graphics that stone walls currently have.. I haven't decided yet.

That's it for this time. I didn't want to go into the save/load algorithm, I think I mentioned it earlier, and the changes are minor anyways.

As usual, I have made a video containing all the updates, albeit few this time. So enjoy the video:

Phantobra - The Game - Part 7: Now with water... and stuff!



Ingen kommentarer:

Send en kommentar