Collision Detection

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 »

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