A Game A Month #1: Update – Nearly finished!

A Game A Month #1: Update – Nearly finished!

Hi everyone! I’m back with an update of my first monthy game this year. I have made great progress and it seems like I’m on a good way to finish this game in January.

Update: Clouds, explosions, health-bar, score

Here is a short summary of the progress:

  • Menu, pause and game over states
  • Player death: By getting shot, collision with enemies and ground
  • Restart handling – reinitializing gameplay
  • Counting score, showing at top-right corner
  • Showing health-bar, decreasing on hit
  • Spawning non-shooting obstacles (clouds)
  • Spawning items: Repair tool
  • Additional “super”-class “GameObject” – For ShootingObjects, Obstacles and Items – for handling movement and collision areas
  • Spawning explosion animation on enemy and player death
  • Background shaking
  • Dynamic player shadow

Gameplay improvements

Press to start!

The game starts with a small menu now. It’s done very simple: At the start the gameplay is initialized, but the spawning of enemies and the updating of the player is deactivated, while the flag “started” in the Gameplay class is set to false. So the background is scrolling, which makes an ingame-feeling in the menu. At the center of the screen a label “Press to start” is shown by the GUIStage class. When the user presses space, the “started“-flag is set to true and the Gameplay.update() method spawns enemies and updates everything.

The pause-state works nearly the same. There is a paused-flag, which is set to true, when the user hits escape. When paused is true, the whole update method does nothing anymore, but the Gameplay.draw() method still renders everything. A label “Pause” is shown by the GUIStage class.

Game Over!

As stated above the player can be killed now. This gameplay mechanic needed a bunch of things to be done. At first, the player can crash with the ground. Therefore a ground shadow was added. It gives the player a feeling of how much space is left between the ground and the spaceship.

Furthermore a collision with an missile decreases the health attribute. To show the health to the player, a health bar is needed. It consists of two images rendered at the same position (Check out GUIStage.java). A border image and a red inner image, which width is set dynamically according to the health.

To make the death more intense, a background-shake has been added and some explosion animations will spawn now. The explosions are spawned, too, when an enemy is being killed. I made this animation some time ago, so it did’t take a lot of time to implement this. Explosions are “SpawnObjects” which have their own pool, and are respawned by the SpawnPool, like enemies or missiles. Read more about the SpawnPool further down in the text.

The explosion animation consists of 8 frames.

At the player’s death, the gameover process is triggered. A short time offset of two seconds lets the explosion animations finish and makes the player realize that he just lost. The spawning of new enemies is stopped, the control of the player is deactivated but the background still moves. After these two seconds the “Game Over” label is shown and the player has to press a button again, to restart the game.

Items

Another new feature are items (Item.java). Items are spawning at a fixed interval with an own timer. They are managed by the SpawnPool, too. Currently there is only a heal-item but it is possible to define different types with own animations and effects. Items are surrounded by a bubble, which is an additional sprite rendered above the actual item.

A heal-item in a bubble

Obstacles

To make the game less monotone, I had the spontaneous idea to let some obstacles spawn (Obstacle.java). In the current version, a wave of clouds spawns from time to time, which have to be avoided by the player. Of course, it’s possible to add more types of obstacles later on.

The cloud with a thunder animation

Level generation

Since there are obstacles now, the generation of the spawn stages was improved. It works as follows: A stage has a fixed time limit (currently 20 seconds). Currently there are just four types of enemies. Every stage spawns another type of enemy. After four stages two types of enemies spawn at the same time for the next four stages. After these eight stages the spawn system begins at the first stage again, but with an decreased spawn interval to spawn more enemies. Check out calcLevel() and spawnObjects() in Gameplay.java.

After every two stages, there spawns an obstacle stage, which pauses the spawning of enemies. The duration of the obstacle stage increases every time a new obstacle stage spawns, so this part of the game becomes also harder with time.

The main part is done!

So for now, all core mechanics and features work fine! This is where the fun part starts: creating and adding more enemies, missiles, items, obstacles, levels and, of course, sounds. Also the GUI and the menu need some polish. Finally, some balancing has to be done to make the game as fun as possible. I’m looking forward to the next update!

To do:

  • More enemies and missile types
  • More items
  • More levels
  • Cosmetics (Menu, GUI)
  • Sounds
  • Balancing
  • …drink more coffee!

For those who are here just for the update: that’s all for now! Come back in a week to play the finished game! Until then, I appreciate every feedback and suggestion in the comments.

For more information about this “A Game A Month”-Project read this post.

Source code

Check out the source code of the current udpate on Github or download it here:

To import it to IntelliJ properly, check out my previous post.

More code!

For those who are interested: Like I stated in my previous post, I will dive deeper into the code in this blogpost. Especially the SpawnPool, which is the most important and helpful component of the game, I guess.

Check out the next page!

3 thoughts on “A Game A Month #1: Update – Nearly finished!

      1. 🙂
        Getting people to a blog isn’t easy. But here’s still little content. When you’ve published more articles you’re going to get more traffic from Google. Until then, just stick it out.

Leave a Reply to Stein Ove Helset Cancel reply

Your email address will not be published.