Code Monkey home page Code Monkey logo

tinytetris's Introduction

tinytetris

80x23 terminal tetris!

tinytetris gif

tinytetris.cpp

This is the 80x23 version. You control it with a (left), d (right), w (rotate), s (drop), and q (quit). It depends on curses.h (so you'll need to compile with -lcurses, and install curses if you don't already have it) and requires C++11.

tinytetris-commented.cpp

This one is almost identical to tinytetris.cpp, but not minified, and with some comments to make it easier to read (but it's still tricky to read in certain parts).

build binary tinytetris-commented.cpp

g++ -o tinytetris-commented tinytetris-commented.cpp -lncurses

tinytetris's People

Contributors

chungy avatar cjauvin avatar greentea666 avatar taylorconor avatar vocalfan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinytetris's Issues

I cannot make it.

linux:~/code/other/tinytetris$ make
g++   -lcurses  tinytetris.cpp   -o tinytetris
/tmp/ccNKijAL.o: In function `F()':
tinytetris.cpp:(.text+0xf7): undefined reference to `move'
tinytetris.cpp:(.text+0x161): undefined reference to `stdscr'
tinytetris.cpp:(.text+0x171): undefined reference to `wattr_on'
tinytetris.cpp:(.text+0x184): undefined reference to `printw'
tinytetris.cpp:(.text+0x19c): undefined reference to `stdscr'
tinytetris.cpp:(.text+0x1ac): undefined reference to `wattr_off'
tinytetris.cpp:(.text+0x1ce): undefined reference to `move'
tinytetris.cpp:(.text+0x1e7): undefined reference to `printw'
tinytetris.cpp:(.text+0x1ec): undefined reference to `refresh'
/tmp/ccNKijAL.o: In function `L()':
tinytetris.cpp:(.text+0x634): undefined reference to `stdscr'
tinytetris.cpp:(.text+0x63c): undefined reference to `wgetch'
/tmp/ccNKijAL.o: In function `main':
tinytetris.cpp:(.text+0x83f): undefined reference to `initscr'
tinytetris.cpp:(.text+0x844): undefined reference to `start_color'
tinytetris.cpp:(.text+0x877): undefined reference to `init_pair'
tinytetris.cpp:(.text+0x89c): undefined reference to `resizeterm'
tinytetris.cpp:(.text+0x8a1): undefined reference to `noecho'
tinytetris.cpp:(.text+0x8a8): undefined reference to `stdscr'
tinytetris.cpp:(.text+0x8b5): undefined reference to `wtimeout'
tinytetris.cpp:(.text+0x8bf): undefined reference to `curs_set'
tinytetris.cpp:(.text+0x8c6): undefined reference to `stdscr'
tinytetris.cpp:(.text+0x8d8): undefined reference to `box'
tinytetris.cpp:(.text+0x8e2): undefined reference to `endwin'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'tinytetris' failed
make: *** [tinytetris] Error 1

what's the meaning of "262176" ?

I read the code in "frame()" function and find that " attron(262176 | board[i][j] << 8)", I know what attron means, but I don't understand 262176, what's the meaning?

BUG: new_piece()

It seems that when calling new_piece() a new piece may be created where there is already a piece.

usage of memset

void remove_line()
{
  for (int row = y; row <= y + NUM(r, 18); row++)
  {
    c = 1;
    for (int i = 0; i < 10; i++)
    {
      c *= board[row][i];
    }
    if (!c)
    {
      continue;
    }
    for (int i = row - 1; i > 0; i--) 
    {
      memcpy(&board[i + 1][0], &board[i][0], 40);
    }
    memset(&board[0][0], 0, 10);  // **# I feel like it should be 40**
    score++;
  }
}

make error

wenc@wenc-virtual-machine:~/hellogithub/tinytetris$ make
g++ tinytetris.cpp -lcurses -o tinytetris
tinytetris.cpp: In function ‘I F()’:
tinytetris.cpp:10:73: error: ISO C++ forbids declaration of ‘z’ with no type [-fpermissive]
+y][N(r,(i2)+2)+x]=v;}I F(){for(I c=0;c<20;c++){move(1+c,1);for(auto &z:a[c]){
^
tinytetris.cpp:10:75: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
+y][N(r,(i
2)+2)+x]=v;}I F(){for(I c=0;c<20;c++){move(1+c,1);for(auto &z:a[c]){
^
tinytetris.cpp: In function ‘I R()’:
tinytetris.cpp:14:12: error: ISO C++ forbids declaration of ‘z’ with no type [-fpermissive]
;for(auto &z:a[q])c*=z;if(!c)continue;for(I c=q-1;c>0;c--)memcpy(&a[c+1][0],&a[
^
tinytetris.cpp:14:14: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
;for(auto &z:a[q])c*=z;if(!c)continue;for(I c=q-1;c>0;c--)memcpy(&a[c+1][0],&a[
^
: recipe for target 'tinytetris' failed
make: *** [tinytetris] Error 1

Add CMakeLists.txt

It's good if there's a CMakeLists.txt。I write one that works for me. In this case, you need to create build and src folder, and put the code that needs compilation in src:

cmake_minimum_required (VERSION 3.0)


project(terris_demo)


find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})

aux_source_directory(src terris_src)

add_executable(${PROJECT_NAME} ${terris_src})
target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})

Game borders fly away

Proof

Снимок экрана 2022-05-10 в 21 55 28

Libs

What should I provide? I don't know anything about C++, so tell me which libs versions I should add to this Issue.

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.