Code Monkey home page Code Monkey logo

coursework's Introduction

DESCRIPTION

This is game 'The Battleship'.

USAGE

  1. Clone this repository.
  2. Run file battleship.html using browser.

TEST

For testing the code in file game.js using ESLint you should run 'npm run lint' in terminal.

FEATURES

  1. using HTML for run this game in browser
  2. using element for drawing graphics in browser
  3. using browser events
  4. using classes for creating ships of players

coursework's People

Contributors

olegmak02 avatar

Watchers

Timur Shemsedinov avatar  avatar

coursework's Issues

Review

  • Use constants, for example here: outputMessage(str, x = 410, y = 800)
  • This is a good place for ternary:
    let ind;
    if (this.direction) {
      ind = this.coordsX.indexOf(x);
    } else {
      ind = this.coordsY.indexOf(y);
    }
  • Better use collection of functions instead of switch/case
  • Use constants: if (clickX > 390 && clickX < 830 && clickY > 520 && clickY < 660)
  • Decompose long expressions (see above)
  • Let's rewrite this:
function mousemove(e) {
  if (e.clientY < 465 && e.clientX < 465 &&
  e.clientY >= 115 && e.clientX >= 115) {
    onField = true;
  } else {
    onField = false;
  }
}

Here is better implementation:

const MIN = 115;
const MAX = 465;

const between = (val, min, max) => val >= min && val < max;
const inArea = val => between(val, MIN, MAX);

const mousemove = ({ clientY, clientX }) => inArea(clientY) && inArea(clientX);

Оформление репозитория

  • Добавить eslint и конфигурацию, лучше взять эту: .eslintrc.json
  • В файле README.md нужно 1-2 страницы описания проекта и кода
  • Добавить лицензию, например MIT
  • Добавить package.json с зависимостями, тем же eslint. Пример: package.json

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.