Coder Social home page Coder Social logo

space_shooter's Introduction

CS50 Final Project -- 2D Spaceshooter game

Description:

Spaceshooter is a 2D game written in Typescript with Pixi.js. The objective of the game is to shoot down things. At Level 1, your objective, as a player, is to shoot down asteroids. At Level 2, the objective is to shoot down the “spawn”.

This game has been an excellent opportunity for me to improve on Objected-Oriented Programming and some other patterns such as:

  1. Factory: asteroids are spawned and animation is created using a Factory pattern
  2. Singleton which took the form of both a class and a mixin/decorator. A Singleton class was used for the Asset Manager to make all the assets available from one place while the mixin was used to share components across different levels of the game (e.g. some UI elements, the player's ship)
  3. Object Pooling: asteroids and projectiles are reused when killed or disappear, ie their position is reset to a random horizontal location.
  4. Collision detection: implemented Axis-aligned Bounding Box collision for projectiles. The projectiles can collide with the asteroids, the “spawn”, the player, and other projectiles (such as the one shot by the spawn). It was not optimized to the "T", but the result was sufficient for my use case.

Challenges:

The key challenge was applying the OOP pattern which I am not totally confident with. Also, it was my first encounter with the Pixi.js library, albeit not the first one with the Typescript. Another limiting factor was constantly choosing between Composition and Inheritance.

Misc:

How to run locally:

  1. Clone the repo
  2. Run pnpm i to install dependencies
  3. Run pnpm dev to open the game at http://localhost:5173/

The game is won when:

  • You have destroyed all asteroids (8 hits)

The game is lost when:

  • 60 seconds have lapsed;
  • You are out of ammo and the 60 seconds of game time are still going;

Level 1: Preview image of how the game looks

Level 2: image

space_shooter's People

Contributors

pavsoldatov avatar dependabot[bot] avatar

Watchers

 avatar

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.