GithubHelp home page GithubHelp logo

tetris's Introduction

Hi there 👋

  • 🦀 I like writing code, typically in Rust these days.
  • 📋 I write infrequently at samtay.github.io.
  • 💎 I write more frequently in obsidian, but not for public consumption.

tetris's People

Contributors

jose1711 avatar kommusoft avatar samtay 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

tetris's Issues

Is it possible to change the color of the blocks?

I want to have them all black. It seems that you are using the terminal colors. I have almost zero experience with Haskell, so if you can provide me with instructions on how to change the color, I'd be really grateful!

Cant install from source on openSUSE Tumbleweed

When I run 'slack install tetris' I get this error:

/usr/bin/ld.bfd: cannot find -lgmp: No such file or directory
collect2: error: ld returned 1 exit status
ghc-9.6.4: gcc failed in phase Linker. (Exit code: 1)

Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error)
       using:
       /home/sparky/.stack/programs/x86_64-linux/ghc-tinfo6-9.6.4/bin/ghc-9.6.4 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-3.10.1.0 /home/sparky/.stack/setup-exe-src/setup-HwdwpEmb.hs /home/sparky/.stack/setup-exe-src/setup-shim-HwdwpEmb.hs -o /home/sparky/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_HwdwpEmb_3.10.1.0_ghc-9.6.4

How do I fix this?

Build error NB: the module ‘Graphics.Vty’ does not export ‘mkVty’.

If I build this project I get the following error message:

src/UI/Game.hs:69:17: error: [GHC-76037]
    Not in scope: ‘V.mkVty’
    NB: the module ‘Graphics.Vty’ does not export ‘mkVty’.
    Suggested fix:
      Perhaps use data constructor ‘V.Vty’ (imported from Graphics.Vty)
   |
69 |   let builder = V.mkVty V.defaultConfig
   |                 ^^^^^^^
[3 of 3] Compiling UI.PickLevel     ( src/UI/PickLevel.hs, dist/build/UI/PickLevel.o, dist/build/UI/PickLevel.dyn_o )
error: builder for '/nix/store/lqw7zgbhxz4g4zh27g6wyb06j8yg340g-tetris-0.1.4.1.drv' failed with exit code 1;
       last 10 log lines:
       >
       > src/UI/Game.hs:69:17: error: [GHC-76037]
       >     Not in scope: ‘V.mkVty’
       >     NB: the module ‘Graphics.Vty’ does not export ‘mkVty’.
       >     Suggested fix:
       >       Perhaps use data constructor ‘V.Vty’ (imported from Graphics.Vty)
       >    |
       > 69 |   let builder = V.mkVty V.defaultConfig
       >    |                 ^^^^^^^
       > [3 of 3] Compiling UI.PickLevel     ( src/UI/PickLevel.hs, dist/build/UI/PickLevel.o, dist/build/UI/PickLevel.dyn_o )
       For full logs, run 'nix log /nix/store/lqw7zgbhxz4g4zh27g6wyb06j8yg340g-tetris-0.1.4.1.drv'.

Dashed block

Hello,
very nice realization. Out of curiosity, how did you do the "dashed" pieces?
image

It seems to be with attributes, but I'm not sure.

Problem: The CPU resource demand increases

If tetris is put into sleep mode with the pause command it starts to increase its demand of the CPU resource. After a few days pausing it consumes currently more than 25 parts of 100 on a 8 core CPU (i.e. 255.99%). Top shows

last pid: 18889;  load averages:  6.47,  6.29,  6.66                   up 330+11:44:16 13:34:35
470 processes: 2 running, 467 sleeping, 1 waiting
CPU: 44.6% user,  0.0% nice,  1.7% system,  0.1% interrupt, 53.5% idle
Mem: 7322M Active, 7881M Inact, 6698M Laundry, 8742M Wired, 502M Buf, 1170M Free
ARC: 3830M Total, 2307M MFU, 832M MRU, 800K Anon, 74M Header, 617M Other
     1725M Compressed, 5208M Uncompressed, 3.02:1 Ratio
Swap: 64G Total, 38G Used, 26G Free, 58% Inuse

  PID USERNAME    THR PRI NICE   SIZE    RES STATE    C   TIME    WCPU COMMAND
   11 root          8 155 ki31     0B   128K CPU0     0    ??? 428.23% idle
12283 xxxxxx       20  20    0   881M   801M uwait    3 153.3H 255.99% tetris
88553 yyyyyy        6  20    0   246M   124M uwait    5  91.4H  87.21% ghc-9.4.6

What's going on there?
When put into sleep mode it starts with consuming only very little (1.12%) of the CPU resource:
18900 zzzzzz 20 20 0 121M 26M uwait 4 0:00 1.12% tetris

Error when trying to install on Debian 11

➜  tetris git:(master) stack install tetris

