In Mole Mash, how can I add a second timer to put a limit to the game

1,509 views
Skip to first unread message

Charlie McEwen

unread,
Jun 3, 2015, 2:50:47 PM6/3/15
to mitappinv...@googlegroups.com
I'd like to limit Mole Mash to a specific length of time and then stop the mole movement, clear the screen and show a final score.
I can't figure out how to do this.
Can anyone offer advice/guidance/solution, please?
Thanks
Charlie

Abraham Getzler

unread,
Jun 3, 2015, 4:25:12 PM6/3/15
to mitappinv...@googlegroups.com
Add a Clock called GameStopper  set to a single shot, 
timed to go off after the proper time.
Do all your game ending stuff in it.


Enable it at game start,
disable at game end (when it fires.)

ABG

Charlie McEwen

unread,
Jun 4, 2015, 5:39:48 PM6/4/15
to mitappinv...@googlegroups.com
At the age of 75 I've decided to teach myself how to write apps for my smartphone but, after reading your reply, its clear that I don't understand as much as I thought I did!!

I've created GameStopper and set "always fires" and a time interval of 10000 (I think that should be 10 seconds?). Is that what you meant?
The "Game ending stuff" I would like to put in would:
a) stop the mole moving and clear him from the screen
b) display the score in the centre of the screen
c) provide a button to start a new game of Mole Mash

Sadly, I'm pretty much lost at this point.
Thanks ABG for your reply. Can you, or anyone else please, either give me more detailed guidance or tell me where to find it for myself?

Taifun

unread,
Jun 4, 2015, 5:44:32 PM6/4/15
to mitappinv...@googlegroups.com
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Abraham Getzler

unread,
Jun 4, 2015, 5:53:42 PM6/4/15
to mitappinv...@googlegroups.com
The "always fires" switch on a Clock is for repeating events like a metronome.
You want to keep that off.
Use the other switch, that enables (starts and stops) it.


A Notifier is a good way to pop up a message.
Pick the type that comes with an Okay button,
and look for the Notifier block that picks up after the Okay is hit
to start the new game.

Use the PrtSc button to take screen shots of your blocks,
Windows Paint to clip and save them, and attach them as files to your
post for others to see.

ABG



Charlie McEwen

unread,
Jun 5, 2015, 4:33:52 AM6/5/15
to mitappinv...@googlegroups.com
As suggested by Taifun (thanks) I attach a screen shot of my blocks to date.
Component List.doc

Charlie McEwen

unread,
Jun 5, 2015, 4:55:21 AM6/5/15
to mitappinv...@googlegroups.com
Sorry, I attached the wrong doc. The correct one is here.
Doc1.doc

Abraham Getzler

unread,
Jun 5, 2015, 12:01:11 PM6/5/15
to mitappinv...@googlegroups.com

Charlie McEwen

unread,
Jun 11, 2015, 2:01:55 PM6/11/15
to mitappinv...@googlegroups.com
The game works, up to a point – the mole moves, the score of hits increments, the score goes back to zero with the reset button, but…..

I want to be able to stop the game after a predetermined time (10 sec, say, for testing). I’m using GameStopper for this.

I think I need to do this inside MoleTimer (which already successfully makes the mole move randomly).

So, what I think I want to do is:

When MoleTimer If GameStopper reached Call StopMole  (which should stop the mole somewhere in the screen) Else Call MoveMole

Later I plan to add a display of the scores (hits and misses) into StopMole.

BUT…. It doesn’t seem to get to StopMole. Presumably GameStopper isn’t working? Or, is the app just not getting to it? Why?
Can I have two timers running at the same time?

It seem to me that there must be some basic concepts that I’m not grasping, but What Are They?
I’ve tried studying the links ABG gave me but can’t make the leap from those to actually doing the above.
I’d really, really appreciate two things, please :
1) specific help with the above and, for future use…
2)  an “Idiot’s” Guide to using App Inventor 2.

I’ve attached a screen shot of what I’ve done so far.



Mole Help Please.jpg

SteveJG

unread,
Jun 11, 2015, 2:10:35 PM6/11/15
to mitappinv...@googlegroups.com
Regarding 2, not for idiots but great for those that want to learn AI2:

We want you to have fun with App Inventor so here are some resources to help you learn to use the AI2 tools  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Regarding 1,   have you read  Creating Animated Apps        ...it won't solve your clock issue but will help with animation concepts.
However, how long the game lasts?   Several ways to do this ...  one is the second post in this thread  https://groups.google.com/forum/#!searchin/mitappinventortest/count$20down$20timer%7Csort:date/mitappinventortest/nRj9P_m_xvo/GXqVFGOmScMJ   

You set the timer to go off for any time interval you want.  Remember the basic units are ms   (1000 ms = 1 second).

You will need to modify this example as it more complex than you require.   Try some blocks, if you have issues ask again.




Yes, you can have two timers running simultaneously.


Regards,
Steve







Abraham Getzler

unread,
Jun 11, 2015, 3:01:45 PM6/11/15
to mitappinv...@googlegroups.com
See attached files for one way to do a single-clock countdown.

ABG

countdown.aia
designer.png
blocks.png

SteveJG

unread,
Jun 11, 2015, 5:33:24 PM6/11/15
to mitappinv...@googlegroups.com
Nice code ABG!    Another way is shown in    

Magic Counts a simple count down clock or timer AI2 tutorial

                      that uses a slightly different method and you might find it useful somewhere Charlie.

--Steve

Bob Walker

unread,
Dec 12, 2019, 4:18:37 PM12/12/19
to MIT App Inventor Forum
On my phone it worked better when I added the "round" block.  Before that I would get 8.974, 7.932, and so forth.

Capture blocks.JPG


Bob


Bob Walker

unread,
Dec 12, 2019, 4:20:21 PM12/12/19
to MIT App Inventor Forum
Broken link, Steve.

SteveJG

unread,
Dec 12, 2019, 4:52:18 PM12/12/19
to MIT App Inventor Forum
@Bob  ..note the date of the original post...four and a half years ago.  The web page material is copyrighted.  So called online education groups were using my code illegally in courses.  I took the examples down.  Sorry.

For what is worth, here is the original Clock code from the tutorial; it might give you some ideas for your Project.

magicCounts.PNG

Initially set the startClockSeconds to 0     and create the ancillary code to enable / start the Clock   and the idea  might help do what you want it to do.   Yes, this counts in integers, no need to round.

--Steve






Bob Walker

unread,
Dec 19, 2019, 10:16:40 AM12/19/19
to MIT App Inventor Forum
Sorry, Steve, I didn't know how long the link hadn't been working when I pointed it out.  Thank you for the code sample.

Regards,
Bob
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages