Giter Site home page Giter Site logo

osmos_game's Introduction

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

osmos_game's People

Contributors

mbeps avatar

Stargazers

 avatar

Watchers

 avatar

osmos_game's Issues

FEATURES: Show size along inside the entities.

Sometimes, when trying to engulf an enemy, is difficult to tell whether it is bigger or smaller. Displaying the size would make it easier to compare the size and decide whether to go of the kill.

IMPROVEMENT: Draw score dynamically

Draw the score dynamically as the size of the canvas changes. Alternatively, draw the text in the middle of the wall as the wall itself is dynamically draw according the canvas size.

FEATURES: Pause game

Add button and keyboard shortcut to pause the game. Everything in the game would be stopped including some of the handlers.

Engulf method inconsistent

When a larger ball eats a smaller ball the engulf function does not work properly. Sometimes the size of the bigger ball would not change whereas other times the ball would be massive (not the sum of the radii)

FEATURES: Lose mass when moving

When changing direction, lose mass. Eject the mass in the opposite direction of the ball. According to Newton's Laws every action has a opposite reaction and action requires external force. This means that to change velocity manually a reaction is needed, The mass would push the ball in the required direction.

FEATURE: Power up timer

Allow a limited time for which the player will have the power up. Once the time expires, the player will lose the powerup.

PROBLEM: Timer not working

User can set change the timer and the canvas size when asked. Calling the set_timer() function directly changes the timer correctly. However, when using the menu, the timer is not changed and the default one is kept, the function is called correctly.

PROBLEM: Solve the sticky problem

  • After a while some balls get stuck into the wall.
  • When engulfing close to the wall, the ball is also stuck as the size grows into the wall.

PROBLEM: All the enemies split at once

After the set time, all the enemies split at once. This is not seamless and sometimes the enemies combine again defeating the purpose. Making them split at different times would make the experience better,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.