July 2020

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 »