/Chicken-invaders-game

This is the Chicken Invaders Game in the Browser

Primary LanguageJavaScript

Chicken Invaders Game

Chicken-invaders

Gameplay ๐Ÿ•น๏ธ Leaderboard ๐Ÿ†
Instructions Leader

you can view at :

Chicken Invaders Game

High-level Diagram ๐Ÿง

UML

Folder Structure


โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ about
โ”‚   โ”œโ”€โ”€ audio
โ”‚   โ”‚    โ””โ”€โ”€spaceinvaders1.mpeg
โ”‚   โ””โ”€โ”€ js
โ”‚       โ””โ”€โ”€about.js
โ””โ”€โ”€ css
    โ”œโ”€โ”€ App.css # Styles for instructions. Feel free to customize this as you desire.
    โ”œโ”€โ”€ home.css # Styles for index html file
    โ”œโ”€โ”€ leader.css # Styles for leaderboard html file
    โ”œโ”€โ”€main.css # Styles for game html file
    โ”œโ”€โ”€js
    โ”‚  โ”œโ”€โ”€board.js #contains logic for leader-board
    โ”‚  โ”œโ”€โ”€Config.js #contains the configurations for game loop
    โ”‚  โ”œโ”€โ”€Enemy.js #contains the Enemy Class
    โ”‚  โ”œโ”€โ”€Game.js #contains the Game Class
    โ”‚  โ”œโ”€โ”€Helper.js #contains some Helper functions
    โ”‚  โ”œโ”€โ”€home.js #contains player creation modal logic
    โ”‚  โ”œโ”€โ”€Laser.js #contains the Laser Class
    โ”‚  โ”œโ”€โ”€modal.js #contains the Pause modal logic
    โ”‚  โ”œโ”€โ”€Player.js #contains the Player Class
    โ”‚  โ”œโ”€โ”€Present.js #contains the Present Class
    โ”œโ”€โ”€ Images # Helpful images for the app. Use at your discretion.
    โ”‚   โ”œโ”€โ”€ egg.png
    โ”‚   โ”œโ”€โ”€ player-blue-1.png
    โ”‚   โ””โ”€โ”€ laser-blue-1.png
    โ”œโ”€โ”€sound #contains the game sounds
    โ”œโ”€โ”€ game.html #the game loop ui
    โ”œโ”€โ”€ index.html #the home page ui
    โ”œโ”€โ”€ Instructions.html #the instructions ui
    โ”œโ”€โ”€ leaderboard.html #the leaderboard ui
    โ””โ”€โ”€ Main.js # You should not need to modify this file. It is used for the game main loop Logic.

Enemy Class ๐Ÿ”

Is responsible for creating the chickens , the way they move , how they die and the time they shoot.

create($container, src)

This function is responsible for the chicken creation.

destroy($container, enemy)

This is function is used to destroy the chicken and removing it from the DOM.

Present Class ๐ŸŽ‰ ๐Ÿ—

This class is used to create roasted chicken and append it to the DOM when the chicken explodes.

create($container, src)

This function is used to create the roasted chicken and append it to the DOM.

destroy($container, enemy)

This function is used to remove the roasted chicken from the DOM if it is eaten by the space ship or when it hits the game border.

Laser Class ๐Ÿ’ฅ

is responsible for creating the player laser and enemy laser .

create(container):

it is responsible for creating player laser and pushing the created laser to the Laser array in the class Game.

createEnemyLaser(containers):

it is responsible for creating enemy laser and pushing the created laser to the enemyLaser array in the class Game


updateLasers(dt,containers):

it is responsible for moving player laser in right direction & check if the laser hit the enemy


destroyLasers(containers,laser):

it is responsible for destroy the laser and remove it from Dom


updateEnemyLasers(dt,containers):

it is responsible for moving enemy laser in right direction & check if the laser hit the player and decrease the lives if the collision is happened

Player Class

Player class has implemented methods for creating the player, updating player position, destroying the player, and winning

create($container, imgSrc)

Creates a new player (Dom element)

update(dt, $container)

Updates the position of the player on the screen. It calculates the distance based on the physics law: distance=time*speed.

destroy(container, player)

Removes the player, the DOM element, from the screen after getting hit by the enemy weapon (eggs).

won()

Returns true if all enemies are destroyed and no presents on the screen.

clamp(v,min,max)

Keeps the player on the screen limits and force the player not to Exceed them

Game Class ๐Ÿ•น๏ธ ๐ŸŽฎ

init()
  1. It is responsible for initating the game by creating all the enemies
  2. Creates the Player
  3. Handles the Spacing between the chickens
  4. Handles the level logic