Skip to content

erichsu7/Fortris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortris

Fortris is a browser-based version of the classic puzzle game, Tetris.

Play it here!

Technological Highlights

Overview

Fortris is built with JavaScript and rendered with jQuery DOM manipulation and CSS styling.

Object Oriented Design

Object orientation is a must for a game like Fortris. Pieces are made of blocks, which store coordinates. The board keeps track of its blocks. Pieces are further defined by their shape using prototypal inheritance, since each shape of piece needs its own Piece#rotate function.

Game Board

The board is stored as a bucketized hash, with row numbers as the keys and arrays of blocks as the values. This data structure allows for easy addition and subtraction of blocks. When the moving piece is placed, its blocks are deconstructed into their respective rows' block arrays. Once the row is full (the array is of a certain length), the entire blocks array is deleted, and the current row is assigned the blocks of the row above it recursively to cascade the blocks down.

Display

The front-end consists of a view which listens for key inputs and renders the game grid. Key inputs manipulate the falling piece's position and orientation on the back-end. The render function creates a <ul> full of other <ul> elements representing rows, each of which contains <li> elements for the cells in the grid. Then, CSS classes are added to each <li> according to the blocks in the board.

About

JavaScript implementation of Tetris. Unavoidably addicting!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors