# The Dice-Problem

Hi. I need help with a project I'm working on. It's about a table football game. I don't know if you're familiar with the goal system. For example, when I kick the ball in the goal, I swipe the dice next to me to the free space to show I made a goal / I earned a point because of it. And for each goal, you swipe the dice to the free space, until you swope every dice. Then you won the game.

Now I wanted to code this procedure in "Snap!". I've done everything so far. The ball movement, the figures, the gates, (even if the ball touches the gate/goal, then you earn a point, and so on..) except the dice procedure. And it's really difficult to make it work. So my Question is, what should I start with? What has to be done, until it works?

PS: I'm going to send some pictures that show this procedure visually and clearly and the clones on the dice I created.

Create four clones of the dice. Position them at the start. Create a variable to keep track of the next dice to swipe. When a dice is to be swiped, use the variable to determine which dice to move, then increment the variable. Does that help?

Hi Snapenik,
thanks for the reply! I also had this strategy in my head, but I'm not quite sure, because of clones. It affects performance in a bad way. is there an alternative?

I imply, that you want to use an own sprite for each dice. There is a principle in Computer Science, which we call Model-View. We create a mathematical model that works, and then implement the representation on the screen. You could take a list for the model like this one:

Each dice has its own number. When you get a goal, you first change the model list und then send a message "setDice":

Each single sprite reacts on this message by gliding to the right place:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.