Skip to content

๐Ÿ‘พ A 2D platformer game developed using a Physics Engine - Year 1 CS Coursework

Notifications You must be signed in to change notification settings

hstoklosa/CityPlatformer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‘พ CityPlatformer | 2D Game

Concept

The game is a 2D platformer developed in Java, utilising a physics engine to stimulate the game world. It presents a dynamic and engaging experience, mixing typical platforming elements with a focus on creativity.

The main idea of the game is that the player should navigate through various levels, each presenting unique environments with its own challenges, by using portals that are found on the pre-defined locations.

The environments consists of entities such as

  • various types of enemies that could be static/dynamic
  • collectibles to be picked up by the player
  • interactive and non-interactive blocks

Your objective is to collect as many coins as possible by playing this character , using the following controls in game. The character is equipped with a name, health and stamina, and it can be recharged throughout the game.

In order to make the game more modern and visually pleasing, I have decided to implement a system (i.e., with SpriteLoader and AnimationHandler) which applies appropriate animations to the bodies defined in the physics library using spritesheets.

Animation Examples:

  • Idle character
  • Moving character (including walk and run)
  • Jump (and double jump)
  • Spinning coin
  • Portal enchantment

Preview

Main Screen & Other

Button A Button A

Gameplay

Level 1 Gameplay

Gameplay

Gameplay

Controls

The game's controls are hard-coded, however you can use ESC button to pause the game and access some of the available options.

Key Action Description
Button A Movement Move to the left.
Button D Movement Move to the right.
Button CTRL Sprint Sprint on left/right movement with stamina decaying over time.
Button SPACE Jump Space - normal jump
Space x 2 - double jump
Button S Save Save the current game state by overrwriting the most recent save in saves.txt file.
Button L Load Load most recent save from saves.txt file.
Button R Restart Restart the current level by restoring factory options.
LMB Shoot Shoot a slow, short range bullet that deals a big amount of damage.
RMB Shoot Shoot a quick, long range bullet that deals a small amount of damage.

Enemies

The enemies inserted onto each level are the biggest threat to the player since their main objective is to prevent the player from progressing onto further levels by dealing damage.

As the enemy is destroyed, a coin is spawned and it can be collected by the player to increase game score.

Types

Image Name Description
Bunny Enemy Image BUNNY A dynamic enemy that deals damage using melee attacks on close range.

The enemy is aware of the main player's presence and it will automatically go towards the player's location if presence is detected.
Slime Enemy Image SLIME A static enemy that has a shooting ability.

The enemy is aware whenever a player enters its specified range in order to start dealing damage with bullets.
Slime Enemy Image SPIKE A static enemy dealing damage on contact. The spike deals damage on contact and bounces the player until the player runs out of health/manages to get out.

Collectibles

Collectible Spawning

  • Collectibles are placed at pre-defined coordatinates - randomising this process can be a future objective.
  • Collectibles have a chance to spawn when an enemy is destroyed. The choice of item is random, but the chance of an item spawning is the same for all collectibles.
Image Name Description
Coin Collectible Image COIN Increases score by 5 points.
Melon Collectible Image MELON Regenerates 15 health points.

Blocks

Image Type Name Description
Green Basic Tile
Purple Basic Tile
Red Basic Tile
NON-INTERACTIVE
/
STATIC
TILE Static tile that is part of the terrain and its design.
Moving Platform Tile INTERACTIVE PLATFORM A moving platform that transports the player by jumping onto it.

It can be moving in the horizontal or vertical direction.
Platform Block INTERACTIVE PORTAL Portal that takes the player onto the next level unless an enemy is still alive on the current level.
Chest Block INTERACTIVE CHEST A chest holds a random collectible. The collectible can be discovered by hitting the chest 3 times.
Trampoline Block INTERACTIVE TRAMPOLINE Allows the player to bounce e.g., onto a higher platform.

The higher the person falls, the higher the bounce rate.

Saving & High score

Saving

In order to save the current state of the game, the player must use the S control/keybind to overwrite the CityPlatformer/saves.txt file.

This data can be later loaded in the game using either the main menu button or the L control. This will appropriately read the file using streams and load the data into the respective world.

High score

Highscore Game Screen

As soon as the player finishes the last level, the game will look into the CityPlatformer/scores.txt file to find the appropriate position for the final score and name of the player.

This data can be later accessed using the high score screen within the game.

Planned features

  • Use MySQL to store scores and saves (partially done)

Copyright & Licenses

Code

All code is written by me, unless it has been referenced.

Additionally, the project includes a physics engine library city.cs.engine that was provided by CUoL (unknown license).

Font

The font used in this project is PressStart2P, which was designed by CodeMan38. It is publicly available at Google Fonts, licensed under the SIL Open Font License.

Art

The art in this game came from Pixel Adventure 1 and Pixel Adventure 2, created by Pixel Frog and released under a Creative Commons Zero (CC0) license.

Some of the graphics were slightly modified by me using the GIMP software, which is approved by the license even for commercial purposes.

Sounds

The music track and sound effects were gathered from Nosoapradio and FreeSound sites, licensed under the Creative Commons License.


ยฉ 2024 H. Stoklosa - [email protected]

https://github.com/hstoklosa

About

๐Ÿ‘พ A 2D platformer game developed using a Physics Engine - Year 1 CS Coursework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages