[ANN] REPLTetris.jl

Hello there,

I had some fun writing a little Tetris game which is playable in the Julia REPL.

REPLTetris

I welcome comments and pull requests!

Here is the link to the repo: REPLTetris.jl

15 Likes

I think you need to rename the REPLTetris/src/ReplTetris.jl to REPLTetris/src/REPLTetris.jl :slight_smile:

1 Like

Is there a problem with the name of the main source file ?

https://github.com/ChristianKurz/REPLTetris.jl/tree/master/src

Done.

I had some afterthoughts regarding the name - seems like my local changes to the case of the filename didn’t get carried over to github.

Fun stuff! How many frames per second does it do? :stuck_out_tongue: Do you do anything fancy for updating the canvas (like only writing the diff for each frame?)

2 Likes

it does a few frames per e - i’d guess its close to 3 fps.

This is pretty dump atm - everything is updated every frame.

Btw thanks for the nice Crayons.jl package!

1 Like

Nice! Re:

look into better type-structures - StaticArrays aren’t really needed

How about just using plain old 2d arrays?

Yeah, thats what i had in mind. For calculation intensive stuff i usually use static arrays and it has become a habit. I know, thats premature optimization…

Edit: I removed the dependency on StaticArrays and did some refactoring

I refactored the code a bit:

  • Terminal Commands are moved to a separate module
  • A tile preview is shown
  • reduced tile accelaration to increase playability

Rendering of the tile preview is done via the put-function which only updates the preview part of the screen. This could be used to only render diffs of the board to increase rendering-speed.

The new module Terminal.jl is meant to make the code more readable: Every terminal-sequence is wrapped in a function whose name is human-readable.
I noticed, that there is a similar file in the stdlib/REPL: LineEdit.jl. I will see if i can just depend on that file instead of reinventing the wheel.

1 Like

@shorty66, very cool! I didn’t know about raw terminals before this.

I just updated Tetris.jl to allow REPL mode!!! Would love to have you as a collab in the future.


Example shot of the new gameplay:

3 Likes

I just pushed an update increasing the rendering speed through differential updates. Switched to the original tile colors too!

@djsegal your Tetris-binder was what inspired me to write this in the first place. I didn’t use any of your code though. I’ll see if i can make some PRs to your code.

2 Likes

The latest version is compatible with julia 0.6.x and Julia 0.7.x.
You can now use z and x for rotation in both directions.
While testing i got a new highscore:

Admitted, i’m not too got at playing tetris. But the rendering speed is easily capable of the higher levels.

This reminds me, that i need to have a list of high-scores saved…