Code Monkey home page Code Monkey logo

spaceinvaders's Introduction

Code Climate Issue Count

Space Invaders

Game of Space Invaders created in Java without any game engine.

Runnable JAR can be found at SpaceInvaders/readme-resources/SpaceInvaders-MiroslavJelaska.jar

Do you like it? Show it by giving a โญ๏ธ. ๐Ÿš€

Preview of Space Invaders Game in Java (without game engine)

Game elements

Visual representation Package and class name Type
JFrame and Canvas game.Game (javax.swing.JFrame and java.awt.Canvas) ui
GameOverScreenOverlay - You Won GameOverScreenOverlay - You Lost ui.GameOverScreenOverlay ui
StatusRibbon ui.StatusRibbon ui
HeroShip actors.HeroShip actor
HeroProjectile actors.HeroProjectile actor
InvaderShip actors.InvaderShip actor
InvaderProjectile actors.InvaderProjectile actor
Explosion vfx.Explosion vfx

Execution flow

Explosion

Game mechanics

Controls

Action Key
โคŽ Move Left ย  A ย  ย  ย 
Move Right โคย  D ย  ย  ย 
Shoot ๐Ÿ’ฅ Spacebar

Points

Points are gained by destroying invader ships, 100 points per each. Bonus points are added for each destroyed ship depending on the time it was destroyed. The sooner in gameplay ship gets destroyed the more bonus points are gained.

Bonus points are given by following function:

  BonusPoints(time) = 1000 points * e^(-0.1 * time)

This is actualy function of exponential decay where total amount N0 is 1000 and exponential decay constant ๐›Œ is 0.1 within general formula equation.

Bonus points plot

Code snippet

  private static final int TotalBonusPoints = 1000;
  private static final double ExponentialDecayConstant = -0.1;
  private int bonusPointsWithExponentialDecay(long time){
      return (int)(TotalBonusPoints * Math.exp(ExponentialDecayConstant * time));
  }

Other

Useful resources

Color scheme

Color scheme is inspired by "monokai" color scheme. Colors used in game are:

  • #231f20 #231f20 (Game background)
  • #FFFFFF #FFFFFF (Hero)
  • #F92672 #F92672 (HeroProjectile)
  • #A6E22E #A6E22E (InvaderShip and StatusRibbon::Title)
  • #AE81FF #AE81FF (InvaderProjectile and Explosion)
  • #282828 #282828 (StatusRibbon::Background)
  • #E6DB74 #E6DB74 (StatusRibbon::Text)

Credits

Audio effects used in the game were downloaded from www.freesound.org and were under CC license. Here I'll mention authors and their audio tracks which were used in this game.

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.