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 »

Week 9 Game Engine Progress

Game Engine Work:

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.

Mountain Inner Corner Test
Image showing the inner corner checking system before the proper tiles were put in.
Mountain Inner Corners Done
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:

Trees Rendering for the First Time
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.

Week 9 Game Engine Progress Read More »

Week 8 Game Engine Progress

Game Engine Work:

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

Week 8 Game Engine Progress Read More »

Week 7 Game Engine Progress

Game Engine Work:

This week I believe that I made great progress on the Game Engine. However, I kind of got sidetracked from what I wanted to work on. I had planned to continue working on the map and producing the tile assets I would need for trees and other obstructions. However, I started working on a projectile system, and then found myself working on a spawner system. Once I started working on the spawner system, I then found myself coding classes for the games mobs. I also created the Animated Sprite Class and modified my player movement to use the animated sprite instead of a bunch of single sprites.

The Projectile System:

Basic Arrow Projectile System. Still needs work.

I started out the week working on a simple projectile system. I tried to simulate a bow firing. It is partially working. I will need to work on rotating the arrow to match the direction it is being fired in. Hopefully that won’t be too hard to do. I also would need to make the bow asset and have animations to match the bow firing.

After I had the basic arrow firing, I made it work with collision detection. From there I thought it would be cool to work on a particle spawner system to spawn particles when objects collide together. I used it on the arrow as a test and it seemed cool. Once I have actual objects it can collide with, I will test it more.

Mob Spawner System:

The video clip shows the mob spawner and the basic movement AI at this point.

Since I had a basic entity spawner for the projectile system, I figured I could use it to spawn mobs as well. After a little bit of tweaking I was able to set a spawner near the player and have mobs appear. Once I had that worked out I then added some basic movement to the mob class. I used the player sprite for the first mob because I did not have any other art to use. Using the player sprites worked great for testing it though.

Work Planned for the Upcoming Week:

This upcoming week I would like to start working on the other interactable objects like the trees and grass. Additionally, I would like to start working on elevation change tiles that I can use to change heights on the map. The changes I made this week to the entity class and the way they render will hopefully help me complete some of this work this week. Hopefully I can get a good chunk of this work done this week and move onto more enemies and some more fun stuff next week. Until next time.

Week 7 Game Engine Progress Read More »

Week 6 Game Engine Progress

Grass And Sand Details
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:

Water Tiles Animated Separated
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
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.

Week 6 Game Engine Progress Read More »

Week 5 Game Engine Progress

Game Engine Work:

This week I continued working on the generation of the 2D map for the game. I spent a lot more time working on coding the edge checking system. Currently I have pretty much figured out how to make it work. I have a few special cases that I seem to be finding that I did not check for. One is featured in the image below that shows if the edge is closer to another edge it does not know to handle it properly. It only finished the edge on one side. The error is just above the character to the left. To fix this I need to add art assets for each case and check it in the code. Currently I also have most of the grass edge working. I need to finish checking some of the special cases just like in the water section.

Water Tile Special Cases
Water Edge Tile bug that will be fixed soon

After the edge system is done for the water and grass, I need to work on the other sections with edges. In the future I want to change the water tile and make it animate. I also don’t want the tile to just be blue water. Also, soon I want to add more detailed tiles to the map to make it look much more interesting.

In the map generation right now, I marked an area in dark green that would be the denser forest area. The dense forest would be made up of much denser tree placement and taller grass and shrubs. Some of these areas would be inaccessible without cutting the objects down. I also marked out terrain with a grey area for mountains and a white area for snow. In these areas I want it to look like they are a higher elevation and I believe that I will be able to make it look higher using edge sprites. Instead of replacing the edge with a one tile change, I would need to probably use at least 2 tiles to make it look like it is higher up. Also, once I add collision the player would not be able to just walk into these areas without a ladder or ramp or something.

Water and Grass Edge Done
Water and Grass Edges are working for the most part.

Future Game Engine Work:

I would like to add elevation changes to other areas as well down the road. I have been thinking a lot about what I would like to have in the game, and I think I would like to have cave entrances spawn on the map in the elevated areas. Then if you enter a cave, I could generate a below ground map that would resemble caving and dungeon exploration. I think by adding this element it would make the game much more interesting and would make the game very repayable due to all the procedural generation changing every time you play the game.

Furthermore, I started thinking that maybe most of the enemies on the surface will be forest animals. I really enjoy nature and wildlife photography so I figure a game with wild animals would be cool. To start I would like to implement some animals that would be non-aggressive and others that would attack the player. I would probably start with sprites for bears, wolves, rabbits, and foxes. I think it would be real fun if the player could tame these animals or trap them. But this work would be something that I am no where near ready to implement.

For now, I think I am going to focus heavily on the procedural generation of the world. Then I will work more on the game play aspects. It has taken me longer than I thought it would to figure out how to calculate all the edge checks, but I am starting to get the hang of it. The next step is to try using cellular automata or another method to produce more random placement of detailed tiles. Then I would like to work on the elevation changes.

Game Art Work:

Over the period of the week I worked a lot getting the proper tiles for all the edge cases. With the grass edge I was able to use less tiles because of the way I created the tile set. So, it was easier to complete than the water. I will most likely use the new method to complete the other areas, so I don’t have to make as many assets. Other than making a few edge tiles I really did not work much on art assets this week. I want to add more randomness to all areas on the map because currently the blank colors are boring. So, this week I will work on adding more detail tile sprites to each area. Once there is more randomization the map will start to look a lot more interesting.

In the future I would like to add a rivers and path system. So, I will need to create art assets for this as well. The other problem I might encounter is if a river intersects with an elevation change. In that case I would need tiles that look like a waterfall to now throw of the aesthetic. I am sure that I will encounter all kinds of problems as I work on this, but I am hoping I can figure them all out and make everything work as intended.

