2D Sprite Art

Back Into the Code – Terrain Trouble, Weather Systems, and Visual Tweaks

Procedural Generation

Since my last post about returning to game development after a long break, I’ve been back in the thick of things. I’ve spent most of my time working on procedural terrain generation.  More specifically, trying to connect different terrain types smoothly using TileMapLayer.set_cells_terrain_connect() in Godot 4.3.  Let’s just say it didn’t go as planned.

The idea was to have nice seamless borders between terrain types, but the reality turned out to be full of edge cases. Whenever three or more terrain types meet in close proximity, things break down, visually and logically. The transitions look bad, and worse, the system is painfully slow. Loading terrain in real time for a chunk-based world is completely impractical with this method. So for now, I’ve put that approach on hold and will be revisiting it with a fresh strategy later.

Ambiance and Environmental Systems

In the meantime, I’ve shifted focus to some gameplay ambiance and environmental systems. I started laying the groundwork for a weather system, building a basic state machine to manage weather types. To complement that, I added a CanvasModulate layer to simulate a day-night cycle and hooked it up to a simple UI from a great tutorial I found. The plan is to eventually make the weather and time systems work together so that, for instance, the sky darkens more dramatically when it starts to rain or storm.

Speaking of rain, I’ve added some rain particles and a fog effect as a first pass.  They work… kind of. The rain is kind of hard to see so I need to work on that. One issue I’m currently debugging is that the rain moves in the wrong direction when the player moves, likely because the particles are tied too closely to the player’s position. It causes them to shift far more drastically than they should, which breaks the illusion. I’ll need to rethink how I position or simulate the weather visuals relative to the player or camera.

Grass Tile Art

Lastly, I’ve also begun adding some basic grass tiles, moving beyond the basic biome colors I started with. The world definitely needs more visual identity, and building out a consistent tileset will help me get there.  I just started to work on some alternate grass tiles as well as the edge tiles.  I went with more of a noise based style and  I am assuming it is a work in progress at this point.  

What’s Next?

Up next, I’ll probably focus on tile art and continuing to develop the procedural generation system. I want to start shaping how the chunk generation works in practice, as well as improve the overall look of the world. I’d also like to begin populating the environment with trees and other natural elements to give the map more life and variation.

Thanks for reading. Feel free to follow along or reach out if you’ve dealt with similar terrain headaches in Godot. More soon.

Back Into the Code – Terrain Trouble, Weather Systems, and Visual Tweaks Read More »

New Sprite Work Continued

This last month has been very busy and I have not worked on the game project as much as I would have liked. Within the last week I took my character sprite base and started making an idle animation from it. I also completed the side and back idle but I didn’t make a gif of them. The character sprites to this point are ok, but I think the sprites could use some more work. I need to add more life to the movement because it is very rigid at this point. I believe I also need to slow down the animation so that the character is not breathing so fast.

Tools and Weapons Sprites

I also started putting together some of the base sprites for weapons and tools. Which included some of the essential survival style tools from many other games. In this case a pickaxe, shovel, axe, hoe, and a sword. I also made sure to include a bow and arrow for ranged weapons. These should just be the start as I would like some fancier versions of these items made from other materials for my game. I was thinking that I may want to add a weapons forging mechanic to the game so I made some sprites for an anvil and tools. We shall see if that is something I can add, but at least I have some kind of workbench or anvil for making items. Some of these sprites are just for the items hotbar, but not the actual in game sizes. For instance with the anvil, one sprite is 16×16 for the item box, and the other is 32×32 for the in game item that would be placed.

Progress

I know that progress has been slow, but I hope to continue making small strides. Over the next few weeks I will continue to try and find more time to work on the project. I would like to over time start recording parts of my work for vlogs so I can have a record of the progress of the game. Especially once I start working in the game engine and pieces start coming together. Right now I am just mostly working on art, and some ideas for what I would like to accomplish. Until next time.

New Sprite Work Continued Read More »

New Sprite Work

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:

Main Character Sprite

Dirt and Grass Tileset:

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.

New Sprite Work Read More »

Nearly Infinite Procedural Terrain Generation

Chunk Edge Errors
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.

Nearly Infinite Procedural Terrain Generation Read More »

Player Attack Animations and New 2D Grass Tiles

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:

Updated Grass Tile
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.

Player Attack Animations and New 2D Grass Tiles Read More »

Item and Inventory System Continued

Tree chopping partially done. Still need animations.

Over the last two weeks I continued working on an Inventory System and an Item system. The major change was I switched my inventory to store data using an array instead of a list. Because inventories are a set size and I think it will be more efficient to handle it this way. I need to next think about how to handle item stacking. Because currently I can pick up 20 items until the inventory is full. But if I pick up 20 pieces of wood, they should not fill every slot in the inventory. They should stack in some way.

Wood Log Sprite:

After changing the inventory system slightly, I created a sprite for a wood log. I then implemented the code to chop down trees. However, I have not added the animations for the player or the tree falling at this point. I have been working on the player attack animations as well and I think for the time being I will have the attack animation be the same as the chopping animation. There definitely is a lot more polish needed, but I think the work so far is a good start.

Attack Animations:

While working on the attack animations I realized that my sprites for running and idling were not anchoring the player sprite at the same location. So, I had to go through and modify the player sprites anchor locations. Now that they are all relatively at the same location I can try and work out how I am going to handle the attacks. The issue is I have 32 x 32 pixel sprites currently. Some of the attack animations will need to be larger to accommodate the weapons. Unless I separate the weapon from the player. I am not sure that I want to do that. For now, I think I am just going to use larger sprites and anchor them at the center point, so the player does not jump around between animations.

Progress:

I feel like I have made little progress over the last two weeks and I am hoping as the semester progresses, I find more time to work on my project. My work and class are keeping me busy but I will do my best to find time to work on this project. Until next time.

Full Change List:

Re-Coded: the inventory system to store items using arrays instead of a list.
Created: wood log asset to drop when a tree is cutdown.
Coded: Player chopping down trees (without animation) into the game.
Modified: anchor points on all player sprites to the center.

Item and Inventory System Continued Read More »

Item and Inventory System Started

Item Pickup System
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. 

Campfire
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

Added: Player idle animations to the game.

Created: Sprites for long grass

Item and Inventory System Started Read More »

Animated Water Tiles Started

Water Tile Animations Working
Image showing the water tile animations

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.

Dark Water Tiles Working
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)

Animated Water Tiles Started Read More »

Migration to LibGDX Framework Complete

Mountains Working Again
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)

Migration to LibGDX Framework Complete Read More »

Continued Game Migration into the LibGDX Framework

Grass Details and Edges Working Again
Grass Details and Edges Working Again

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
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.

Continued Game Migration into the LibGDX Framework Read More »