Free Essay

Ball Bounce

In:

Submitted By 12robhoo
Words 976
Pages 4
BallBounce: A simple game app
In this tutorial, you will learn about animation in App Inventor by making a Ball (a sprite) bounce around on the screen (on a Canvas).

Name the Project
Call it something like "BallBounce". Remember, no spaces. But underscores are OK.

Start a New Project
If you have another project open, go to My Projects menu and choose New Project.

Add a Canvas
From the Drawing and Animation drawer, drag out a Canvas component and drop it onto the viewer.

BallBounce: A simple game app - 1

BallBounce: A simple game app - 2

Set the Screen so that it does not scroll
The default setting for App Inventor is that the screen of your app will be "scrollable", which means that the user interface can go beyond the limit of the screen and the user can scroll down by swiping their finger (like scrolling on a web page). When you are using a Canvas, you have to turn off the "Scrollable" setting (UNCHECK THE BOX) so that the screen does not scroll. This will allow you to make the Canvas to fill up the whole screen.

Change the Height and Width of the Canvas to Fill Parent
Make sure the Canvas component is selected (#1) so that its properties show up in the Properties Pane (#2). Down at the bottom, set the Height property to "Fill Parent". Do the same with the Width property.

BallBounce: A simple game app - 3

BallBounce: A simple game app - 4

Add a Ball
Now that we have a Canvas in place, we can add a Ball Sprite. This can also be found in the Drawing and Animation drawer. Drag out a Ball component and drop it onto the Canvas (#1). If you'd like the ball to show up better, you can change its Radius property in the Properties pane (#2).

Open the Ball1 Drawer to view the Ball's blocks.

Drag out the Flung Event Handler Open the Blocks Editor.
Choose the block when Ball1.Flung and drag-and-drop it onto the workspace. Flung refers to the user making a "Fling gesture" with his/her finger to "fling" the ball. Fling is a gesture like what a golf club does, not like how you launch Angry Birds! In App Inventor, the event handler for that type of gesture is called when Flung.

BallBounce: A simple game app - 5

BallBounce: A simple game app - 6

Set the Ball's Heading and Speed. First get the setter blocks.
Open the Ball drawer and scroll down in the list of blocks to get the set Ball1.Heading and set Ball1.Speed blocks

Plug the set Ball1.Speed and set Ball1.Heading into the Fling event handler

Set the Ball's speed to be the same as the Fling gesture's speed
Mouse over the "speed" parameter of the when Ball1.Flung event handler. The get and set blocks for the speed of the fling will pop up. Grab the get speed block and plug that into the set Ball1.Speed block.

BallBounce: A simple game app - 7

BallBounce: A simple game app - 8

Set the Ball's heading to be the same as the Fling gesture's heading
Do the same for the Ball's heading. Mouse over the heading parameter and you'll see the get heading block appear. Grab that block, and click it into the set Ball1.Heading block.

Test it out
A good habit while building apps is to test while you build. App Inventor lets you do this easily because you can have a live connection between your phone (or emulator) and the App Inventor development environment. If you don't have a phone (or emulator) connected, go to the connection instructions and then come back to this tutorial. (Connection instructions are in Tutorial #1 or on the website under "Getting Started".)

Why does the Ball get stuck on the side of the screen?!
After flinging your ball across the screen, you probably noticed that it got stuck on the side. This is because the ball's heading has not changed even though it hit the side of the canvas. To make the ball "bounce" of the edge of the screen, we can program in a new event handler called "When Edge Reached".

BallBounce: A simple game app - 9

BallBounce: A simple game app - 10

Add an Edge Reached Event
Go into the Ball1 drawer and pull out a when Ball1.EdgeReached do event.

Go back into the Ball1 drawer and pull out a Ball.Bounce block.

Add the edge value for the Ball.Bounce block
The Ball.Bounce method needs an edge argument. Notice that the Ball1.EdgeReached event has an "edge" as a parameter. We can take the get edge block from that argument and plug it into the call Ball1.Bounce method. Grab the get edge block by mousing over (hover your mouse pointer over) the "edge" parameter on the when Ball1.EdgeReached block.

BallBounce: A simple game app - 11

BallBounce: A simple game app - 12

Your final blocks should look like this. Now test it out!

Test it out!
Now, when you fling the ball, it should bounce off the edges of the canvas. Great job!

There are many ways to extend this app.
Here are some ideas... but the possibilities are endless! - Change the color of the ball based on how fast it is moving or which edge it reaches. - Scale the speed of the ball so that it slows down and stops after it gets flung. - Give the ball obstacles or targets to hit - Introduce a paddle for intercepting the ball, like a Pong game Visit the App Inventor website to find tutorials that help you extend this app, particularly the Mini Golf tutorial. Have fun with these extensions, or others that you think up!

BallBounce: A simple game app - 13

BallBounce: A simple game app - 14

l

Similar Documents

Premium Essay

Bon Jovi's 'Livin' On A Prayer

...Rob Graham Mr. Buckley English 3 9/1/14 Livin’ on a Prayer Song Analysis Bon Jovi’s 1986 hit “Livin’ on a Prayer” was a major success and gave the band their first Number 1 on the “Hot Mainstream Rock Tracks Chart” as well as giving the band their second consecutive #1 “Billboard Hot 100 hit”. (http://en.wikipedia.org/wiki/Livin'_on_a_Prayer#Lyrical_interpretation) This song talks about a working class couple Gina and Tommy that struggle to make money while trying to keep their relationship alive, while also tying in the Union Strikes of the time. Firstly, throughout this song one can see that Bon Jovi is referencing a working class couple when they state “Tommy used to work on the docks” and “Gina works the diner all day working for her...

Words: 578 - Pages: 3

Premium Essay

Regulation of Air Pressure Experiment

...Replication of Air pressure experiment Find an air filled ball that has an air input that will allow you to increase or decrease the air pressure. I used a rubber basketball but a leather basketball would have also worked. The smaller the ball, the harder it is going to be to see the differences in bounce height. Use an air pump and an air pressure gauge to put air in the ball and to measure the air pressure in the ball. Make sure you adjust the air pressure between bounces and measure and record the pressure readings each time. Create a system to measure the height of the ball’s bounces. I used a roll of paper and marked it every six inches with painter’s tape. Use something like a camcorder to record the bounces. I setup the camcorder on a tripod and aimed it at the area where it could film the entire bounce with the measuring paper in the background. Do a test drop and view the results in the camcorder to verify it gets the entire bounce and also that the angle is correct. Record the height of the bounces at the different air pressures. Make sure the surface you are bouncing on is free of anything that may interfere with the ball bouncing. Make sure the area you are doing the experiment in is free of wind and changes in temperature during the experiment. Log the results in some form of table. I used Microsoft Excel and created a graph from the results. Using a notepad and pencil would also have...

Words: 266 - Pages: 2

Free Essay

The Modern Day Basketball

...not just a piece of rubber or leather, no it is far more than that. I always wonder about a basketball though, why is it orange? Why does a basketball bounce like it does? The things that a basketball does deceives the mind, especially when you put it in the hands of a well-trained player. There are all different kinds of people that use a basketball. You have kids just starting out to people that have never played before to the finest athletes in the world. There are people whose expertise is dribbling and others who are much better at shooting. There are others that can jump and grab the ball 12 feet in the air and you have players that focus their game on dunking the basketball. I often wonder why a basketball looks to appealing when you see one sitting on the ground. I don’t think I have ever walked by a basketball without picking it up to dribble it a few times and if there was a rim, there’s no chance I’m not shooting it. A basketball is appealing to the eye. One of my favorite sights in the world is seeing a basketball perfectly swoosh through the net. I still often wonder how the most recent version of the basketball got to be the way we see it today. The basketball we have all come to know is an inflated sphere. Basketballs range in size from very small promotional items to regular sized and finally extra-large balls nearly a foot in diameter used in training exercises to increase the skill of players.(1) The standard size of a basketball in the NBA is 29.5 to 29...

Words: 579 - Pages: 3

Premium Essay

Project Approach

...The project approach Katz, Lilian G. Scholastic Early Childhood Today12.6 (Mar 1998): 43-44. Turn on hit highlighting for speaking browsers by selecting the Enter button Abstract (summary) TranslateAbstract Engaging children in active investigations of topics that have personal meaning for them can enhance a curriculum and a child's desire to learn. Projects are ways to help children answer their own questions and learn more about the world. Full Text * TranslateFull text * Headnote Enhance your curriculum by engaging children in active investigations of topics that have personal meaning for them. Projects are ways to help children answer their own questions and learn more about the world. A PROJECT IS an in-depth investigation of a topic worth learning more about. The study is undertaken by a small group of children within a class, by a whole class, or occasionally by an individual child. The key feature of a project is that it is a research effort focused on finding answers to questions about a topic posed by children, the teacher, or both. Rather than simply seeking right answers, the goal of a project is to learn more about a topic. The Place of Project Work The project approach should be seen as complementary to the more informal parts of the early childhood curriculum. Project work is not a separate subject; it provides contexts for applying specific skills learned in other parts of the curriculum. Nor is project work an "add on" to the basics; it is integral...

Words: 1238 - Pages: 5

Free Essay

Int 1 Task 3 Wgu

...known as Hooke’s Law: The restoring force exerted by an elastic object is proportional to how far it has been distorted from its equilibrium state. Everything we associate with springs, has some place in the behavior of balls (Bloomfield, p.69). When a ball or a spring returns to its equilibrium state, it releases stored energy. Isaac Newton and the Law of Universal Gravitation: Isaac Newton (1643­1727) studied gravity and its effects on falling objects. He is most famous for the three laws of motion. Newton’s law of universal gravitation states that every point mass attracts every single other point mass by a force pointing along the line intersecting both points. The earth’s gravity exerts a downward force on the ball, called the ball’s weight. Its weight causes the ball to accelerate downward (Bloomfield p. 10). Reasoning: What does elastic mean? When a rubber band gets stretched it returns to its original shape. What is something that is not elastic? When a piece of bubble gum gets stretched, it stays stretched. It does not return to its original shape. When a ball hits the floor, the energy of the collision is stored as a physical deformation of the ball (On the Rebound, 2011 para. 3). The ball has kinetic energy just before it touches the floor. As the ball gets squeezed against the floor, kinetic energy is converted to potential energy. If all the...

Words: 3456 - Pages: 14

Premium Essay

Medicine Ball Research Paper

...medicine ball is one in every of those ball sized, weighted balls that boxers, amongst others, use to boost their fitness. you'd have seen the trainer throwing the ball at the boxer, World Health Organization catches it, will a stomach exercise and throws it back. therein case the exercise is plyometric, and improbably sensible for core power, like countering a punch, or learning back to avoid a punch, then countering. Reading this text can teach you ways ball exercises can profit you, in addition as providing you with some ideas of compound exercises that you simply would possibly do, which will extremely get you results. we'll be straight to the purpose, and provides you some data, though this text couldn't presumably address all the attainable exercises. The unimaginable flexibility of this athletic facility instrumentation is many-fold, as a...

Words: 879 - Pages: 4

Free Essay

Marketing and Tennis Balls

...Now, Tennis Balls Are Chasing the Dogs; Penn Racquet Sports courts canine customers Dennis Berman in New York. Business Week. Suppose your industry were in free fall. What would you do to find more customers? Would you go global in search of sales? Try the Internet? How about switching species? That's the drastic move made by Penn Racquet Sports, the nation's No.1 maker of tennis balls, which is suffering from flat sales and a decade-long lull in recreational tennis. This month, Penn begins marketing its familiar, fuzzy orbs to some undeniably loyal customers: dogs. R.P. Fetchem's is a traditional tennis ball that has been gussied up as a ``natural felt fetch toy'' for pooches. ``Ten times more people own pets than play tennis,'' explains Penn President Gregg R. Weida, owner of a schnauzer named Jake. NO DYES. Penn is teaching an old ball new marketing tricks--and hoping to bounce its estimated $70 million in sales up by 5% to 10%. For the benefit of four-legged consumers, Penn has made the balls dye-free. They sport the Ralston Purina Co. logo, thanks to a licensing deal with the dog-food giant. The biggest change is the price: $4 to $5 for a can of two Fetchem's vs. $2.50 for three old-fashioned tennis balls. That hasn't deterred retailers. [pic]PetsMart Inc. will test them, ordering 400 cases for its 413 stores. ``The fact that it's got the Ralston name and the natural felt are pluses,'' says Greg Forquer, [pic]PetsMart vice-president for merchandising. But that won't...

Words: 729 - Pages: 3

Premium Essay

Pokeballs

...Pokémon are different from humans in biological structure. In fact, their matter is unstable and has a certain tendency to turn into a special form of energy. This is, however, only triggered by certain radiation. This radiation is that of Apricorns, those nut-like fruits people made Pokéballs out of in ancient times. The inside of an Apricorn's shell contains energy drainers, a sort of biological energy black holes - they let out that certain radiation and they can suck energy in to their centers. Those are there to protect the Apricorns from Pokémon that might want to eat them in a very effective way - a Pokémon that cracks the shell of an Apricorn will be hit by the radiation, turn into energy, and be sucked towards the Apricorn. This can imprison smaller Pokémon inside forever - which additionally provides the Apricorn with more power to suck in more Pokémon - or if it is a powerful Pokémon, it would feel dizzy and perhaps decide the Apricorn is not good to eat. If a Pokémon actually eats the Apricorn, however, it dies and the energy drainers release the energy they contained. Different types of Apricorns, targeted as food for different kinds of Pokémon, contain different kinds of energy drainers which suck in different types of energy - usually some form which is dominant in some Pokémon and not others (such as Water Pokémon, fast Pokémon, heavy Pokémon, etc.). All Apricorns contain some drainers for all variations, though, so they can all catch anything that is weak...

Words: 459 - Pages: 2

Free Essay

Techology Essay

...decent thing was the fact that the ball was always pumped right. Now imagine all the new, various forms of technology that has come about since 1863: computers, smart phones, smart watches, televisions, vehicles etc., it is only right that Football has a fair share of the technological advancements. From muddy fields to constantly trimming the grass before games, Astro Turf fields are the future. They don’t just save you the stress of refilling the worn out areas and constant mowing the grass, they enhance the performance of the players. Also suitable for any weather, the astro turf fields are made of plastic blades of grass that are filled with small, crumbly rubber like shavings with gives players a better grip. Another positive about this piece of technology is that it prevents unwarranted injuries that can come from unlevelled grounds or a field consisting of many holes. Moreover, technology has played a key role with the equipment used for the game. Firstly, the advancement of shin pads; they don’t just guard the shin anymore, they are now being mad with shock absorbers, reducing the impact of a tackle on that area. The shin is a very delicate part of the body, and even the advanced shin pads can’t really prevent damage from a reckless and dangerous tackle. Secondly, the ball. Different balls are made for different leagues and for different competitions within the various leagues. Officials and players complain every now and then about the balls being played with, but as of...

Words: 799 - Pages: 4

Free Essay

Gergergertg

...OTHER EXPERIMENTER: FULL NAME: EDA HAZAL RAŞİT STUDENT NO: 140203009 EXPERIMENT PERFORMED ON: 30/09/2015 REPORT SUBMITTED ON: 07/10/2015 EXPERIMENT 1: The Relationship between Time of Flight and Initial Velocity Equipments: 1. Projectile launcher 2. Time-of-Flight Accessory 3. Xplorer GLX (as timing device) 4. Yellow Nylon Ball (2.5 cm diameter, 10 g) 5. Photogate 6. Photogate bracket 7. Carbon paper 8. White paper 9. Measuring tape 10. Duct tape Purpose: Purpose of this experiment is to Procedure: I have equipment to measured the fall time and I have different ball. This lesson was my first LAB so I didn’t know anything about equipments and teacher have thought equipments. After that, we make a group and we have started. We started the experiment by connecting material such as control box, drop box and AC adapter. After, I set the h=1,50. This distance between the bottom of the ball and the time of flight accessory. It is very important because if we didn’t calculate truely, we could find wrong results again. However,...

Words: 628 - Pages: 3

Premium Essay

Personal Narrative: Mickey Mouse Club Home

...1990’s T.V in a lady's basement. I was strapped in a carseat being baby sat by our neighborhood babysitter, watching Mickey Mouse with my stuffed soccer ball with a goth bedroom looming in the darkness in the other side of the basement. I wasn’t alone either all the neighborhood kids are there. Then I’m starting to get bored so I chuck my soccer ball across the room vividly regretting what I just did, because the fact I was in a carseat I could not walk at all. So I sat there and thought and finally I was going to try and walk with the carseat on my back, so I was trying my hardest to get up then I did, now the hard part was walking. I walked...

Words: 995 - Pages: 4

Free Essay

Rainbows

.............................................................................. 3 Coaching Points: ............................................................................................................... 4 Ages 6-10 .............................................................................................................................. 5 Coaching Points: ............................................................................................................... 6 Ages 11-15: ........................................................................................................................... 7 Coaching Points: ............................................................................................................... 8 Ball Familiarity ......................................................................................................................... 9 Dribbling: .............................................................................................................................. 9 Passing: ................................................................................................................................. 9 Shooting: ............................................................................................................................... 9 Trapping/Control: ................................................................................................................. 9 Heading:...

Words: 9054 - Pages: 37

Premium Essay

Cognitive Theory

...ALZ HEIMER job shadow I have the opportunity to serve in Silverado Alzheimer center. It´s a heritage center and hospice too. It has a psychology and rehabilitation unit. There are patients of different Alzheimer´ Stage. Their goals is to provide the patient a better quality of life. Their goal is to provide a better memory to the patient to benefit the life of the patient and his family. There is an Occupational therapy area. It has many instruments. There are different balls, poles, math , mats, bottles, belts, hand cycles, ropes, etc. There are some chairs for the visitor. They can wait there while the patient finish his therapy. The Occupational Therapy room has three lines on the floor which the patient stand up to evaluate their ability to throw up balls, pad, balloons, foam rollers. They have all the Occupational Therapy objects organized in shelves. There are different settings. There is a rehabilitation room. There is one portable tablet, a huge exercise ball. Furthermore, Home care is one of the priorities. There are many home adornment , instruments and kitchen dishes as a decorations in the shelves of the halls. It helps the patient to feel like at home. There is a big dinning area which the patient relate with others and share time. There is a cultural hall which elderly have a variety of activities. I could observed three patients. The first patient was diagnosed with a a shoulder leisure several months ago and have dementia stage 2 since...

Words: 570 - Pages: 3

Free Essay

Asas

...Person Analysis We went to local, family based cricket ball manufacturers. We observed the whole process of leather ball making which is a two steps process consisting of leather processing and stitching. We use some of the key criteria’s for person analysis Work History Cricket ball making has a major work area in leather processing. As each product being made in Meerut, by family owned businesses is particularly based in distinct villages, cricket ball making is situated in Shobhapur. It used to be the major business of many families but currently only a few players exist there. The reason being, entry of bigger players and more importantly, the manual work of leather processing which is a taboo in that place since it creates a stink and makes the place inhabitable. Nevertheless, manually processed leather has its own positives too which has made sure the sustenance of these businesses. We spoke to the workers making the balls. The roles are caste based. Lower caste people do the leather processing work. It’s a week-long process which involves cleaning the leather and drying it. Their own community people follow them in that line of work. In case of stitching too new workers are brought by the old ones and taught. People continue what their family business is into, for example for a family; its generations would continue to manufacture balls, which they have been doing since years. Training received As per survey they all received on the job training. There isn’t any...

Words: 607 - Pages: 3

Premium Essay

Children and the News

...updates.1. 2. All about Balls: This was meant to collect as many balls from houses. | Questions| 1. 1. To ask around the children questions about the hurricane. Like how did effect them? What happened? How do we stay safer and what precautions needed to take place for that to happen.1. 2. Questions to ask about the many different sized balls, the different measurements and and also what kinds of balls. Like if a planet is a shape of a ball? | Representation|1. 1. The educator does create a web that which shows the child new knowledge of the hurricane.2. 2. Balls were also represented by using a Web that presented many different types of balls.| |Phase Two:Research| Investigation|1. 1. The people tried to compare each others findings and relate it to what they thought rather than what they wanted to hear. They compared, contrasted and found many of the same understandings.2. 2. Children were able to observe different sized and shape balls from new experiences like indoor and outdoor activities by finding out new sizes, heights, lengths, and areas. | Field Work|1. WHEN using raw materials to construct new houses that depend on community care and health provisions – it shows the children how to build and take leadership over there home stay and how helpful it is to lend a hand.2. Discovering all about balls and play areas for new spaces that the children can play with and find out more about balls like setting up a play room with different balls that lean closer among sports...

Words: 1356 - Pages: 6