[ANN] REPLTetris.jl


#1

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


#2

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


#3

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


#4

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.


#5

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?)


#6

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!


#7

Nice! Re:

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

How about just using plain old 2d arrays?


#8

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


#9

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.


#10

@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:


#11

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.


#13

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…