August 2020

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 »