Apps for Appalachia: Wednesday Continued

Wednesday Continued

Lists are an important part of computing, and there are lots of ways to deal with them. Today’s exercise explores some of those ideas, and puts the explanation of those ideas in your capable hands.

CatBounce

For lack of a better demo app, I present to you… Cat Bounce. It has cats, and they bounce. Well, LimeCat does. Here is the AIA starter file.

Group 1: Initialization

When the app starts, all of the cats are added to the list. Use the For Each Number block to iterate through the list, setting a random speed and heading for each of the image sprites.

You will need to think about how to reference elements of a list using indicies, and explain that in your tutorial.

Group 2: Cats Go That Way!

The canvas has a “Flung” event handler. If someone flicks the canvas (but not a sprite—this is important!), then you should make all of the cats change their heading and speed in concordance with the flick.

You should use and explain the for each block as part of this effort.

Group 3: Come Over Here!

The canvas also has a Touched handler. When touched, you want all of the cats to begin moving towards the place that was touched.

This is tricky: you should use the while loop. As a hint: you may need a variable (local or global) that serves as an index. You will want to explain the condition that you use to determine whether or not you should keep looping as part of this tutorial.

Group 4a: Bad Cat!

It is possible to find out if an ImageSprite has been touched. There are two states of being for a cat:

A cat begins by wandering around.

  1. When a cat is touched and it is moving, it should stop moving, and be removed from the list of cats.

  2. When a cat is touched and it is not moving, it should begin moving in a random direction at a random speed.

Develop the code that handles this just for LimeCat. You should use a global variable to determine whether or not LimeCat is moving.

Group 4b: Bad Cat!

It is possible to find out if an ImageSprite has been touched. There are two states of being for a cat:

A cat begins by wandering around.

  1. When a cat is touched and it is moving, it should stop moving, and be removed from the list of cats.

  2. When a cat is touched and it is not moving, it should begin moving in a random direction at a random speed.

Develop the code that handles this just for GrumpyCat. You should solve this without using a global variable (it isn’t explicitly necessary). Explain, in your tutorial, how you used the information inherent in an ImageSprite to solve this problem.

Group 5: What Is Good For One Cat…

Cats are random creatures. I would like to have a procedure called RandomizeCat that takes an ImageSprite as a parameter (one of the cats, if you will), and sets its speed and heading to some reasonably random values.

Your tutorial should discuss the important aspects of procedures: they let us avoid duplicating code, and what parameters are and why they are important.

Group 6: Tricky Fling (CHALLENGE)

Using the Canvas.Flung handler, it is possible to figure out which cat was flung.

  1. Loop over all of the cats. Choose your loop.

  2. Check which cat has x,y coordinates that are close to the x,y coordinates of the fling.

  3. If you figure out which cat it is, change the heading and speed of that cat so they begin moving as flung.

This involves looping, looking at the x,y coordinates of both the touch and cat, and deciding whether the x,y coordinates of the event and the sprite are close enough to be the same.

Group 7: Cat Clicker (CHALLENGE)

This one involves something new that we haven’t done in class yet. It is a challenge.

Research the TinyDB component. Think of it as a magic super-variable. You can store a value at a tag, and then get the value back from that tag. So, each tag is like a variable, really.

Use the TinyDB to keep a counter of how many times each cat is touched.

Update the labels at the bottom of the screen with the number of times each cat has been pressed once every five seconds. Use the ScoreUpdate timer for this.

The primary thing you want to explain in your tutorial is how the TinyDB works.

For Today

For today, you want to do three things:

  1. Develop a solution in App Inventor that satisfies your given task.

  2. Develop a series of slides that capture your solution, step-by-step.

  3. Begin writing a script (where both of you will take part) to explain the concept you’ve been given.

Please use Google Presentations to develop your presentation, so that you can easily collaborate on it with your classmate.

At the end of class, submit a URL to your Presentation-in-progress to Moodle.

For Friday

We want to run a draft presentation on Friday, if at all possible. We’ll see where we get to.