LibGDX

Finally Back and Healthy, Switching to Godot from LibGdx

Image of LTGD Game Jam Game
Live Torment: Gary’s Damnation, our Let’s Talk Game Jam Game

Health Problems and Update:

It has been a very long time since I posted anything on my site.  It has been a rough couple of years, and I am looking forward to getting back into game development again.  Over the last few years, I started having a lot of health issues which mostly could be correlated with being overweight and not exercising at all.  I started having chest pain, shortness of breath, tachycardia, and other heart related issues.  I was also having stomach related issues including chronic gastritis, and now chronic esophagitis, and Gerd.  It turned out that I was having Gerd attacks from what I was eating, and it was giving me heart attack like symptoms.  They also found that I had a couple of partial blockages in my heart, which were not helping the situation.  After multiple trips to the ER and many, many procedures, and doctors’ visits over the years, I am finally starting to feel better.  I drastically changed my diet to a very low fat, acid reflux diet.  I determined that whenever I would eat fats except a few types like avocados it would trigger my chest pains, arm pain, shortness of breath, and other symptoms.  So, I have not been eating those foods for the last few years, and it seems that I will never be able to again.  Due to the drastic dietary changes, I lost about 150 pounds over the period of a year and a half, and I am in a lot better shape than I had been for many years.  I still occasionally have problems, but they are much better managed at this point.

Game Jam:

About 6 months ago a coworker and prior student of mine asked me if I wanted to do a game jam with him.  So, we worked on a game for the Let’s Talk Game Design Game Jam.  If you are interested the game, it is available for download on itch.io for free.  The only rule of the Game Jam was that the name had to be from the letters LTGD, and we had about a week to make the game.  Our game was called Live Torment: Gary’s Damnation.  It was about Gary, a man with a bucket on his head who ended up in hell.  His goal was to collect souls for hell’s number one live streamer Lilith.  So, basically the game was a weird, janky, 3d platformer where you would go around collecting souls.  It was a fun project, but we really didn’t have the time to polish the game in a week.  Overall, I learned a lot from the project because we had to build a full game in a week and publish it.  I also had never used the game engine we decided to make the game in (Godot), so it was a great learning experience. The game also got featured in the Youtube video on the Lets Talk Game Design Channel which was a bonus.

Switch from LibGdx to Godot:

After the game Jam I was really liking Godot. So, I decided that if I was going to make a game it would make sense to use the engine.  I like the fact that the engine is open source and would allow me to publish the game without paying them to use it.  In the past I used LibGdx and I was coding my game from scratch in Java.  I think this was probably a bad idea, since I had to create everything to make anything work.  I ultimately was struggling with the procedural map generation and kind of gave up on my project.  When I started playing with Godot it was just before the update to Godot 4.  So, I waited a bit for that to come out and when it finally did, I seemed to not have the time to work on the project, due to my other hobbies.  Mostly wildlife photography and astrophotography as well as 3d printing and building robotics projects.  With Godot 4.1 coming out now I am hoping to get back into the swing of things and start working on my game.  I think I am sticking with the same idea of a procedurally generated 2d Minecraft / Zelda style game.  But, I may change my mind once I start. Most likely I think I will continue from where I left off.  I will be making a lot of new sprites as I was not very happy with them, but the idea will be the same. 

Plans:

I am hoping that I will keep up with the project and look to post at least one to two times a month, maybe more if I get a lot done.  But I still work full time, so it must be realistic with the free time that I have.  I also plan on updated the website to better fit the updated project using Godot instead of LibGdx.  I will probably also make a section on my site to host some of my other hobbies, since a lot of people are interested in my photography.  But I still want my site to be mostly about my game development.  I look forward to keeping everyone updated on the project.  Until next time.                 

Finally Back and Healthy, Switching to Godot from LibGdx 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 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 »

Game Migration into the LibGDX Framework

After watching a lot of indie game developers’ videos and checking out their websites I came across a java game framework called LibGDX.  I decided to look into it, and I think it is the best way for me to go on with my current game project.  LibGDX is a free open source game development framework written in the Java programming language with some C and C++ components for performance dependent code.  It allows for development of desktop and mobile games by using the same code base.  It also has cross platform development. 

LibGDX First Map Rendering
LibGDX First Map Rendering. Each tile is 1 pixel for testing the noise algorithm.

Framework vs Game Engine:

LibGDX is a framework not a game engine.  A framework is essentially a code base that handles important aspects of games, usually hardware interfacing and input, but come with no predetermined rule set.  A game engine is a set of tools and mechanisms prepared to make a certain type of game. Good examples of game engines are Unreal Engine and Unity.

Teaching Schedule:

I figured switching to LibGDX would be the best option for me, since I was already coding the project in Java. In about a month I will be teaching on top of my full-time job for the fall semester. So, this should allow me to design the game, but not have to code everything. Hopefully, saving me time in the development process.

LibGDX Version Work:

LibGDX Game Map Scaled
LibGDX Game Map scaled up to size. Default tiles and Player rendering.

First, I imported the framework into an Eclipse project and started working on switching over my current project into the LIbGDX framework. Then I was able to figure out rendering the tiles to the screen as well as setting up the player and the movement animations. I first tested the setup by rendering each tile as 1 pixel. After I had that done I scaled up to 16 pixels per tile. Then I scaled everything by 3 for the view window. Today I was able to also get tile-based collision done, and I setup for entity collision for the future.

So far I only worked on printing the game maps default tiles. But, I should be able get the others working quickly since I already have working Java code for that. I will need to figure out the rendering process using the framework, but it shouldn’t be much different than the default tiles. I don’t think it will take me too long before I have everything working that I had working before. The framework should allow me to be able to get more done in less time. At least that is the idea.

This week I didn’t work on anything new. I mostly worked on learning the new framework and getting the project back to where I was originally. There is still a lot of work to do in order to get back to where I was. I think in the long run though, this transition will help speed up development. I wish I had known about this framework about 10 weeks ago. Hopefully over the next week or two I will be back to creating new content for the game and back on track. Until next time.

Game Migration into the LibGDX Framework Read More »