

When the ball hits the hole, the ball should reset at the bottom of the screen and the hole should move to a new random location.ĭoes your ball get stuck if it hits the edge? The ball should slow down as it moves, eventually stopping. When you fling the ball it should move in the direction of your fling, with a speed similar to the strength of your fling. Connect your device to AppInventor, or start the emulator to load your app. You can't just put a text block with the word "Hole" in it, you must use the Hole block, that can be found in the drawer for the Hole image sprite. Notice that the if then block tests to see if the object involved in the collision with the golf ball ( other) is the black ball sprite representing the hole. Note: When you first drag out the GolfBall.CollidedWith event handler, the named parameter is called "other". Program the Behavior of the Hole: When the ball collides with the hole, the ball disappears and resets at the bottom of the screen. Note that the Hole.MoveTo block sets the hole up in a new random location for the next play. This procedure will be called when a hole is scored and the ball has to be placed back at the starting point. Program a new procedure called SetupNewHole: For a summary of mutators, check out the Mutators page You'll need to use the if mutator function to change the if block into an if-else block. If you don’t have this then the ball will just bounce forever. Notice that if the ball is not moving then these blocks will do nothing. Use timer event to slow ball down so it doesn’t bounce around forever.Įach time the clock fires, it will reduce the speed of the ball slightly. You can play with this "scaling factor" to make the ball more or less responsive to a fling. You may want to scale up the speed a little bit because the speed of the fling is a little slower than how a golf ball would move. yvel, the speed in the y direction of the user's flingĮssentially, you want to set the GolfBall’s speed and heading to match the speed and heading of the player’s fling gesture.xvel, the speed in the x direction of the user's fling.heading, the direction (in degrees) of the user's fling gesture.speed, the speed of the user's flinging gesture.y, the y position on the Canvas grid of the user's finger.x, the x position on the Canvas grid of the user's finger.Notice how this event handler takes in 6 different arguments: The clock will fire continuously to control the movement of the ballįirst, use the GolfBall.Flung event handler to move the golf ball when it is flung.

Z = 2 (when sprites are overlapping, the one with the higher z will appear on top) This is the ball the player will fling to try to hit the Hole We’ll need our screen to have a defined height in order to set up the golf course properly.Īdd the following components in the Designer:īackgroundColor: Green (or whatever you like!)

Screens that are set to scroll do not have a height. In the Screen Properties (shown in right-hand pane): Uncheck the checkbox labeled "Scrollable" so that the screen will not scroll when the app is running.
#Game golf download free#
Think of a title related to Mini Golf, or feel free to use the suggested title "Fling It Mini Golf", and type it into the Properties pane on the right side of the Designer. When the Design window opens notice that App Inventor automatically names the screen "Screen1", but you can set the Title of the screen, which will show up in the top bar of the app. Log into App Inventor and start a new project. We'll build this app in stages, adding a little bit of the game at a time. Part I: Start a new app and make a ball that responds to fling events If you are not familiar with the basics, try stepping through some of the basic tutorials before continuing. This tutorial assumes you are familiar with the basics of App Inventor- using the Component Designer to build a user interface, and using the Blocks Editor to specify the app's behavior. Dynamic Positioning of sprites on a canvas, based on the size of the screen.Using the Sprite component and the TouchUp, TouchDown, and Flung events.The total score is the number of strokes it takes to complete the entire course. For each fling of the ball, the stroke count goes up by one. The ball will bounce off of the rectangular obstacle and the sides of the course. To play this mini golf app, the player first positions his/her ball within the confines of the tee, and then flings the ball toward the hole.
#Game golf download how to#
This Mini Golf App demonstrates how to use the Fling, TouchUp, and TouchDown gestures for Sprites Note that these event handlers are also available for the Canvas.
