I made a minimal Tetris clone in terminal to learn Roc and pure functional programming. https://github.com/cjcone/roctris
SO COOL!!! :smiley::smiley::smiley:
This is so cool, thanks for sharing! Awesome that Roc can do this :)
anyone else tried it on a M1 Mac? I'm getting a segfault right away :sweat_smile:
$ cargo run ../roctris/Roctris.roc
Blocking waiting for file lock on package cache
Finished dev [unoptimized + debuginfo] target(s) in 6.85s
Running `target/debug/roc ../roctris/Roctris.roc`
Segmentation fault: 11
this is from nix-shell
in the roc/
dir
Same here, I get a SIGSEGV error on M1 – pretty sure it's to do with Stdin
, same thing happens on the interactive CLI examples in the roc/
SO COOL!!! :smiley::smiley::smiley:
On i7 Mac compiled but no dice of moving it ...
[nix-shell:~/projects/roc]$ cargo run roc build ../roctris/Roctris.roc
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Running `target/debug/roc roc build ../roctris/Roctris.roc`
🔨 Rebuilding host... Done!
🎉 Built /Users/popara/projects/roctris/Roctris in 2484 ms
[nix-shell:~/projects/roc]$ /Users/popara/projects/roctris/Roctris
thread '<unnamed>' panicked at 'failed printing to stdout: Bad address (os error 14)', library/std/src/io/stdio.rs:1201:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
seems like the kind of error you get when trying to write outside of a buffer, but for stdout. The game only writes within a ~40x20 character windows so probably not trying to write outside of the terminal window
It's probably on the Roc side. We definitely have some bugs that access out of bounds.
tonight I'll try putting up a test program for debugging
Yeah, almost certainly a(multiple) Roc bug(s). When run with --optimized
it gets farther
Which means that branches that get optimized away and there conditionals are at least part of the cause of the bug
I pulled latest Roc tonight and I think it's happening to me too. No segfault message, app just exits. Gonna start commenting stuff out to see what's triggering it
With a debug build and gdb, you should be able to get the function name that it segfaults in.
k Stdout wasn't working at all, looks like I just need to update my lib.rs
to use &RocStr
instead of ManuallyDrop<RocStr>
k should be good to go
that update gets farther for me, but still segfaults :big_smile:
Screen-Shot-2022-04-13-at-9.30.02-PM.png
boo
Indeed. This is the fun and M1 and memory issues.
It works on my Machine!!! (TM)
Screenshot-2022-04-14-at-18.57.22.png
Just spent 20 minutes playing it! :D
interestingly, on x86 mac I get this opening screen...
Screen-Shot-2022-04-14-at-3.40.25-PM.png
then when I press spacebar it transitions to this: (no segfault or anything, just appears to hang)
Screen-Shot-2022-04-14-at-3.40.30-PM.png
which terminal emulator are you using? that might be the difference.
I have tested it so far on iTerm2, Kitty and VSCode ... everywhere behaves allright dough ...
ha, that was it! I was using macOS default terminal
works on kitty! :smiley:
@Jared Cone would you be ok with it if I included a demo of roctris in my talk on Tuesday?
Emacs farts it
@Richard Feldman absolutely
awesome, thanks!
This is probably to be expected, but I'm seeing a "Call parameter type does not match function signature!" (after fixing a few roc standard library changes, I think)
I've updated https://github.com/jared-cone/roctris to latest roc. Moving on to a 3d game now :)
That's really cool! It looks like you are using unicode block characters for terminal rendering. If you don't mind my asking, how are you handling redrawing the canvas of the game while keeping the game info in the panel on the right? Are you using raw mode to navigate the cursor to specific positions, and only redrawing the parts of the screen that have updated?
Yep!
I don't recall if that was actually necessary. I think it was, IIRC clearing and redrawing the whole screen had black flickering
Last updated: Jul 06 2025 at 12:14 UTC