Friday, April 16, 2021

Understanding

 Moving on: I re-instated my score code, with an arrangement

for shiny tiles (in PlayState)


In Board.lua, inserted code - which I lifted outright - for 

including the whole row or column. What I couldn't see for

myself was that one can do a 'for... do' loop assigning a series

of y or x values. Now I understand!




                                                           *     *     *

The last part of the assignment struck me as truly Herculean: only allowing

a swap between tiles if it results in a match. Otherwise, reset the board. Just

found the code that does this on a Github. It's actually quite clever: from

Board.lua,  have every tile check left, right, top, bottom for a possible match 

by actually making the match; then reversing the match and returning true. 

If the whole eventually returns false to PlayState, re-set the board.


Now that's programming!


https://github.com/learyjk/Match-3

No comments: