# \[ANN\] REPLTetris.jl

**URL:** https://discourse.julialang.org/t/ann-repltetris-jl/11128
**Category:** General Usage
**Created:** [May 24, 2018, 1:39pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128 "2018-05-24T13:39:42Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 24, 2018, 1:39pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/1 "2018-05-24T13:39:42Z")

</div>

Hello there,

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

![REPLTetris](https://global.discourse-cdn.com/julialang/original/3X/e/5/e526c3d2371a734ea3ddbabdfb14475022397eef.png)

I welcome comments and pull requests!

Here is the link to the repo: [REPLTetris.jl](https://github.com/ChristianKurz/REPLTetris.jl)

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [May 24, 2018, 1:50pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/2 "2018-05-24T13:50:34Z")

</div>

I think you need to rename the `REPLTetris/src/ReplTetris.jl` to `REPLTetris/src/REPLTetris.jl` 🙂

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [May 24, 2018, 1:51pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/3 "2018-05-24T13:51:09Z")

</div>

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

[https://github.com/ChristianKurz/REPLTetris.jl/tree/master/src](https://github.com/ChristianKurz/REPLTetris.jl/tree/master/src)

---

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 24, 2018, 1:56pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/4 "2018-05-24T13:56:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [May 24, 2018, 2:06pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/5 "2018-05-24T14:06:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 24, 2018, 2:08pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/6 "2018-05-24T14:08:42Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [May 24, 2018, 5:22pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/7 "2018-05-24T17:22:32Z")

</div>

Nice! Re:

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

How about just using plain old 2d arrays?

---

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 24, 2018, 9:28pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/8 "2018-05-24T21:28:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 26, 2018, 4:28pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/9 "2018-05-26T16:28:58Z")

</div>

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

![](https://global.discourse-cdn.com/julialang/original/3X/c/3/c3c18979fdb82fd14f38c1cb44f9a78e3189b30f.png)

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.

---

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [May 27, 2018, 10:45am UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/10 "2018-05-27T10:45:08Z")

</div>

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

I just updated [Tetris.jl](https://github.com/djsegal/Tetris.jl) to allow REPL mode!!! Would love to have you as a collab in the future.

> **[GitHub - djsegal/Tetris.jl: you know, for kids? 👾](https://github.com/djsegal/Tetris.jl)**
>
> you know, for kids? 👾. Contribute to djsegal/Tetris.jl development by creating an account on GitHub.

* * *

Example shot of the new gameplay:

 ![20%20AM](https://global.discourse-cdn.com/julialang/original/3X/6/5/6597ccddfbe27d7e0322d1a49bd41b5ca5106bff.png)

---

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 27, 2018, 12:52pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/11 "2018-05-27T12:52:37Z")

</div>

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.

![](https://global.discourse-cdn.com/julialang/original/3X/e/5/e526c3d2371a734ea3ddbabdfb14475022397eef.png)

---

<div class="post-metadata">

### Author: ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)
#### Post date: [May 29, 2018, 8:00pm UTC](https://discourse.julialang.org/t/ann-repltetris-jl/11128/13 "2018-05-29T20:00:34Z")

</div>

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:

![](https://global.discourse-cdn.com/julialang/original/3X/6/3/6349757db25f7c301b0ef3b804af00008241f5a6.png)

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…