HttpExceptionRequest Request {
  host                 = "raw.githubusercontent.com"
  port                 = 443
  secure               = True
  requestHeaders       = [("User-Agent","The Haskell Stack")]
  path                 = "/fpco/stackage-content/master/stack/stack-setup-2.yaml"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (StatusCodeException (Response {responseStatus = Status {statusCode = 503, statusMessage = "Service Unavailable"}, responseVersion = HTTP/1.1, responseHeaders = [("Connection","keep-alive"),("Cache-Control","no-cache"),("Content-Type","text/html; charset=utf-8"),("Strict-Transport-Security","max-age=31536000"),("X-Content-Type-Options","nosniff"),("X-Frame-Options","deny"),("X-XSS-Protection","0"),("Content-Security-Policy","default-src 'none'; style-src 'unsafe-inline'"),("Fastly-Restarts","1"),("Accept-Ranges","bytes"),("Date","Wed, 12 Jan 2022 02:26:20 GMT"),("Via","1.1 varnish"),("X-Served-By","cache-cgh11131-CGH"),("X-Cache","MISS"),("X-Cache-Hits","0"),("X-Timer","S1641954373.926645,VS0,VE7275"),("Access-Control-Allow-Origin","*"),("X-Fastly-Request-ID","82353a753b9eb3bd81cec5e9e77f2a174ff967a9"),("Expires","Wed, 12 Jan 2022 02:31:20 GMT"),("Vary","Authorization,Accept-Encoding"),("transfer-encoding","chunked")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "<!DOCTYPE html>\r\n<!--\r\n\r\nHello future GitHubber! I bet you're here to remove those nasty inline styles,\r\nDRY up these templates and make 'em nice and re-usable, right?\r\n\r\nPlease, don't. https://github.com/styleguide/templates/2.0\r\n\r\n-->\r\n<html>\r\n  <head>\r\n    <title>Unicorn! &middot; GitHub</title>\r\n    <style type=\"text/css\" media=\"screen\">\r\n      body {\r\n        background-color: #f1f1f1;\r\n        margin: 0;\r\n        font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\r\n      }\r\n\r\n      .container { margin: 50px auto 40px auto; width: 600px; text-align: center; }\r\n\r\n      a { color: #4183c4; text-decoration: none; }\r\n      a:hover { text-decoration: underline; }\r\n\r\n      h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; }\r\n      p { color: rgba(0, 0, 0, 0.5); margin: 10px 0 10px; font-size: 18px; font-weight: 200; line-height: 1.6em;}\r\n\r\n      ul { list-style: none; margin: 25px 0; padding: 0; }\r\n      li { display: table-cell; font-weight: bold; width: 1%; }\r\n")

Remove preview location.

Thanks for your great work @samtay !
I love this just because its key binding is exactly same as vim, loved it.
Preview location, however, I really don't like it, which causes confusing, also make difference from the classical tetris!
Can we turn on/off the preview location?
image

Possible fix for the reported issues with build on Linux

In README.md, you mention that

People seem to have varying levels of success with the linux binary

I believe that this may be because compiling vty requires a copy of of libtinfo.so. The message stating this may be confusing since it’s displayed long before the error is actually recognized by stack and the build is terminated, and the description for the libtinfo packages on Ubuntu state that it’s deprecated/transitional package. In fact, what is needed is libncurses-dev (on Debian/Ubuntu) or an equivalent library providding development access to ncurses.

Crashes on macos 13.0.1 (22A400) with latest xcode

After selecting a level, the game renders, but before my block displays:

tetris(44546,0x30ec64000) malloc: *** error for object 0x600001628010: pointer being freed was not allocated
tetris(44546,0x30ec64000) malloc: *** set a breakpoint in malloc_error_break to debug
[1] 44546 abort tetris

image

Creating Linux executable on macOS?

I made a game in brick (thanks for your tutorials, they were super helpful!) and am now putting out a release. I noticed that you have releases for both macOS and Linux. Is there any way to generate a Linux build on a macOS, without using a VM or dual-booting? I'm guessing the answer is no, but just thought I'd ask.

Command Line Parameters Error Messages

A great game and a great implementation. I'm very happy about that, thanks a lot!
The program works, but I have some minor issues with command line parameters.
--level is honoured.
--ascii-only and either --no-preview or --preview-chars "xx" cannot be used together and result in "Invalid option". Why?

Getting error in alacritty

I followed the installation steps and installed tetris but i am getting

setupTerm: Couldn't look up terminfo entry "alacritty"

error.

Feature Request: Offer a choice for roation direction

With the current version the pieces Jare rotated counter clockwise while the original version rotates the pieces clockwise. It would be nice to either have a choice about the direction of the rotation or have the rotation clockwise.

Feature Request: Rename preview and introduce traditional preview

With the current version preview is showing where a piece will land. Thankfully, this can be disabled with the command line option "-n". Nevertheless, this is a feature not available with most of the other implementations and, even more importantly, not available with the classic version of the game.
OTOH, the classic preview function is to show which piece will be given next. This feature cannot be disabled with the current version and the next piece appears before the soon to be current piece is visible. To rephrase that: The next piece which shows up in the frame at the top right is in fact the piece after the next piece because it is displayed even before the soon to be current piece is visible. Therefore: it would be an improvement to having an option to disable this kind of preview and if not disabled to only show the next piece after the soon to be current piece is already visible in the field of operation.

Store functionality

I couldn't find the ability to store the the current block and swap it with the one currently in the store. If the store is empty, the next block from the stack is the new active.

(Re)question - for Termux in Android?

I saw your seemingly wonderful clone on https://opensource.com/article/18/12/linux-toy-tetris
and wanted to try it on my most available device (Android on ARM)

It has the Termux Terminal Emulator, but following the curl way led to a file called tetris containing only a 'Not found' string. (Got confused when 'cat-ing' it :)

Maybe I am just lazy, but I don't know how to install this here.
Solutions, maybe:

  • Ask the Termux team to add it to their repos
  • Try the curl way harder/"termuxified"
  • Maybe Termux got dex?
  • Compile?
    Don't mean to clutter your issue section, but maybe there is a hint to be found?

Error when installing binary on Linux (CentOS 7)

I installed the binary from this repo, following the instructions in the README. When I tried to run the executable, I got this error:

tetris: error while loading shared libraries: libncursesw.so.6: cannot open shared object file: No such file or directory

Building from source worked and ran successfully. System is CentOS 7.

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.