3 ms·
How would you build a GUI for your bits-based chessboard?
by fjsolwmv 9y ago
How would you build a GUI for your bits-based chessboard?
- christophilus 9y agoTrivially, you'd iterate i from 0-63 and then do 10 bit checks per value of i in order to determine what piece, if any, is on tile i. You could probably optimize it further, but that'd be hella fast on any device I can think of, and would take very little code to implement.
- fjdfhdjldj 9y agofor each type of piece if the bit is set, draw the piece at that position. if you click on a square and there is a piece in that square( there is a bit set in that position in any of the types), get the valid moves and draw them. if then you click an empty valid space, render the piece moving.etc.. most of the details are usually hidden behind functions. You renderer should not care about the internal representation of your data.