mbeps / Osmos_Game

A simple Osmos Game programmed using Python and SimpleGUI library. Player will have to kill all the enemies to win.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Osmos Game

Introduction

The game is called Osmos. The main objective is for the player to kill and engulf all the enemies. All the balls bounce against walls upon collisions. There is also gravity acting upon entities; mass objects and other enemies are attracted to each other but not the player. Since mass objects do not merge, they are never bigger than the enemies which means that they are always attracted to the enemies. Gravity acts on the bigger enemies too but the force is much weaker.

The bigger ball engulfs the smaller balls. Gravity makes it easier to engulf entities. If the player is larger than the enemy, then then the enemy is engulfed and killed. However, if the enemy is larger, then the player is killed, and the game is over. When player moves close to an enemy, it will eject mass into the enemy to move away from it, this will attract the enemy towards the player and increases its size. Because enemies can engulf each other and merge into a massive enemy, it makes it hard for the player to win which means that a timer has been implemented to split the enemies into smaller ones, this gives a chance for the player to win. Mass objects which are ejected by the player are also engulfed. Once a ball engulfs another, the size increases.

For the player to move via the controls, mass is lost. This mass is ejected in the opposite direction to simulate Newton’s Laws. As mentioned before, this is then engulfed by others.

At a set time, power ups will be spawned at a random place in the canvas. These power ups increase the speed of the player for a limited time. In the future, more types of power ups can be added.

A timer can be set which defines the time limit by which time the player must win. If the timer runs out before the player has killed all the enemies, then the game is over.

Technology

The game is made a using the SimpleGUI module developed by CodeSkulptor3 for Python (version 3). Instructions are included bellow. Using this module, simple GUI applications can be built. A vector module has been used to handle all the vector calculations.

Resources:

Rules

  • Control the player with the arrow keys.
  • Bigger balls kill the smaller ball.
  • Player wins when all the enemies are dead.
  • Player loses if the it gets killed or the timer runs out (if set).
  • Balls (enemies, player) bounce if there is a collision with the wall.

Features

  • Power ups increase player speed for limited time.
  • Time limit (can be unlimited).
  • Gravity between objects.
  • Display scores.
  • Mass is ejected from player when moving using arrow keys.
  • Enemy is split after a set time to make the game play more fair.

Controls

  • Left arrow (←) - player moves left.
  • Right arrow (→) - player moves right.
  • Up arrow (↑) - player moves up.
  • Down arrow (↓) - player moves down.
  • E - exit game.

Demo Videos

Winning

Winning.mp4
  • Player wins when there are no more enemies in the game.
  • Number of kills displayed in game.

Losing

Losing.mp4
  • When player is dead because it was killed by an enemy.
  • Timer has ran out.

Power Ups

Power.Ups.mp4
  • If the player peeks up a power up, it will get faster temporarily.
  • Power ups spawn in random places in the canvas at certain times.

Split

Split.mp4
  • At certain times, a random enemy will be split.
    • Two smaller enemies will be created to give the player a chance to kill.
  • Only split when the enemy is large.

Timer

Timer.mp4
  • When the timer is set, there is a time limit by which the player must win.
  • If the timer is not set, then the game place is unlimited (until enemies are dead or player is dead).
  • Timer is a countdown displayed in the game.

Gravity

Gravity.mp4
  • Enemies and mass (ejected by player) are attracted to each other.
  • Bigger ball object has a larger pull on the smaller object.
  • Smaller ball object attracts the larger ball but the force is only a fraction of the attraction of the larger ball on the smaller.
  • Mass objects cannot merge (engulf each other) which means that they always have a set size which is smaller than the any enemy.
    • Mass always strongly attracted to enemies.
    • Multiple mass objects in one place (when ejected from same spot by player) have enough force to significantly move large enemy object.
  • Player does not attract any ball objects.

Installation

SimpleGUI requires Python 3 to be installed. Game developed using Python 3.10. Poetry project manager has been used for managing dependencies.

Install Project Dependencies

poetry install

Running

Run the main.py using Python 3. Make sure that you are in the directory where the game is stored.

poetry run python main.py

Documentation

This section explains how the game fundamentally works.

Game Plan

This section explains the simple core mechanics of the game. Game Over

image

  • Player will engulf other balls (mass or enemies) to increase size.
  • Mass will be lost to move - Mass will push in opposite direction.
  • Enemies can engulf mass - If player is engulfed then the game is over.

Bouncing

image

  • All ball types of balls:
  • Player
  • Enemy
  • Particles
  • Inheritance
  • All balls can inherit bounce, ingulf, etc methods

Engulfing

image

  • If ball1 > ball2:
  • Ball1 engulfs ball2.
  • Else If ball2 > ball1:
  • Ball2 engulfs ball1. Logic
  • If ball1 > ball2
  • Ball1 gets mass from ball.
  • Ball2 is removed.

Moving

image

  • Newtons third means that the smaller mass will push the player.
  • Mass will be faster than the player as player will be bigger.
  • Both mass and player will have equal momentum
  • Enemies do not lose mass but slit after some time

Structure

This section shows the core structure of the game. It demonstrates how components link to each other.

Game Structure

Modules & Classes

Entities:

  • Ball - the super class for enemies, player, mass, and power ups which defines the basic functionalities of a ball such as bouncing.
  • Enemy - sub-class of Ball which defines how an enemy should function.
  • Mass - sub-class of Ball which defines how mass should behave. Mass is normally ejected from the player when controlling it.
  • Player - sub-class of balls controlled by the user to kill all the enemies and win.
  • Power_Ups - sub-class of ball which is spawned in random places and does not move. Gives a temporary power up to the player.

Game_Control:

  • Interactions - this module manages all the interactions between objects and the the game environment.
  • Keyboard - handles and keeps track of the key presses which can then be used to execute certain operations depending on the keys that were pressed.
  • Vector - manages all the vector calculations.

Maps:

  • Line - these are the walls around the canvas which represent the boundary of the game. Ball objects bounce upon collision.

License

MIT

About

A simple Osmos Game programmed using Python and SimpleGUI library. Player will have to kill all the enemies to win.

License:MIT License


Languages

Language:Python 100.0%