Show off your games, demos and other (playable) creations.
Post Reply
Posts: 4
Joined: Thu Oct 08, 2020 2:43 pm


Post by mhazaza » Wed Oct 14, 2020 2:02 pm

This is a very basic chess app.
Check, Mate, Stalemate, En Passant, Castling, Threefold Repetition and 50-Move Rule works.
The king lights up red on Checkmate and brown when a draw occurs.
(478.57 KiB) Downloaded 46 times
Key Controls
F --> flip Board
C --> switch Board color
S --> switch style of pieces
V ---> trigger fullscreen on/off
Left --> last turn
Right --> next turn
2,3,4 --> hold number for under promotion (quick fix)

Also all the piece-png's are literally stolen from (the site seems not to have a safe connection).
Anyway, have a great day and keep on keeping this ultra awesome framework alive and well.

Edit: Added a basic movelist which adjusts to window space and reacts on mouseclick.
Last edited by mhazaza on Thu Nov 12, 2020 10:30 am, edited 45 times in total.

User avatar
Party member
Posts: 1655
Joined: Fri Mar 07, 2008 1:39 pm

Re: Chess

Post by ivan » Wed Oct 14, 2020 4:15 pm

Not bad. I see you already have En-passant working so that's pretty good.
Good job at separating your logic code (which is in pure Lua) from the rest of the Love2d functions.
I'm not crazy about your use of closures which reminds me of JavaScript.
In general there is a lot that can be optimized and streamlines in your code.
Also, there is some silly stuff like your "unsign" function. Why not just use math.abs instead of "unsign"?
Having said that, your code is probably better than most of the chess stuff I have seen on this forum so good job there.

By the way, I'm the developer behind the following library:

Posts: 4
Joined: Thu Oct 08, 2020 2:43 pm

Re: Chess

Post by mhazaza » Wed Oct 14, 2020 5:10 pm

I didn't research any standard libraries, my goal was to do as much on myself as's kind of silly i guess :D
Yeah you're totally right about the "Call" metamethod nonsense. I'm definitely gonna clean that up soon.
The reason i did this was because a few weeks ago i was obsessed with having the pieces flip one square at a time via love.update in 60 frames per second. so i had to find a way to have an iteration which persists over multiple calls. i ended up using similar code for the move generation and just did the whole iteration at once recursively. i just kept it because it worked accurately. thanks a lot for pointing this out and even taking the time to look through my code <3
gonna check out your lib now

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests