How do I use a looping block without freezing the app?

I tried to create a maze app, but when I use an emulator to test it, it says that "MIT AI2 Companion isn't responding.". At first it works for a while, then after some seconds, it freezes and I could only hear the background music.

Tried to troubleshoot, but it still freezes. Would be grateful for any advice! And also Merry Christmas to you all!

Attached are my codes and also my aia file.

TermPrj1_2B_17.aia (6.1 MB)

And here is the screenshot of the message "MIT AI2 Companion isn't responding" (if it serves any use)

Maybe it's because the "While test" blocks in the TouchDown event?

Thanks for your reply, but is there another way to move the sprite instead of using the "while test" block?

Tell us when / how you want the hero to move?

It is a maze game, so the user should be able to control the movement of the sprite by touching the canvas such that the sprite will move either vertically or horizontally towards the point of touch, but it moves within the boundaries of the wall (the black lines) (i.e. it doesn't pass through the walls)
Attached is the pdf of the requirements+ coding tips if it helps
F2 CL TermPrj1_2223 (1).pdf (353.7 KB)

Do you mean moving the sprite while touching down? when touch up, moving stop?
If so, use a clock:

When canvas.touchdown,
set clock.enabled = true;
end when

When canvas.touchup,
set clock.enabled = false;
end when

when clock.timer,
move the sprite, but not use While loop
end when

Thank you so much! Will try editing the codes.

I know this may be a strange request, but I just checked the requirements of the assignment and it seems that I must use at least one looping block in the whole program (that is while.....do). Is there a way I can use this block, but it won't freeze the app (like in what cases can I use the looping blocks?) Thank you!

Merry Christmas everyone! May I know how can I use a looping block without freezing the app? I know that this a a strange request, but my project is required to use "at least one looping block (while....do)", no matter it serves any use or not (but it just needs to be there). Thank you everyone in advance for your ideas! :slight_smile:

attached is the information of the maze project, and also my codes
F2 CL TermPrj1_2223 (1).pdf (353.7 KB)

well I just managed to use while test... do block that serves no use :confused:
blocks (3)

Interesting. a garbage code can make you pass exam/assignment .

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