It's 8pm here. Self challenge which I'll live blog: can I implement a version of tetris in Racket by 10pm? Let's see if I can... I'm gonna live blog it here.

Ok, starting off, a while ago I already wrote out some vectors representing the tetris shapes and a little utility to rotate them. That's all I'm starting with, which isn't too much of a head start.

I'm going to use "lux", which is the "grown up" version of Racket's big bang. There are multiple renderers you can plug in... it comes with a Racket "draw" based basic canvas one, or I can use raart, which would be terminal ansi-art based. Not sure which I'm doing yet.

Already have nice looking rendering of blocks. Check out the visual rendering of the block hashmap at the REPL!

@notclacke For instance, check this out. I just wrote a board renderer... and yes, it's rendering the whole board at the REPL.

I wonder how many non-racket developers are jealous with this screenshot? ;)

1 hour to go... I've got a lot to get done in this hour. It probably won't be done in my original 2 hour goal.

But what about 3? ;)

Okay, this looks good enough like a GUI to get onto gameplay

Christopher Lemmer Webber
Follow

So, it's 9:38PM right now. That's a little over two hours until midnight.

How about we make this a game for charity? Feel free to put down pledges to donate to a freedom-loving charity. Put down your donation amount and choose one of the following orgs:

- EFF
- Software Freedom Conservancy
- ACLU
- FSF

If I get a graphical game by midnight, donate $MONEY amount to $CHARITY.

I promise $30 to Conservancy if I get this done by midnight. Bonus: if I get a console version too, $60!

Working on the blitting-to-the-board function, which doubles as collision detection. Probably the hardest part of this (and not too hard)

come on chris... don't lag now... only an hour left!

Okay, it's midnight! Here's what works:
- the game renders and looks nice
- pieces advance and can rotate and can be placed

Here's what I don't have yet:
- You can't clear rows yet... oops!
- Rotation code is apparently broken... you can't rotate all the way around, only 90 degrees and back. I don't know why this is!

I'm going to see if I can get those last two bits in. I consider that good enough for me to donate the smaller amount, but you judge for yourself!

gosh I'm tired and I can't figure out why my roation code doesn't work.

I guess I'll add all the rest of the code.

Okay, it's 2 hours past the "deadline" but now I have a fully working and dare I say *nice* game of Tetris working here with Racktris. Try it yourself!

$ git clone gitlab.com/dustyweb/racktris.g
$ cd racktris
$ racket racktris.rkt

Have fun!

Considering things "mostly" worked at midnight, and it's all working before I'm going to sleep, I'm calling it a success. Donating $30 to Conservancy now!

Oh yeah, you'll need the Lux game engine:

$ raco pkg install lux

Oh yeah, want to see what the finished game looks like? Here's a screenshot:

Those tiles used in the game are procedurally generated btw! They use the Racket "icon" library. Same rendering as the buttons in DrRacket ;)

@cwebber this is so motivating to see done in racketttttt

@cwebber im actually more excited for that, now that you say it, as i was trying to look for easy-to-use terminal libraries for games, seeing as i have never made a game before lol

@cwebber I had a look at it (both the game and the source). Looks good, but what is up with the Lux documentation? I wanna know how to do things with it, not do bible study :p

@moggers87 haha, yeah... well the answer is here github.com/jeapostrophe/lux/is

Jay McCarthy is religious, so I guess this was a joke on using religious verbage rather than scientific ones (from the big-bang library, the game lib which comes with racket on which this is inspired)

@cwebber awful!

Maybe I'll come back to it when I'm not so annoyed at it.

@cwebber Oh, will try when I get to my laptop. One can never have too many tetromino-based games on hand.

@kk Cool, let me know if it works (or doesn't, and you need help!)

@dthompson So Lux is really cool! It's basically "big-bang for grownups" (where big-bang is Racket's builtin game engine for middle schoolers).

The answer to "does it use opengl" is "yes, optionally" but not in the way most game engines say that. The core of the functional game engine actually doesn't specify the input/output system, which is provided by a "chaos". One chaos comes bundled which uses Racket's canvas drawing and GUI input events, but you can plug in others

(cotd ...)

@dthompson Two other really interesting chaos renderers available are:

- raart: for making ansi art / console / curses games github.com/jeapostrophe/raart/ Underdocumented, but comes with a demo github.com/jeapostrophe/raart/
- mode-lambda: "the best 2D graphics of the 90s, today!" (that's literally its slogan) which is optimized for SNES style games, and even includes mode 7 graphics docs.racket-lang.org/mode-lamb

(cotd ...)

@dthompson So here's what's cool about this: since the input / rendering engine is decoupled from the game loop engine, it's very easy to write one game and have totally different renderers... or at least I think so! Tonight I'm going to add an optional console version of Racktris using Raart and I think it's going to be pretty easy.

@cwebber cool! thanks for explaining. I can do similar things with my little bespoke thing, though I only ever do OpenGL stuff...

@cwebber @dthompson Definitely would like to hear more about how the console version goes. Also "mode-lambda" sounds like it is _extremely_ my brand 😍

@kingcons @dthompson a lot of the "changed" bits were really just slightly shifted sexps. Mostly it's just new code and moving a bit of functionality (not much!) into the new "engine" slot.

@kingcons @dthompson Oh and also the raart rendering stuff.

What's nice about raart is it's basically a picture combinator language, but for ansi art.

@kingcons @dthompson Oh yeah, it's probably obvious but... the advantage of being able to separate out the rendering engine so you can have a GUI lib and an ansi drawing lib for instance means it would be perfect for roguelikes

/cc @technomancy

@cwebber not sure how much time is left, and I'll have to check back in the morning to see if you made it, but $25 for ACLU and $25 to SFC if you do!

@cwebber Sweet! I'll give $5 to the ACLU if you make it. 15 minutes!

@cwebber I'm a couple days late, but just sent $25 to SFC and ACLU! Now time to play some tetris :D

@doesntgolf That's super awesome! Maybe next time I'll pre-plan and announce it.

FOSS gamejams for charity seem like a fun idea.

Sign in to participate in the conversation
Octodon

Octodon is a nice general purpose instance.