GithubHelp home page GithubHelp logo

debugger-defense's Introduction

Debugger Defense

Play online!

Debugger Defense is a competitive typing game. Bugs crawl across the screen in the hopes of infiltrating your final product, so squash them by typing out their associated words! You have all the time in the world, but that's just the problem... they never stop coming! Commit yourself to the endless fight, and make your mark on the leaderboard.

Created by: Sarah Kat Peters, Skylar Prill, Peter Yao, Peter Zeng

Technologies

  • MERN Stack โ€” MongoDB, Express.js, React.js, Node.js
  • HTML's Canvas Element
  • JavaScript
  • Redux.js

Core Features

Fresh Gameplay

Debugger Defense is a new game every time you play. With Object Oriented Programming, we were able to make each Bug its own class, and thus kept track of local state and initialized each Bug to a different speed, starting position, and word. Our dictionary parsing tool and progressively steepening difficulty metrics make sure that you receive a varied dose of words, both short and long!

Bug Constructor
class Bug {
  constructor(difficulty, gameStartTime) {
    this.word = getRandomWord(difficulty);
    this.speed = Math.random() * (2000 - 500) + 500;
    this.radius = 45;
    this.difficulty = difficulty;
    
    let xPos, yPos;

    if (Math.random() > 0.5) {
      xPos = 5;
      yPos = Math.random() * (600 - 150);
    } else {
      xPos = Math.random() * (600 - 150);
      yPos = 5;
    }
    
    this.position = [xPos, yPos];
    
    // vectors to destination
    this.xDiff = 970 - this.position[0];
    this.yDiff = 570 - this.position[1];
  }

Iteractive Typing

It's all about typing. By chaining an event listener to the window, we allow the user to type madly at their keyboard without having to worry about clicking on a specific enemy. In order to keep the gameplay smooth across browsers and machines, we relied on the window's requestAnimationFrame() method to properly calibrate frame rendering and avoid jerky animations or skipping gameplay.

Event Listener for Typing
parse() {
    window.addEventListener("keydown", event => {
      for (let i = 0; i < this.bugs.length; i++) {
        for (let j = 0; j < this.bugs[i].word.length; j++) {
          if (this.bugs[i].word.charAt(j) === "_") {
            continue;
          } else if (event.key === this.bugs[i].word.charAt(j)) {
            this.bugs[i].word = this.bugs[i].word.replace(
              this.bugs[i].word.charAt(j),
              "_"
            );
            break;
          } else {
            break;
          }
        }
      }
    });
  }
requestAnimationFrame() Loop
animate() {
  this.detectCollision();
  this.detectFullSpelling();
  this.incrementDifficulty();
  this.draw(this.ctx);
  this.step();

  requestAnimationFrame(this.animate.bind(this));
}

Leaderboard

To keep users coming back, it's important to give them benchmarks against which to compete. By using asynchronous axios requests to the back-end, and by organizing the fetched data into the appropriate order, Debugger Defense keeps a current list of the top typing athletes. It updates as soon as you finish your game, so place yourself among the greats!

Formatting Scores with JavaScript XML
formatScores() {
  let counter = 0;
  const formatted = this.props.scores.map(score => {
      counter += 1;
      return (
        <li key={score.date} className="leaderboard-single-score">
          {this.counterColor(counter)}
          <div className="score-info">
            <br/>
            {score.username} 
            <br/> 
            {score.score} points
            <br/> 
            {score.secondsElapsed} seconds
            <div/>
          </div>
        </li>
        )
  })
  
  return formatted;
}

debugger-defense's People

Contributors

peteryao7 avatar peter-zeng avatar l412 avatar kat-onyx avatar pzengpzeng avatar

Stargazers

Steven Le avatar Josh Choi avatar Rikey Chen avatar Nero Chen avatar Christine Pham avatar Jerrik Shaw avatar Nikki avatar Julian Napolitan avatar Safuh Saray avatar Bao Tran avatar Micah Jaffe avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  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.