Coder Social home page Coder Social logo

tetris's Introduction

Tetris

What if we had no grid?

Up and running

Install node and yarn. Then:

yarn install
yarn global add browserify budo
./scripts/dev.sh

things

  • a shape
    • has a list of occupied cell coordinates (by x,y) at reference orientation
    • has presentation info (like color)
    • has a name?
  • the basic shapes: line, square, left-s, right-s, left-l, right-l, tee
  • a piece
    • is of a shape
    • at an orientation (0-3)
    • at a position (x:0-10; y:0-20; 0,0 at top left)
  • a dead cell
    • is of a shape (e.g., for color)
    • at x,y
  • a game
    • has a list of dead cells
    • has a live piece (could be 1st/last in list?)

events

  • on start:
    • add/make live piece:
      • random shape
      • x position near middle
      • if would violate, do end
  • on tick or down move:
    • move down 1
    • handle potential landing
  • on lateral move (left/right):
    • unless would violate
    • move piece 1 left/right
  • on rotate:
    • unless would violate
    • increment live piece orientation 1, modulo 4
    • handle potential landing

functions

  • would violate: given a candidate piece whether:
    • piece extent would exceed x-boundary (0,10)
    • piece would overlap a dead cell
  • potential landing:
    • if live piece: did land:
      • add its cells to dead cell list
      • for any complete (gapless, edge-to-edge) row in dead cell list
        • remove all cells in the row
        • move all cells above the row down
      • increment score by some function of count of lines removed
      • do start
  • did land: whether any:
    • any cell of live piece is any:
      • directly above (y-1) that of any dead cell
      • on bottom row

presentation

  • on any change, render grid of cells:
    • for each x,y, display for shape in that x,y
  • tick every second or so

tetris's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

phpsmarter

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.