Over the last two weeks I have not gotten to much done except for setting up the base game project in Godot as well as working on a few sprites. I wanted to have some base sprites for putting into the terrain generator I am going to be working on. I also wanted to make sure that I had some basic character sprites ready to go. So, I have been working on getting a basic character sprite and the walking animations. I did not complete all the frames yet, and I am not sure I will keep these colors or hair but it was just to get started. I think in the future I may want interchangeable sprite parts for different clothes and hairstyles. Most likely I will continue working on the character sprites and terrain tiles over the next couple of weeks, but I will also be working on starting the programming in Godot. Until next time.
Character Sprite:
Dirt and Grass Tileset:
The basic 9 tiles were made in Aseprite and then I used them in Tilesetter to generate the rest as a blob tileset. I am not sure how great it will work, but it should be good enough to get me started.
Chunk Loading implemented with errors along the edges of the chunks
I know it has been a little over 4 weeks since my last update. But I have been very busy with my class and full-time job. I feel like I have not made much progress with the game. About 3 weeks ago I modified the terrain generation to work using chunks and changed the generation to be nearly infinite.
Chunk System:
The game world now is limited by the max size of a 32-bit integer. So, the terrain generation can only modify x and y values between -2147483648 and positive 2147483648. Which if my math is correct, makes my game world about 2 billion pixels in each direction from the center. I am not the best at math, but the map would have a lot of tiles before causing issues. So that is why I am calling it nearly infinite. It would take a long time to see all the tiles of the game world. Also, each time you start a new game the seed can change and generate another entirely different terrain. Or if you keep the same seed the game world would be the same at the start. This is like how Minecraft world generation works, except mine is 2D.
Major Changes:
Due to this massive change I modified my terrain generation edge checking code to check the edges on each chunk. However, currently along the edges of chunks because it does not know what type of tile is next to the edge, it draws incorrectly. I believe I need to rewrite the code now to have all the current chunks load on the screen and then calculate the edges of the tiles that are visible. That way there are not just some tiles that do not change to edge tiles. Because I am loading in 16×16 chunks of tiles, I am loading about 25 chunks total to fill my screen. I think the best way to solve my issue is to load the chunks and then calculate the edge changes. Hopefully, this solution will work after I get a chance to implement it.
When I am testing currently I have only one chunk load in which is what you see in the video. But I can have more load in, and then you will not see the transitions because they would be off the screen.
Video showing the chunk loading one chunk at a time. It also shows the errors around the edges.
Other Issues:
Another major issue currently is that the map is generated using Perlin noise and a seed. Which works great for the terrain generation because it can use the seed to get the next chunk of terrain data. However, all the other items like trees or entities I need to come up with a system to not just randomly place them. Currently the game draws these objects at random when the chunk loads. But when the chunk unloads, I have not yet programmed in to remove the entities in the chunk. I need to come up with a system to save this information. I am thinking I will need to create id’s for the chunks and check if they have already been seen by the player. If they have then I will need to load them from a file of chunks. This will also require me to be able to save this same data to a file each time a chunk is unloaded.
An additional part that needs to be implemented is saving the entire game and loading from a save file. I have not yet implemented this. I may need to get this working before starting to save chunks. The game should be able to save a game and then reload that point so you can come back and play at another time. Because the game world is so large, and I want it to be an adventure I need to be able to save the current game. Also, you should be able to start a new game if you so desire.
Game Outlook:
Because of the amount of work required I think I put myself in a tough spot and I lost some of my drive to work on the project. I am hopeful now that I can start working towards solving these problems and getting the project back on track. I started working on serialization code, but I have not really tested it yet. My hope is that saving this data will not cause issues with delays. I may need to separate this data into smaller files, but I think many chunks should be saved in each file. My only concern is that if I have multiple files, I will have to check each file to see if the player has seen the chunk before loading the chunk. Or I would need an index to reference which file that information was stored in. I’ve never coded anything like this before so it will be difficult.
I think if I start tackling one piece at a time, I will be able to overcome these issues. I just think that it is going to take me a long time. Winter Break at the college is fast approaching so that may help me be able to work more on the project. I will do my best to post more soon. Until next time.
Full Change List:
Coded: a chunk system to load tiles in a 16×16 grid to allow less to render at a time. Currently the game loads 25 chunks in total, a 5×5 grid of chunks to cover the entire screen. Updated: The game map system to handle chunks and level data. Updated: Replaced the original level generation with chunks to have a nearly infinite world. Bug: Fixed attack animations and arrow shooting after the map update bugged the code. Bug: Fixed the spawning system after the map update bugged the code.
I know it has been about 3 weeks since my last update. But I have been very busy with my class and job. But I worked on the game a lot over the last couple of days. I made many improvements that I was very pleased with. I was able to fix several bugs that I was encountering as well.
Bug Fixes:
The first major bug was that the edge of the game world was not rendering and when the player crossed the edge of the map the game would crash with an out of bounds exception. After redoing the map rendering code, I was able to fix the issue and now the player can walk around past the edge of the world. Which will be fixed when map collision is turned back on. Currently I have it off for testing, and the fact that I am spawning in on a mountain. If I had terrain collision on, I would not be able to get off the mountain currently, because I have not implemented anything to create a path down.
I also had a lot of bugs when resizing the game window. There a still a few issues when the screen size gets very small. But I think I am going to limit the size of the screen to certain ratios. After the fix I implemented, the screen scales much better and the map is rendering properly no matter the size of the screen.
Attack Animations and Sprites:
The largest project I undertook was created the sprites for the player attack animations. Then I also implemented them into the game. So, the player can now attack in all four directions. After implementing that I needed an actual way for the player to attack. I created a new system for collision detection that is much cleaner than my old code. It is working great so far but I do have a small issue with sprites of different sizes working with the same collision code because, the rectangles that detect collision are not being set to the right scale. I will need to fix this in the future.
HUD System:
Furthermore, I worked on a new HUD system for the game. I need to add much more to it, but I was learning just how to create one. Now that I was able to get the game world time to show up in the upper right corner, I would like to add more art to the HUD. The HUD also needs to show much more information than it currently does, but I did get it started. I would like to have it show the players health and have an items bar at the bottom. That will probably be done down the road once I have a better understanding of how to implement it.
Default Grass Tile Update:
Image showing the updated Grass Tile
The last update over the last few weeks was changing the default grass tile. I updated it using a noise pattern of different green colors. It seems to have worked well so far, and I am quite happy with the new look. I also updated the other grass edge tiles to match it. Additionally, I want to work on other default tiles that are basically just a color. I want to change them to have more details. I think it just makes everything look better. Once the basic tiles are updated, I am going to start working on other objects that will be above the base layer that the player can interact with, to make the game world seem more alive.
I am hopeful that I will be able to post every two weeks again starting next time.
Full Change List:
Added: Player attack animations for all 4 directions Coded: A HUD interface to show the time of the game world. More coming soon. Coded: A new collision detection system to determine when the player attacks are hitting other objects in the game world. Updated: The grass tile to look more like thick grass. Updated: The other grass related tiles to match. Bug Fix: Issues with resizing the screen causing map to not render properly. Bug Fix: Solved the issue with the void space at the edge of the world not rendering properly. Game was crashing when reaching the edge of the world.
Gif showing the items being auto picked up when walking over them
I realize that it has been two weeks since posting the last update. But college has started the fall semester and my work schedule has increased. Besides my full-time job at the college I also am teaching a class this fall. So, I must spend a little more time working on my class, leaving less time for me to work on my game. But I will still be working on the game it will just be at a slower pace.
Item and Inventory System:
Over the last two weeks I started working on an Inventory System and an Item system. The inventory is working in code. I can put items into the inventory and remove them. However, I have not worked on a graphic interface yet for this. I also added the item system so items can be placed in the game world and can be picked up by the player. The items can also be rendered into the game world. But for now, that most items I do not have icons for I just rendered in a black square. Once I get more sprites, I will add them.
Campfire Animation and Sprites:
After working on the item and inventory systems I decided to test it by creating a campfire sprite. From there I realized I would need a way to animate it, so I worked on the art for each frame of the animation. I am satisfied with the way it turned out so far but I think I will modify it a bit. I also may investigate adding particle effects to make it look like smoke is coming off. But overall, I think it looks good so far.
Gif showing the animated campfire
Attack Animations:
I also started thinking about how to handle the attack animations of the main character. But so far, I am not sure how I want this to work. I did start making animations for it, but I am no where near done with that work.
While I was working out the player attack animations, I decided I would first create idle animations for each direction that the player can stand. I was able to finish them, but I want to do more work with them, so the clothes and hair are more responsive to the player movement. But it was a good start.
One last project I worked on was creating long grass sprites for adding grass that the player can walk through. I only created the sprites at this point, and I have not implemented it into the game at this point.
It has been a slow two weeks and I am hoping as the semester progresses, I find more time to work on my project. Currently, I am doing a lot of art for the game and it is taking a lot of hours just to get the sprites done. I believe once I get the attack sprites created then I will still need to implement them into the game. I am probably going to be posting every two weeks for a while. But, depending on how much I can get done I may post more often.
Full Change List:
Coded: the start of an inventory system for the player and other mobs.
Coded: the start of the item system (player can pick up items and store them in inventory)
Created: a campfire sprite and animations for use as a placeable item.
Created: Sprites for the player idle animation frames
This week the first thing I worked on was getting the animated water tile animations setup. I created a universal animated tile class that I am using to handle all the animated tiles. So, all my water tiles are setup as tiles of the animated tile class. Basically, my animated tile class is setup to take in a sprite sheet and separate each sprite into different frames of the overall animation. Each animated strip is made up of 8 sprites. By using the class with different sprite sheets, I can now add all the different edge water tiles into the game using the same class.
Reconfigured Tile Classes:
While figuring out how to create the animated tile class I changed the way I was making my tiles. I originally had a class for each one, mountain, water, grass, etc. Now I created a class called basic tile that handles all the standard tiles. I also set a Boolean variable that is set upon using the class that determines if the tile should be solid (can collide with it). This change helped simplify my code and remove a lot of unnecessary classes.
Animated Tile Error:
I did run into a crazy bug while working out the animated tile class. As I would move around with the player the more water tiles that would show on the screen the faster the animation would play. After a lot of debugging I was able to figure out that I was adding the delta time variable to the state time to many times. The variable was continually adding to the state time 60 times for each tile visible each loop of the game. So, I just needed to move where I was adding the delta time so it would only change once every game loop. That fixed the crazy looking bug where the animation would speed up so fast it would just look like glitches.
Image showing the difference between water tiles
The last work I did for the week was getting the dark water also animating. For now, I decided not to calculate the edge between the dark water and the regular water. So, the tiles just have a squared edge. But the animation is the same, and the only difference is that the water is slightly darker.
Screen Resizing Error:
Just today I was also able to figure out a rendering issue when the screen size would change. The error would cause the screen edges to show the edge of the screen being removed from rendering because it should have been off the screen, but it was not. I was using the wrong size for the screen resolution and it was causing the screen edges to appear smaller than they should with bars on the sides. I still need to figure out a way to limit the screen changes to stay in the same aspect ratio, so the sprites do not distort depending on the screen size. But that will have to wait till a later time.
Next Pieces of the Project:
The next parts I would like to start working on are more animation for the player. Attack animations being the first I would like to work on. The problem is I need to figure out how I plan to handle them, and I also need to create the sprites. I also want to start working on a user interface and inventory system.
Change List:
Added: water edge and corner sprites Created: water tile animation sheets for each edge animation and regular water. Created: dark water tile animation sheet for the dark water. Added: animated tile class to handle all different animated tiles. Added: basic tile class to replace all my standard tiles with one tile class. Removed: separate tile classes (water, mountain, grass, sand, etc.). Fixed Bug: water animations speeding up depending on how many were on the screen. (updating state time in the wrong location) Fixed Bug: screen size when getting smaller would not render properly. (I was using the wrong numbers to calculate the screen size when rendering the map tiles)
Two layers of mountains are procedurally generating into the world.
This week I was able to complete coding everything from my previous version into the new LibGDX version. So, now I should be able to start implementing new things. I was able to get two layers of mountains procedurally generating again in the game world. There are still a few bugs where I am not checking some special cases but overall, it is looking pretty good. Additionally, I was able to fix the rabbit animation problems I was having from the previous week.
I recently made a list of the next items on my list to work on. It is very long but I would like to start working on attack animations and sprites. Then I would like to work on adding an inventory system and an item system. I would also like to work on animated tiles to make the world look more alive. Every week I seem to talk about working on a noise algorithm for placing objects around the world better, but I keep putting that on hold. Hopefully, I can start working on that soon as well.
Hopefully the next post will have something more interesting to talk about. I spent most of my time this week working on fixing unexpected bugs and getting everything working as good as or better than before. I am looking forward to starting work on the next pieces of the project.
On the end of the post every week I am going add a list of changes that I made during the week and add them to the end of the post.
Full Change List:
Fixed Bug: particle spawner had a null pointer exception because there was no sprite for the spawner. (put spawners into a new type of entity called non render entities)
Fixed Bug: particle spawner not removed during cleanup after it is used. (Empty object was still in memory)
Fixed: Rabbit movement animations. Each rabbit needed its own copy of the animation sprites.
Implemented: Mountain Tiles have been added to the game world. (2 layers)
Code change: Moved Rendering into each class. Many calls instead of one giant one.
Code change: Created a class for levels. Moved a lot of the level data out of the game class.
Implemented: Entity Sorting for rendering.
Fixed Bug: Entity Sorting crashing when sorting Trees. (Trees at same y height caused the crash)
Over this week I continued working on getting the project to work in the LibGDX framework. I encountered a lot of problems with sprite rotation that I was using for shooting arrows and would probably use quite a bit in the future. But after many hours I did figure out what I was doing wrong. Basically, it came down to the way I was rendering did not handle the rotation so even though I was processing the rotation it would not show it. I still may have some errors with the shooting but for now it is good enough.
Map Generation:
After figuring out those problems I continued working on getting the map tiles back to where they were in the previous project. I have everything done but the mountains and the water. But I figured I am going to be animated the water tiles, so I don’t really need to complete that now. I can skip it and implement the animated tiles. This week I need to get the mountains and the mobs spawning in correctly.
Rabbit:
Over the last couple of days, I started working on the rabbit mob. I encountered some issues with the way the animation is handled. Once I got the movement working, I realized the way I created the animation would not work. Each rabbit needs its own animation. I set up just one and it made it so all the rabbits would move but follow the same animation. They looked like they were skating on ice. It looked funny but was not going to work. I am hoping that over the next day or so I can get them working correctly. Then I will be back to where I was for the most part.
Tree Spawning and Future Work:
Trees Rendering Again. Entity sorting still needs to be done
I also worked on spawning trees back in this week. I did not run into too many problems getting that to work. Soon I will need to work on sorting the entities though, so they don’t render like they are floating. Once I finish the mountains and the mobs everything should be back to where it was. My goal is to have it all done this week. After that I would like to work on a noise function to produce better looking sprite placement for trees and grass. I think that is the next big step for this project. Then of course I need to add in more animals to make the game feel alive. Hopefully all will go well. Until next time.
This week was a great week. I was able to get started on the procedural mountain generation. For the most part I was able to use a lot of the same code from the edge detection to generate the mountains. I only have one layer of mountains currently, but I plan on adding several different layers, so it looks like mountains instead of a one high wall.
Image showing the inner corner checking system before the proper tiles were put in.
Image showing the mountain generation after the corner checking was done.
Also this week I was able to get the first tree rendered in the game. I first rendered just one tree. Then I added a bunch. When I initially added them randomly in the forest area all over the world map the games fps went to almost zero. It was unplayable. I knew that I needed to find a way to limit what entities would render. After a little tinkering I was able to limit the rendering all the entities not just trees.
I calculated the distance the entities were from the current player position and then anything further than off the screen does not render. I also tested this on the Rabbits, and it worked for them too. Currently the movement of entities is still calculated, but not rendered if they are off the screen. In the future I may need to also not calculate their movement if they are for say on the other side of the map.
Now that I have the trees rendering, I can start working on an algorithm to better place them in the game world. Currently I am only using the built-in rand function to place them. I need to investigate other better algorithms for placement.
I will also need to work on the rendering order for entities. Currently the player is always on top of the trees, and rabbits run under them. I need take all the entities and take their y coordinates and then sort all of them based on there height on the map. Then depending on the height, it will draw them in order from highest to lowest on the screen. This will be accomplished from sorting the array of entities and then drawing them in order. I hope I can figure out how to implement it this week.
This week I also started working on the beginning of the GUI system for the game. Currently it is just a couple of boxes and components. But I will be working more on it this week if I have time.
Game Art Work:
Image showing the trees rendering for the first time. Photobombed by the rabbit.
I wanted something that I could render easier. With the current tiles it would just be one tile high instead of several like my previous tiles. But as I add more layers, they should look ok. Now, that I made the current mountains for my game they render in for the most part in one tile. Then I calculate the inner corners to make it look correct. I’m very happy with the way they are turning out so far.
In order to render the trees I needed to have a sprite for it so I made my first tree sprite for the game. I was failing miserable making trees, so I went to YouTube to watch tutorials on pixel art. After watching several tutorials I was finally able to make a decent looking tree. I am sure with more practice I will be able to implement many different trees into the game.
Work Planned for the Upcoming Week:
This upcoming week I plan to continue working on the mountains. I want to add several layers and see how they look from there. I also want to work on an algorithm for placing game objects around the world in a much better pattern. Once I have the trees worked out then I can start adding patches of grass and other objects.
I don’t think I will work on River generation this week, but we shall see. I will be working on getting an animated tile class working hopefully. Once I have that working, I will be able to add my animated water tiles and see how they look. I am happy with the progress so far, and I can’t believe it has been 9 weeks since I started working on this. Let me know your thoughts on the project and any suggestions you may have. Until next time.
Rabbits spawning in from the same point on the map at startup
I spent a lot of my time this week working on cleaning up my code and optimizing some things in the game engine. I also did a little work with my mob / npc classes. Last week I created a class for a mob spawner, so I decided to put it to use this week and added some rabbits to my game. I implemented the class for the rabbits and then I worked out some basic movement for them. I just wanted them to be peaceful mobs that would occasionally move around for now. In the future obviously I want to be able to interact with them.
Later in the week I worked on implementing the A* pathfinding algorithm to use for mob pathfinding in the game. It seems to work well at this point, but I need to do more tests with the collision system. It seemed to bug sometimes if the player collides with a solid tile. Other than that, I spent my other time working on art for the project.
Game Art Work:
This week I created the art for the first mob in the game the Rabbit. Because my player sprite is 32 pixels I decided that I needed to make the rabbit 16 pixels. I found it very hard to create a 16 pixel sprite and get the details in to make it look like a rabbit. I was happy with the way the up and down animations looked but the side to side animations might need some work. Let me know what you think in the comments. I also need to create idle animations for all my characters so when they stop moving, they are not just standing still.
Rabbit Mob Sprite Sheet
I also started working on some tiles for giving the illusion of height. I modeled the sprites heavily after The Legend of Zelda: A Link to the Past and I will probably add more details to the sprites later. For now, I just needed sprites so I could work out how to procedurally add them to the world generation without causing a lot of bugs.
2D Cliff Tiles
Work Planned for the Upcoming Week:
This upcoming week I would like to work on procedurally generating the elevation change tiles into the world. I think it is going to take a lot of work to figure it all out. With a bit of luck, I hope it will be easier than I think. After I figure out terrain height changes, I can work on adding rivers. Then I will need to work out spawning entities like trees through out the world. I will most likely work on some art for new mobs just to break up all the coding this upcoming week. Hopefully after this week the map will start looking more interesting so I can start focusing on gameplay aspects. Until next time.
Image showing the detail tiles for the grass and sand
Game Engine Work:
This week I continued working on the generation of the 2D map for the game. I decided it was a lot of extra work, working out all the special cases. So, I decided to simplify the map and make a smoothing algorithm. I basically am checking anywhere on the map where a tile is surrounded by another color tile or where 3 sides are surrounded by another color tile. If that is the case, then I replace the tile with the color around it. As far as I can tell this seems to eliminate some of the special cases and allows me to make less tiles. It basically removes any areas where there was a single tile jutting out into another color. It also eliminated areas where a single tile was inside another area. For instance, one sand tile in the grass area.
I also did some work on collision detection. I added the code for collision detection of tiles by adding a Boolean variable to check if the player is moving into a certain tile. For now, I tested it using water tiles. So, the player could not walk into the water. I disabled it for testing the rest of the map generation for now. But, in the future I will use the collision detection function to test entities on the map like trees, rocks, stumps, etc. I plan on working on implementing some of that work this coming week. I will also be working on an entities class that will use similar collision detection to the tiles.
Game Art Work:
Image showing the different tiles that would be used for the water tile animation
This week I decided to work on some Animated Water Tiles. I was able to get them very close to the way I think I want them. The only thing that is bothering me is that the water would only animate in one direction. This can be seen below. If the image is not animated click on the image and you should be able to see the animation. I may want to change that in the future.
Animated Water Tile Animation
I also worked on adding some grass and sand details. If you look at the map image at the top, you can see some of the grass and flower detail tiles. I only worked on details that would not need collision with the player. In the near future I will add animated grass and other interactable tiles. I added a few sand details, but I would like to add some shells or other objects to make it look better and have the player be able to interact with these as well. For now, the details are just picked at random from tiles that are not edges. But I will probably work on a different algorithm for placing these better and in clumps. More than likely I will need to use an algorithm for a cellular automata for this.
Work Planned for the Upcoming Week:
I want to work on coding the Animated Tile Class. Then I should be able to implement the animated water tiles to the map generation. Additionally, I would like to work on elevation change tiles that I can use to change heights on the map. I would also like to create an entities class that can be used for interactable objects like stumps, tall grass, etc. In order to accomplish this I believe I need another rendering system for these as they will be above the map tiles. I have a lot of coding ahead of me and probably a lot of error checking, but I am hopeful that I can complete this work this week. Until next time.