Maze game help! Code won't work!

So I've recently started to make a little maze game in appinventor, basically you use your finger as a direction guide for the animation to move to the end of the maze. I like the concept, but the only problem is that when I run it on my companion, the thing just freezes and gives me the code error
"#null!" Is there something wrong with the code?

The thing is, I want (and need) these features in the game:
Touchscreen movement;
Stopwatch & timer;
Multiple mazes;
Detect whether touching wall, and rebound if that is true.


Here's my code:
Maze_Game.aia (1.1 MB)


Have you read Creating Animated Apps ? The tutorial will help with " Detect whether touching wall, and rebound if that is true."

Button will help with using a Button to control the Sprite drag. using Canvas and ImageSprite. You can use Button.TouchUp and Buttkon.TouchDown.

Thanks, but my major issue here is that the app just crashes immediately after I open it. I already have finished all the requirements listed, it's only that I do not understand what is wrong with my code. Sorry!

The problem for "t the app just crashes immediately after I open it" is probably your code in the Screen1.Initialize event handler. Look there for the bad code (possibly related to a Clock setting).

Alright, I'll check it out. Thanks so much!

I tried your code, and the app did not crash on startup in the new AI2 emulator.

When I started a game, the code froze.

Here is the probable source of the freeze:

Loops are not useful for things that update the screen.

Instead, define 4 Clocks, for the 4 directions of movement, and have them all disabled until you start them moving the player, one step per Timer event.

Have each Clock Timer do the appropriate edge or barrier testing.

I see, thanks!I I'll try editing the code and update on it.

If the pixel scolor sensing approach doesn't work for you, there are alternative approaches based on a row and column framework, since your sample images are all built on a grid.

You could keep a row and column cell naming convention like one of

  • A1, B1,C1 reading cell names in the first row of a spreadsheet, or
  • '01,01', '01,02', '01,03' for numbered coordinate pairs for those cells.

A maze could be represented as where you would end up in you went in one four directions from a cell.

Four dictionaries (left, right, up, down) would be enough, with the key being the cell name and the value being where you would end up if you tried to go in that direction.

A wall would send you back to the originating cell.
A doorway would send you into the adjacent cell in that direction.

The 4 dictionaries could be fed into a drawing routine, to draw the walls.