Game needs to check position on canvas with changing colors in a label.

32 views
Skip to first unread message

Eva Lee

unread,
Nov 9, 2019, 12:32:18 PM11/9/19
to MIT App Inventor Forum
I am trying to make a color game where the user moves a dot to the given color in Spanish that pops up at the bottom of the screen.  I wanted a random color (pick random from list), but I ended up trying to settle for sequential color names trying to pop up in order to check if the ball's current position is in the area that matches the color.  Neither worked.  I think my problem is in connecting the ball position list outlining the parameters of each colored square to the name of the color, but I am not sure.  This is to teach children Spanish color names, so I cannot use the canvas color picker as the original game creator did.  Any ideas?
Screenshot (173).png
Screenshot (174).png

SteveJG

unread,
Nov 9, 2019, 6:24:04 PM11/9/19
to mitappinv...@googlegroups.com
Here is something to try based on a forum discussion showing  a very different approach.  It might be useful to your development of this app Eva   by creating hot spots https://groups.google.com/forum/#!searchin/mitappinventortest/map$20buttons%7Csort:date/mitappinventortest/ttjjP_yH4xE/gcnwG_UQBgAJ 

Here is a partial example.  Only red and orange are activated

zhotSpots.PNG

Use the Forum discussion above for an explanation how it works.   Touch a color, the color appears in the header and the app 'says' the color name (in English). You can program it in Spanish.  Adapt it to your hearts content.

Does this work for you?    If not, try the techniques in '36 buttons' https://groups.google.com/forum/#!searchin/mitappinventortest/buttons/mitappinventortest/c7xYUTKFG_Q/d6R62Pj8VG4J ... in your case 12 buttons.

Regards,
Steve


HotSpots.aia

TimAI2

unread,
Nov 10, 2019, 12:46:03 PM11/10/19
to MIT App Inventor Forum

ABG

unread,
Nov 10, 2019, 6:46:03 PM11/10/19
to MIT App Inventor Forum
Here's where you went wrong with that BallPosition global variable ...

The initial value of a global variable is calculated only once , at app start, and does not change by itself.

If you were to take your big chunk of logic, you could turn it into a value procedure with that same name BallPosition 
(actually, it should be called BallPositionColorName) using an IF/THEN/ELSEIF/ELseif ladder like
I marked up.

The or tests in your blocks should be and tests, easy to change in place.
All 4 sides of a square must bound the ball for it to be in a square, so it's and and and and ...

Replace any get global BallPosition  blocks with calls to the new value procedure,
to get the current color name for the ball's current (x,y).

You may want to double check if the X and Y of a Ball are its center, or its upper left corner.
Center is nicer for this test.  Read the tool tips.

ABG






Screenshot (173).png
Reply all
Reply to author
Forward
0 new messages