Week 5 Game Engine Progress Read More »

Week 4 Game Engine Progress

Game Engine Work:

This week I continued working on the random generation of the 2D map for the game. Initially I was working on coding an edge checking system that would take each grid square of the map and determine if it was shallow water. Then it would check each of those grid squares neighbors “left, up, right, down” to determine if it had an edge with sand or not. Once I got those edge cases working for the shallow water and sand edge, I realized I would need to figure out a corner checking system because the map currently is missing edges in some cases. I still have not worked on that problem yet. It will be the next part I work on. The image below shows the corner cases being bugged currently. The program does not know yet to check the corner case and add a different tile to complete the edge.

Edge Corner Bugs
Picture showing the Edge Corner Bugs

From there I also worked on a sand and grass edge check. I was able to get that all set up to the same point as the prior. So, I just need to figure out the corner checks and add the sprites for that. I am confident that I will be able to figure out the corner cases soon and once I have them working, I will most likely move to complete all the edge cases for the different areas on the map.

Game Art Work:

Over the period of the week I worked a lot on trying to create the tile set for the water and sand edge. Each time I thought I was finished it would not line up correctly. I was not sure if I had an issue in my code or the art. It turned out I believe to be the art. After trying so many different looks I just stuck with a very basic one for now. The initial art I worked on had to many bends in it and looked very unnatural, so I scrapped it. I know in the future I want to animate the water and have the water look more like water.

WaterEdge and Grass Edge Tiles
Tile set for the water edge and grass edge

After spending a lot of hours treading water on the art, I decided on focusing on getting the edge in the sprite to line up correctly. So, I worked only on the edges between colors. Most of the tiles are just the solid color from the map with the edge change. Once I had a pattern for the water tile, I created a simple tile set for the grass edge with the sand using the same technique. I am just using these for testing, and I will work more on the art later. I just decided I was spending to much time on the art, and I was not getting anywhere with the actual game work. So, for now I am creating basic art assets to use for testing the code. I can always modify the art later.

Thoughts:

I know this is a relatively short article for this week’s progress but not much progress was made on the game because I spent to much time on the art. I’m looking forward to getting back on track this week. I would like to have all the edge testing done by the end of the week including the corner cases. Then I will need to move into adding rivers, vegetation, and terrain height changes which I anticipate will be harder for me to figure out.

Let me know what you think of the work so far, and if you have any suggestions feel free to leave a comment.

Week 4 Game Engine Progress Read More »

Week 3 Game Engine Progress

Game Engine Work:

This week I continued working on the generation of the 2D map for the game. I decided for now to take out the moisture map and solely base the map generation on a Perlin noise map of different heights. I set thresholds for areas of water, sand, grass, dense forest, desert, and snow. Most likely I am going to change the desert to mountains or rocky terrain. That way this part of the generation is determining the type of area it is, but not the Biome. For now, the map is not determined by other factors such as how much rain occurs in the area. The moisture map will most likely be needed to determine more Biomes and river generation in the future.

I wanted to simplify the map as much as possible for now so I could work on the edge cases between different types of tiles. I did not want it to just look like squares of color with nothing to break up the edges. You can see what the map currently looks like in the short video above. In the video you can see several of the different terrain types. Including 2 colors of water, sand, grass, and a tile I am currently using to represent a dense forest area. It is just a grass block for now. I decided to have 2 water colors to show the deeper water areas. I may use this for adding fishing to the game in the future. Where certain fish come from only deep water.

In the future I would like the map to have different heights in all the landmass areas. So, I need to figure out a way to randomly generate elevation change in the tiles, so they don’t look out of place. I only want a couple of levels of height, so the map does not look so flat. I will also need to figure out how I am going to handle river generation. Furthermore, I will need to work on adding trees, brush, and other objects like ores to the map. I am going to be looking at Poisson disk sampling to do those parts of the map generation.

Map Generation Next Steps:

The next steps of the map generation, is to figure out how to manage the transitions between the various regions. For instance, between the water and the beach there would need to be a tile in between that has both water and sand to break up the flat look. The same would need to happen for every area that has an edge between two terrain types.

I believe that the following cases would need to be checked for a tile that has two terrain types around it. The lighter tiles would be one terrain type and the darker tiles would be another. The X marks show tiles that we would not care about during each tile check.

Edge Cases Figure
The Figure showing edge cases of tiles

The center tile in each case is the one you are testing to see whether it has neighbors that are not of the same type. The different cases above would need to have art assets for each specific case. From what I have been able to find on the subject I need to have art asset tiles that would look like the image below. So, each case above matches up with the art asset below.

Edge Cases Art Figure
Shows the different art assets that would need to be made for each edge case.

Game Art Work:

This week I worked on coloring the main character sprite. I was trying to make the character look like a ranger. I wanted the outfit to be dark green with leather accents. So, for now I made the clothes a dark green with a brown leather belt. I used a lighter green to highlight some areas. Most likely I will take the black out of the forward-facing hair because it does not fit with the rest of the directions. It just looks funny to me. The main character in the game will probably start out with nothing or just very basic weapons. Currently the character movement is working but I need to create assets for weapons, and assets for different attack animations for the character.

Main Character Sprite Sheet Color
The Colored Main Character Sprite Sheet

I also worked on some water / grass edge tiles. I think it is a good start, but I may need to change them. Once I start working on the edge cases I may decide that these tiles look to detailed for what I am going for. I also started work on the water/ sand edge tiles, but I am not done with them yet. This week I am going to try and focus on finishing the edge tiles and getting all the basic tiles done so the map can start looking like something.

Water Edge Tiles So Far
Water Edge tiles done so far

Week 3 Game Engine Progress Read More »