Looking for an easier solution

Hi there, I'm making a game similar to tic, tac, toe and i have created this procedure, to keep track of how the images are placed on the so called "board" in my game.

Now my question is, how I make a more "clean-looking" blocks of code, which also handles the endless ways a player might put their animal on the board, without being too complicated to implement, if it's possible of course.

I'm also facing a challenge, where another procedure should prevent the players from placing no more than 3 pieces for each player.
procedure - amount of pieces

And last but not least, when all the piece are placed, but no one has won the game yet, I want to make a procedure that handles where they put the pieces next, to finally win the game.

I hope anyone who knows how to do this, can give me easy examples or at least

It sounds like the any component blocks might be a good fit for this. When a user clicks on a particular square in the tic-tac-toe board, you'd want to check for whether it is already occupied or not and respond accordingly. If the move is valid, you'd then want to have an algorithm check for a win.

2 Likes

Should I remove all my procedures and replace them with the blocks you recommend i.e. The for each blocks?

Depending on how you've implemented things, there might be a better way. If you've created an event handler for one of the buttons on the tic-tac-toe board and coded its behavior, then you can right click on it to convert it to a generic event handler for any button. For example, if you copy those blocks into one of the event handlers you might be able to leverage this, but it really depends on your project design.