Giter Club home page Giter Club logo

tetris's Introduction

tetris

An implementation of the basic tetris game principle, rendered with ncurses in a terminal.

The heart of this project is contained in the folder tetris. The goal of this implementation is to be as memory-efficient as possible. No inheritance is used. C++'s principle of zero overhead guarantees that the object-oriented style doesn't cost additional resources while maintaining optimal readability of code.

The memory efficience is established by defining each tetris shape exactly once in memory, and the I and O shapes share the same memory representation. Rotations are achieved by modifying the coordinate access to the shape. (The access is based on the fact that rotating a matrix 90° corresponds to transposing it and then inverting the order of columns.)

Attention: The coordinates are used like matrix indices, for example

(i/j) = (h/w)

(0/0) (0/1) (0/2)

(1/0) (1/1) (1/2)

(2/0) (2/1) (2/2)

In the main program a fully working tetris implementation using the above library is shown. Rendering is done with the library ncurses

The GUI in the terminal.

tetris's People

Contributors

meteoritenhagel avatar

Watchers

 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.