Code Monkey home page Code Monkey logo

coffeescript-game-life's Introduction

Игра ЖИЗНЬ на CoffeeScript

Перевод реализованной на Ruby (https://github.com/nemilya/ruby-game-life) игры, на CoffeeScript.

На базе BDD.

Демо: http://nemilya.github.com/coffeescript-game-life/html/game.html

Бралась спецификация на Ruby: https://github.com/nemilya/ruby-game-life/blob/master/spec/game_life_spec.rb и последовательно - переводилась на Jasmin/CoffeeScript.

В папке _ruby находится оригинал - спецификация для Руби, и реализация на Руби.

В режиме автотестирования, с параллельным создание класса GameLife в lib/game_life.coffee

Про настройку тестирования CoffeeScript - здесь можно прочитать: https://github.com/nemilya/coffeescript-spec-demo

Для генерации JS команда:

coffee -c game_life.coffee

Будет сгенерирован game_life.js. Единственное я там поменял

exports.GameLife = GameLife;

на:

this.GameLife = GameLife;

После этого он подключается, весь html код:

<html>
  <head>
    <title>CoffeeScript Game Life</title>
    <script src="game_life.js"></script>
  </head>
<body>
<pre id="generation" style="font-family: Courier;">
........
..***...
........
</pre>

<script>
  var game = new GameLife({empty_cell:'.', live_cell:'*'})
  var field = document.getElementById('generation');
  generation = field.innerHTML;
  game.set_generation(generation);

  function do_step(){
    game.do_step();
    new_generation = game.screen();
    field.innerHTML = new_generation;
  }
</script>

<button onclick="do_step()" >Step</button>

</body>
</html>

coffeescript-game-life's People

Contributors

nemilya avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

meettya

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.