Giter Club home page Giter Club logo

type-r's Introduction

Type-R

Live Link: https://antrivera.github.io/type-r/

Background

Type-R is a game centered around typing quickly and accurately. The player controls a ship (A "type-R" model) and must fend off alien ships by typing the words/letters that appear next to the given ship before it reaches the player.

MVP

  • Appropriate graphics and text appear near enemy ships
  • Typing correct letters/word fires bullets from the player ship at the enemy ship with the corresponding letters/word
  • Score keeping
  • Game Over detection / replay prompt

Screenshots and Gameplay

The player ship remains stationary towards the bottom of the screen as enemy alien ships descend from the top. As the player types the correct letters appearing underneath an enemy ship, lasers fire at the ship with the corresponding letters until all letters are entered correctly and the enemy is destroyed. If an alien ship reaches the player, it's game over.

wireframes

wireframes

wireframes

Technologies and Implementation Details

  • Vanilla JavaScript for core game logic
  • HTML5 Canvas for graphics
  • random-words npm package for the word bank

In order to get the player ship to automatically face the alien target, some simple trigonometry is used:

if (ship.hit(letter, this.target)) {
  this.target = ship;

  let x_len;
  if (Math.abs(ship.pos[0] - 250) <= 4) {
    x_len = 0;
  } else {
    x_len = ship.pos[0] > 250 ? (ship.pos[0] - 250) : -(250 - ship.pos[0]);
  }
  let y_len = 1100 - (ship.pos[1]);
  this.angle = Math.atan(x_len/y_len);

The PlayerShip object first sets the alien ship whose leading letter corresponds to the player input (if any such ship exists) as its target.

Next, since the player ship remains in a fixed position in the middle and at the bottom of the canvas, the target ship's position is used to acquire the proper angle that the player ship should face while firing.

A right triangle can be formed from the player ship to the alien target, and the lengths of the opposite and adjacent sides of this triangle relative to the angle that the player ship should make are obtained by simple subtractions from the players fixed position.

Finally, the angle is obtained through the arctangent function, using the previously mentioned side lengths.

To-do

  • Background music
  • Improved animations
  • Improved enemy AI and abilities
  • Wave/round based gameplay

type-r's People

Contributors

antrivera 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.