CSCE 101 Lab 7 – Mushroom Picker Extension

Mushroom Picker with Score, Misses, and Taunting.

Academic Honesty

·  The work you turn in is to be your work, not copied from someone else, from the web, or generated by a program.

·  Never allow anyone access to your files.

·  Never give anyone your password.

·  Never share your USB memory or email your files to anyone else.

·  Never give anyone a printed copy of your file or an electronic copy.

·  Never allow anyone to copy your work.

Problem Statement

You will save the completed assignment in your 101Labs folder on your X: drive (X:\101Labs\).

It is important that you name your files exactly the name given. This is what is looked for during grading. You will extend lab 3 to include:

·  a counter for hits and misses

·  an "lol" image sprite to taunt the user when they actually miss the user. It should pop up where the user misses it.

If you do not have lab 5 complete you may finish it for credit. Your lab instructor, who will accept it for credit for lab 5 as well at a reduced late penalty of 5 points. You have extra time, due to Spring Break but the labs will be closed (though you will have open lab hours the following week).

Note: Programming is not, generally, not like following a recipe, such as in the tutorials, but more like having an assortment of tools (blocks and components) that you must use and compose to accomplish a desired goal.

In Class Portion (due night before next lab)

  1. Duplicate lab 5 by opening it in My Projects and:
  2. Going Projects->Save Project As ...
  3. For the name use "MushMash8_xy", where xy are your initials. (Be sure to include your initials -- your lab instructor may deduct 5 points if you don't. It is very inconvenient for your lab instructor if you don't have unique names. It's also very easy to fix for you -- you can rename it when you download it).
  4. In the MushMash Game Screen Designer, add the lol.jpg image: link
  5. Add a "lol" ImageSprite to the Canvas using the "lol.jpg" image[1], setting it's width and height to something appropriately sized (e.g. 40x30px).
  6. You can make an ImageSprite invisible by setting its Visible property to false.
  7. Add four labels in a Horizontal Arrangement to display hits and misses.
  8. Two labels, which will be written to from blocks editor will start with a Text of "0", no quotes, and should be renamed appropriate to their purpose (to hold the number of hits and misses).
  9. The other two labels should label the output labels ("Hits:" and "Misses:", probably and don't need to be renamed).
  10. Go a ahead and add a "LOLTimer" Clock to the App in Designer. It should start disabled (TimerEnabled=false). We will use this to show the LOLTimer only for a short while.
  11. Make it so that whenever the Mushroom is touched and it is the good mushroom, then you have a hit and the number of hits should go up and be displayed to the user.
  12. Hint 1: You just need to add to the "then" or "else" part of an if you already have
  13. Hint 2: You don't need a variable but, rather, can use the text already in the labels; you can do it the other way with the variable if you like but don't forget to copy the variable to the label. (App Inventor will convert number-like text into numbers when it can). Just be sure to intialize[2] the text properties of the output labels, if you haven't already.
  14. Whenever the Mushroom is missed, you should increment misses (like hits, above). The ImageSprite doesn't have a "NotTouched", obviously, event handler so we need to use the Canvas Touched but there is a complication: when you touch the ImageSprite you also touch the Canvas -- they both receive events and you can have, simultaneously, a hit and a miss.
  15. The fix is to use an if and the touchedAnySprite parameter of Canvas1.Touched. touchedAnySprite will be true if any ImageSprite was also touched at the same time as the Canvas. (Hint: touchedAnySprite is the opposite of what you want -- you need one logic block or a comparison (=) to get what you want).
  16. Increment misses in the then part of the if as above.
  17. Whenever the Mushroom is missed you need to show the "LOL" ImageSprite. You should:
  18. Have the ImageSprite appear near where the user touched: use x and y parameters of the Canvas1.Touched to change the LOLSprite's postion
  19. make the LOLSprite visible (it will be invisible if the user hasn't missed the mushroom recently).
  20. Enable the LOLTimer timer
  21. Upon the LOLTimer going off, the timer should disable itself and make the LOLSprite invisible.
  22. Modify reset to reset Hits and Misses as well.
  23. Test it!
  24. Project Naming for Submission: Make sure your project is named, "MushMash8_xy" as in step 1. You can rename it once it is downloaded as described below. If you didn't submit lab 5, you don't need to download another copy.
  25. Still have time? Do the Get the Gold tutorial, which will be extended significantly for lab 9, If you have time, especially over break and haven't done it yet: do the old erroneous pre-lab for 8, which will be for lab 10).

Submitting Your Code (Generic Instructions)

a.  ​Open "My Projects" in upper right of the App Inventor Webpage

b.  Put a check next to the project you want to download (you can only download one at a time). Download the modified version, if you have multiple copies.

c.  Project->"Export selected project (.aia) to my computer"

d.  The file will download so go, in Chrome, to the download location by clicking thearrow next to the file nameat the bottom of the screen and selecting "Show in folder".

e.  Move the ______.aia file to your X:\101Labs directory for grading.

f.  Important: make sure you have only letters and numbers in the file name -- there should not be a " (1).aia" at the end. Right Click, Rename the file to get rid of the space, number, and parentheses. If you haven't already, you must add your initials to the end of the file name, before the ".aia" extension. Your lab instructor may deduct 5 points if you fail to do either of these steps.

[1] from http://www.fanpop.com/clubs/the-word-lol/images/21172012/title/lolige-photo

[2] "initialize" w.r.t. variables/properties means to give them initial, values ( bad starting values may cause issues).