mardi 27 juin 2023

Foreach loop used to assign labels

enter image description here

I have created a basic matchning game by the help of Google. The user selects cards which show different icons (using the icon scriptfont "webdings"). If the icon is paired with an identical icon, the cards remain on the screen, if not, both cards go blank again. The game is over when all pairs have been matched.

I have attached a snippet of the code which I struggle to understand. It works, but I would like to gain a better understanding. What mostly confuses me is the use of the random object and the next() method.

Can someone please attempt to describe the inner workings of this code to me?

Huge thanks.

I have tried to break it up into smaller pieces, both the foreach loop and the random method. But I still feel confused.




Aucun commentaire:

Enregistrer un commentaire