Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

you need to be able to encapsulate any given board state in some kind of data structure, like a 2d array. then, whenever the player moves, update the board state and maintain an array of the past board states. if the player presses undo, simply revert back to the last state. similarly for reset, go back to the first board state.

so do i need to make the array by hand or make some system that automatically makes the array?

for example, you can have an array of objects where each object looks like { coordinates: (0, 4), tile_id: 2 }. whenever a change happens on the board, you can create a new entry (a new array) and capture all the active objects on the board. if you ever undo, you need to grab the previous array of active objects and be able to interpret it and update the board.