Giter Club home page Giter Club logo

tetris's Introduction

tetris

My ascii/cli rendition of tetris.

Installation

Source

If on linux, install libncursesw5-dev as dependency.

git clone 'https://github.com/k-vernooy/tetris' && cd tetris
make
sudo make install

Homebrew

brew tap k-vernooy/tap
brew install tetris

Usage

To begin the game, simply type tetris in the terminal. Levels can be specified by the flag --start-level x (where x is a number 1-25). The ghost block can be turned on from the command line as well, with --easy.

Control:

Use the arrow keys to control the falling blocks:

  • e to enable/disable the ghost block
  • to rotate the falling block
  • to move right
  • to move left
  • to soft drop. There are known bugs with soft dropping that will be fixed relatively soon. If the program is segfaulting for you, this is likely why.
  • SPACE to hard drop
  • CTRL+C at any time to quit the game

tetris's People

Contributors

heyallnorahere avatar jamesbarford avatar k-vernooy avatar seth-buchanan 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

tetris's Issues

Problem visualizing special characters on my customed project

Hi, I am trying to add a network protocol in your code in order to control it remotely. I configured this using cmake and cmakelist to add all the libraries which i need. But, when it compiled and everything was looking good, it didnt show special characters correctly represented. Thanks from a desperate student!

InkedWhatsApp Image 2022-05-09 at 7 12 52 PM_LI

Segfault

  1. Move first shape all the way to the left hold down.
  2. Move second shape all the way to the right hold down.

Seems to be 100% reproducible

backtrace:```

#0 0x00007f8663fd11f0 in __memcmp_avx2_movbe () from /usr/lib/libc.so.6
#1 0x00007f86642db630 in std::char_traits::compare (__n=, __s2=0x55ce2dadf614 " ", __s1=)
at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:347
#2 std::__cxx11::basic_string<char, std::char_traits, std::allocator >::compare (this=0x55ce2e55f980, __s=__s@entry=0x55ce2dadf614 " ")
at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1435
#3 0x000055ce2dad5d0e in std::operator==<char, std::char_traits, std::allocator > (__rhs=0x55ce2dadf614 " ", __lhs=...) at /usr/include/c++/10.2.0/bits/basic_string.h:6254
#4 std::operator!=<char, std::char_traits, std::allocator > (__rhs=0x55ce2dadf614 " ", __lhs=...) at /usr/include/c++/10.2.0/bits/basic_string.h:6256
#5 Shape::move (this=this@entry=0x7ffffa4077a0, movetype=movetype@entry=3) at src/shape.cpp:320
#6 0x000055ce2daddb20 in game (shape=..., screen=..., startLevel=8, easy=false, basename="bin/tetris") at src/game.cpp:83
#7 0x000055ce2dad35fd in main (argc=, argv=0x7ffffa4079c8) at /usr/include/c++/10.2.0/bits/stl_algobase.h:560

Fails to build and run in Gentoo

Greetings,

I've tried so long to successfully run this game but sadly, still can't.

In Gentoo (amd64, gcc-11.3.0, glibc-2.34-r13, ld 2.37, ncurses-6.3_p20220423) it fails to build:

mkdir -p bin build                                     
g++  build/main.o  build/shape.o  build/screen.o  build/game.o  build/functions.o -std=c++11 -MMD -MP  -O2 -lncursesw -o bin/tetris
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: build/main.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status                                                                                                                                    
make: *** [Makefile:30: main] Error 1

But learned that adding -ltinfo in Makefile's CXXFLAGS var lets it build:

mkdir -p bin build 
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/main.o src/main.cpp -c -o build/main.o
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/shape.o src/shape.cpp -c -o build/shape.o
src/shape.cpp: In member function 'void Shape::draw()':
src/shape.cpp:246:25: warning: format not a string literal and no format arguments [-Wformat-security]
246 |                 mvprintw(currentPos[0], currentPos[1], string("██").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shape.cpp:249:25: warning: format not a string literal and no format arguments [-Wformat-security]
249 |                 mvprintw(currentPos[0], currentPos[1], string("").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shape.cpp: In member function 'void Shape::groundDraw(int)':
src/shape.cpp:380:25: warning: format not a string literal and no format arguments [-Wformat-security]
380 |                 mvprintw(currentPos[0], currentPos[1], string("░░").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/shape.cpp:383:25: warning: format not a string literal and no format arguments [-Wformat-security]
383 |                 mvprintw(currentPos[0], currentPos[1], string("").c_str());
|                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/screen.o src/screen.cpp -c -o build/screen.o
src/screen.cpp: In member function 'void Screen::top()':
src/screen.cpp:30:11: warning: format not a string literal and no format arguments [-Wformat-security]
30 |     printw(readLine(screenstr, 0).c_str());
|     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/screen.cpp: In member function 'void Screen::draw()':
src/screen.cpp:64:27: warning: format not a string literal and no format arguments [-Wformat-security]
64 |                     printw(printChar.c_str());
|                     ~~~~~~^~~~~~~~~~~~~~~~~~~
src/screen.cpp:71:27: warning: format not a string literal and no format arguments [-Wformat-security]
71 |                     printw(string(" ").c_str());
|                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~
src/screen.cpp:75:23: warning: format not a string literal and no format arguments [-Wformat-security]
75 |                 printw(window[i][j].c_str());
|                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
src/screen.cpp:78:15: warning: format not a string literal and no format arguments [-Wformat-security]
78 |         printw(string("\n").c_str());
|         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/game.o src/game.cpp -c -o build/game.o
src/game.cpp: In function 'void game(Shape, Screen, int, bool, std::string)':
src/game.cpp:166:13: warning: format not a string literal and no format arguments [-Wformat-security]
166 |     mvprintw(9,8,string("Game over!").c_str());
|     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/game.cpp:167:13: warning: format not a string literal and no format arguments [-Wformat-security]
167 |     mvprintw(10,5,string("Try again? (y/n)").c_str());
|     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -MT build/functions.o src/functions.cpp -c -o build/functions.o
g++  build/main.o  build/shape.o  build/screen.o  build/game.o  build/functions.o -std=c++11 -MMD -MP  -O2 -lncursesw -ltinfo -o bin/tetris

But trying to run the output binary (bin/tetris) causes a segfault (Sorry, can't provide a coredump since I don't have debug symbols set up).

Is there something I'm doing wrong here? Not familiar with Make or debugging so am kind of lost here.

Brew tap deleted

The brew tap with this project on appears to have been deleted, was this intentional?

Tile doesn't fall all the way

As shown in the following image, there is a blue L-tile on the bottom right. This is a fully intact tile that I played several moves before ending the game. It was originally going to go above the square like this,

- - - - l
- - - - l
- - - l l 
- - - s s
- - - s s

but it lost its ability to fall upon contact while keeping the ability to move left and right for a little while before locking itself midair. By then, the next tile in the queue was able to be moved around as usual. I'd have expected to be able to move from side to side if in contact with a floor before locking, therefore falling until in contact with a floor. This may be a bug or way the game works (that I've never seen before), but whatever it is, I thought it should be made known.

Screenshot 2024-01-29 at 11 41 06 PM

Wrong placement of block

I moved a block just before it lands on top of another and then it got "stuck" midair with just the edges touching.
I also uploaded an image with the result: https://imgur.com/AyG4VPA where the blue left L shaped block stays in the air.

I think that block should drop to the lowest possible solution.

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.