Memory Game for Class

I'm having some issues with a memory game I'm making for my programming class. The app will not open, but when I disable the reset block, a runtime error pops up on my screen. I can add close-ups of the blocks if needed.

Screenshot 2022-09-28 08.20.24

Please download and post each of those event block(s)/procedures here ...
(sample video)

especially those two big procedures.

I still do not know how to work around the forums but I am trying my hardest to find the solution to this issue. I am working on a memory game for my programming class, and the app crashes upon opening it. It gives me a run time error. The button 1 click is the same for all 6 buttons. I have narrowed it down to something in the reset block, as if I disable it, the app runs fine. I have the screen 1 initialize, and all my global variables too. I am terribly sorry if this is not what the last user wanted, as I am very confused when traversing the forums and I am trying my best.

blocks (10)
blocks (3)



Just continue in your existing thread rather than starting a new one... I merged the 2 threads now

Taifun

Consider the Clock Timer event, which you never enable or disable.
Is it set in the Designer as Enabled (default), or disabled?

The first things it does is jump into setting images for two unknown button components, without testing if those global variables really hold addresses of buttons, instead of some default starting value like -1 or 0.

(This would be a good time to init a global variable AllCardButtons to keep a reference copy of that 6 button list, instead of duplicating that long list all over the place. But in the place where you need a temporary copy of it for depletion purposes, take a list copy of it.)

I also don't see a Screen1.Initialize event, which would be a good place to call that reset procedure and to insure your Clock Timer is disabled.

If that does not help,

Export your .aia file and upload it here.
export_and_upload_aia

MemoryGame_v3_copy.aia (290.4 KB)

It appears as if it is still not working. I went back to make sure I had done everything correctly, but no matter how many times I try to use it, it doesn't work. So, here is the.aia file.

I saw a problem in your reset procedure, where you set button images to the card back image.

You had a very long text block for the image name, lacking the .png file type suffix.

Fortunately, AI2 keeps blocks for Media file names under Screen1, to save all that typing.

Here is an updated reset procedure you can try, that hopefully will get you past initialization.

I did not look further.

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

See A way to group projects by theme - #10 by ABG
for a demo.

P.S. Same error further down ...

P.P.S. I did a little testing, and found a place where you blindly tried to use a button block on a variable that does not always contain a button component. To fix this, you need a global list of buttons and to use the is in list test against that list.




P.P.S. I see there are more places where you do not test for a button before trying to use a button block, especially in that flip procedure.
I leave that to you.

So with the is in list for the global buttons, would I simply keep it as such, or what will I add to it?
blocks (17)


blocks (1)