Giter Site home page Giter Site logo

lights-out's Introduction

Lights Out

You will implement the game Lights Out. It is a game based on a 5x5 grid of lights. When it starts, some lights are on and some are off. When you press a light, it and its immediate four neighbors toggle. The goal is to turn all lights off. Play with the reference implementation at https://oose-lights-out.herokuapp.com. Even if you are bad at the game, you can win easily with the Cheat button. When you win, nothing will happen (see Homework 2), and all you can do is press New Game to start over.

The implementation is divided in two parts: server and client. They communicate via the Lights Out API, specified in the Postman Collection at docs/Lights Out API Specification.postman_collection.json.

Homework 1 · Server

Goals: Reading an API specification; setting up the development environment; web server programming in Java.

Import docs/Lights Out API Specification.postman_collection.json as a Postman Collection. Read the documentation and follow the instructions there.

When ready to start working on the server, import this project in IntelliJ as a Maven project and start at src/main/java/edu/jhu/cs/pl/lights_out/Server.java. You can store games in memory instead of using a database; games do not need to persist across server runs.

Homework 2 · Client

Goals: Adding features to an existing code base (written in part by someone else); web client programming in JavaScript; programming creatively.

Task 1 · Game Over

Nothing happens when the game is over. The player receives no feedback, but the lights no and the Cheat button no longer work. Worse, the browser continues to poll the server for the game state, though it will never change again, and may even perform bad requests if the player tries to press a light or Cheat. Fix all these issues by editing the client JavaScript. After you are done, the browser must not make a request that the server would respond with HTTP Status 400 or 404.

Be creative on how to provide feedback. The following is a version that flashes the lights, says “YOU WIN”, and starts a new game:

Game Over Feedback

You do not see this on the deployed version of the reference implementation because that would give away the answer to the homework.

Your version might use the light grid, sound, and so forth.

Task 2 · Multiplayer

Let multiple players play the same game together. Most of the heavy lifting is already done, players just need a way to share the gameIdentifier, and the client needs to be extended to pick up a given gameIdentifier, instead of always starting a new game.

When the page loads, check if a gameIdentifier is provided after the hash in the URL, for example, https://oose-lights-out.herokuapp.com/#d66c5ab2-6e8d-4129-a648-7aa8ec93291a. If it is, then do not start a new game, but use that gameIdentifier.

If no gameIdentifier is provided in the URL, or if the player starts a New Game, change the URL so it includes the new gameIdentifier. Players that want to play the game together should share that URL.

In JavaScript, location.hash allows you to read and write to the URL hash.

lights-out's People

Contributors

leafac avatar

Watchers

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