alice-teacher Games and Timers

Donald Slater djslater107 at mac.com
Wed Dec 2 08:31:23 EST 2015


Look at the following algorithm

	declare gameOver variable to false
	declare score variable and set to 0
	declare currentTime variable and set to 20 seconds   

	mouse click event
		if mouse clicked on mole
			increase score by 1
			if score is equal to 5
				set gameOver to true
     
	while (currentTime > 0 and not gameOver)
            	doTogether->
            		show and hide the mole
			do in order ->
                		display time
                		wait 1 second
               			subtract 1 from currentTime
			// end of do in order
		// end of do Together
	// end of while

	if score is equal to 5
		player wins
	
Let me know if you have any questions…

Don Slater

Alice Team
Carnegie Mellon University
Entertainment Technology Center
700 Technology Drive
Pittsburgh, PA 15219

Email: dslater at cmu.edu

I have learned this at least by my experiment: that if one advances confidently in the direction of his dreams, and endeavors to live the life he has imagined, he will meet with a success unexpected in common hours.
--- Henry David Thoreau

The true object of all human life is play. -- G.K. Chesterton


> On Dec 1, 2015, at 10:29 AM, Jennifer Leaver via alice-teachers <alice-teachers at lists.andrew.cmu.edu> wrote:
> 
> Hi,
> This is my first year using and teaching Alice.  My students are creating games and are stuck on how to get a timer to work correctly with the game.  For example, one student is making a whack-a-mole game.  She has a timer counting down from 20 seconds.  The player wins if s/he whacks 5 moles.  How does she get the timer to stop and text to display, "You won!" if the player clicks the mole 5 times?  We've been trying if/else statements with no success.  If the timer runs down to zero, she wants the display to read, "You lose."
> 
> Thank you so much for your help!
> 
> Jenni Leaver
> Margaretville Central School
> Margaretville, NY 12455
> _______________________________________________
> alice-teachers mailing list
> alice-teachers at lists.andrew.cmu.edu
> https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20151202/64ecf0a5/attachment.html>


More information about the alice-teachers mailing list