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.
Repo here https://gitlab.com/dustyweb/racktris
You can see what I started with in this commit... some stuff but not too much: https://gitlab.com/dustyweb/racktris/commit/20652a2f6cab7d0c16bdbde711bcb92d9af2c851
@notclacke oh you ain't seen nothin yet
@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? ;)
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:
- Software Freedom Conservancy
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!
Oh YEAH, blit code works https://gitlab.com/dustyweb/racktris/commit/7279d61e18f76eb20df4f3ba4288a863e221ef24
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!
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 https://gitlab.com/dustyweb/racktris.git
$ cd racktris
$ racket racktris.rkt
@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
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!)
@cwebber Works fine!
@cwebber how is lux? does it use opengl?
@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
@dthompson Two other really interesting chaos renderers available are:
- raart: for making ansi art / console / curses games https://github.com/jeapostrophe/raart/tree/master#readme Underdocumented, but comes with a demo https://github.com/jeapostrophe/raart/blob/master/t/hack.rkt
- 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 https://docs.racket-lang.org/mode-lambda/
@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 So: four hour Tetris?
@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!
@doesntgolf Thanks so much!
@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.