How do you make a matching game?

Hello everyone, is there a way on how to make an image sprite to spawn randomly on a canvas. I have an idea about a matching game when you pressed the two same colored tile or number it will change its color or number and be combined then when the combined tile is combined with another one they will disappear and each and every tiles that you combine you get a 1 point on the score. This game will be entirely on how fast you can do it within a 60 seconds timer.

This sounds like the 1024 game.1024 Game - Source of 2048! https://1024game.org/

1 Like

Yes. For an example of random sprite posting to the Canvas, see

https://appinventor.mit.edu/explore/ai2/molemash
and
https://appinventor.mit.edu/explore/ai2/molemash-2

1 Like

Oh yeah its something like this but it will be 1 + 1 then the tile will be 2 then 2 + 2 the tile will disappear. And its more on matching or tapping rather than swiping.

Oh my thanks for this!! this is what I'm also looking for. For the taps and random generating.

So does anyone thinks this is possible using MIT???

I do. All sounds very possible.

1 Like

Now I'm stuck I made them that they could be matched with each other but I'm stuck on how to make it by color + number and I don't know how they add and become a new sprite.

Using the Every Sprite block to give you a list of all the Sprites (Visible or not Visible), you can loop through that list to find available Sprites that are not in use yet.

For simplicity, code a Matches value procedure that accepts two Sprite components and returns true if they match, false otherwise.

1 Like

This sounds like a crafting game.

Think about saving recipes in a table, like the game cheat sites.

Consider putting a cauldron on the Canvas. Examine Sprite Pictures dragged onto the Cauldron, for combinations like

House.jpg = lumber.jpg + nails.jpg

1 Like

Ohhh thankyou so just like that. so heres like the idea. If I tap two different colors and numbers then it would reject it.

This looks like 3 Horizontal Arrangements in a Vertical Arrangement, with 3 Buttons each.
(Avoid the buggy Table Arrangement)

Buttons have lots of attributes you can change, like

  • text color
  • background color
  • Bold/Not Bold
  • Font Size

to show which Buttons have just been Clicked in addition to their match qualifications.

Typical match games use a global variable to hold the first clicked component (or '' if none)

From your example, I see the second target gets the sum of the numbers and the matched color, and the first target

  • stays the same value?
  • reverts to 1?
  • gets a new random color?
  • gets a new color according to the rule ...?
1 Like

Yuppp, so you can only tap the same number with the same color. The second block that you've clicked would be the one that become a 2 while the first one that you've clicked will generate a random color with the number 1 again. If the two blocks that you've matched are both two then it will generate a random color with a number 1 in it as well. the 1 blocks will give you 1 point while the 2 blocks will give you 2 points.

Remember what you just said, and study how to nest if/then/else blocks.

1 Like

okay okay, but what do you think? should I use buttons? or canvas with image sprites? which one would work or be programmed the easiest.

With Buttons, you don't have to worry about collisions and dragging.

1 Like

Got it, Thank you so much for the help!!!

I'm back and I'm confuse I think I'm still a beginner at this. Are most of my snippets wrong base on this? I got the code from someone's memory matching game.

A memory match game is not a good model for your app.

You don't have sets of pairs to shuffle.

Among 9 buttons, you will have at most 6 combinations of colors and .Text values to match.
That's 3 colors multiplied by 2 values (1 and 2).
Six values used to fill 9 buttons should always give you three or more match opportunities.

I would just start by looping through the 9 buttons, and change its color and text randomly, without regard to what the other buttons have.

1 Like

I'm sorry I really don't know how to make it, maybe I won't be able to do it. I'm not cut out for this I think :sob: I don't know what snippets to put.