The Temperature Converter
CSCE 101 Lab 9Cocky FootballAcademic HonestyThe 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 In this lab you will be creating an app with a start screen and three other screens, the first of which will contain the Space Invaders game (as you ought to have completed in the pre-lab). The second and third screens will correspond to the Cocky Football game, with the second being the screen which contains the game, and the third being the “Game Over” screenPart 1: Cocky FootballThis part is not required to be completed during your lab time. You will not have to take and submit any screenshots for this lab. The completed Lab 9 will be due on the date posted on your lab instructor’s webpage.This lab will build on the project you should already have created by completing the Lab 9 Pre-Lab. Make sure you have opened your Lab9_XY project in App Inventor.Add two additional screens to your project. Name the screens CockyFootball and GameOver. Your project should now contain the following 4 screens:Screen1SpaceInvaders (or something similar)CockyFootballGameOverDownload the following assets for this lab: Layout: Ensure you are in Screen1. Add a button below the button which navigates your app to the Space Invaders game. This button will allow the user to navigate to the Cocky Football game you’re about to create.Change the text of the button you’ve added so it is clear to the user what the purpose of the button is.Switch to the CockyFootball screen. Feel free to reference the screenshot on page 5.In this screen, you will need the following items:A Canvas, with the following property specifications:The width set to Fill Parent,The height set to 300 pixels,The background image set to fieldTexture.png(found in the list of images you downloaded above).4 Image Sprites, with width set to 50 pixels and height set to 30 pixels.One image sprite should have its Picture property set to playerTexture.png and have its Y property set to 265.Name this image sprite “PlayerSprite”.Two image sprites should have their Picture properties set to opponentTexture.png and their Y set to 175 and 100.Name these image sprites “Opponent1Sprite” and “Opponent2Sprite”.The last image sprite should have its Picture property set to playerTexture.png and have its Y set to 10.Name this image sprite “ReceiverSprite”.Another Image Sprite, named “BallSprite”, with the following property specifications:The Picture set to footballTexture.png,The width set to 12 pixels,The height set to 20 pixels,Rotates unchecked,Enabled unchecked.Two Clock components, one named “MovePlayerClock” and one named “GameClock”.A Horizontal Arrangement below the Canvas.4 Labels inside the Horizontal Arrangement, with the following specifications:The first one should have its Text property set to “USC:” and should be named “USCLabel”,The second one should have its Text property set to (the number) “0” and should be named “USCScore”,The third one should have its Text property set to “CLEM:” and should be named “ClemLabel”, andThe final one should have its Text property set to (the number) “0” and should be named “ClemScore”.A Label below the Horizontal Arrangement, named “TimeLeft” and with its Text property set to “00:00”.A Horizontal Arrangement below the TimeLeft Label.2 buttons inside the Horizontal Arrangement, with their Text properties set to “Reset” and “Main Menu”.The Coding:Make sure to start the emulator so you’re able to test the code you add to your project!Switch back to Screen1.Program the button you added in the Layout section to be able to open the CockyFootball screen.Switch to the CockyFootball screen.Much of the basic mechanics of the code for Cocky Football will be stolen from the Space Invaders tutorial, so you are expected to know how that code works. If you need a reminder of how to do something, refer back to the prelab. You are also encouraged to use the backpack built into the Blocks section of App Inventor to be able to transfer large portions of Space Invaders code to the CockyFootball screen.Initialize a global list called “players”.Add a “when CockyFootball.Initialize” block similar to the “when SpaceInvaders.Initialize” block. Within this event-handler, you will Set the BallSprite’s Visible property to false, just as in SpaceInvaders. Set the global players list to be the full components of Opponent1Sprite, Opponent2Sprite, and ReceiverSprite.In order to control the PlayerSprite, recreate the code that we used for the rocket in Space Invaders. Use PlayerSprite.Dragged and PlayerSprite.Touched events.(Reminder: You can drag portions of code to the backpack in your SpaceInvaders screen, then open the backpack again in CockyFootball and drag out the code you’ve saved.)In the “when PlayerSprite.Touched” event-handler, we want the BallSprite to become visible, enabled, have a speed of 20, and a heading of 90. In order to move it to a spot just above the player, reference the rocket sprite code in Space Invaders.Recreate the “when Bullet.EdgeReached” code for your BallSprite. Also make sure you disable the bullet within this event-handler.In Space Invaders, if the Bullet collided with anything, it was regarded as a point. In Cocky Football, there are 3 different possible items that the BallSprite could collide with: the receiver, the close opponent, and the far opponent. We want a different reaction for each one.(Hint: use the other variable associated with the BallSprite.CollidedWith event-handler.)If the item hit is the ReceiverSprite, then we want to increase USC’s score by 7 points.If the item hit is the close opponent, we want to increase Clemson’s score by 7 points.If the item hit is the far opponent, we want to increase Clemson’s score by 3 points.Regardless of which item is hit, the BallSprite must go invisible and disabled.In order to move the list of non-player sprites (Opponent1Sprite, Opponent3Sprite, and ReceiverSprite) randomly across the canvas, we will combine the “random item from a list” block with the Any component blocks and a local variable. We want to be able to have these sprites move each time the MovePlayerClock fires, so grab the appropriate block for this event.Inside the event-handler, use an “initialize local name to” block (found in Built-in -> Variables) and use “pick a random item list” along with a getter for your global players list in the “to “ portion of the local variable initialization.This sets a local variable to correspond to a random sprite component found in your global players list.In the “in” portion of the local variable initialization, use a “set ImageSprite.X” block (found in Any component -> Any ImageSprite) to move the randomly selected image sprite randomly about its x-axis.The component for which you are trying to change the X property is the component you’ve initialized as your local variable (likely, this variable is still called “name”).The “to” portion of this Any component setter block should follow the pattern seen in similar blocks in the Space Invaders tutorial.E.g., reference the code in the “when Clock1.Timer” event-handler.Below the local variable initialization block, add a block which will change the MovePlayerClock.TimerInterval to a random integer between 750 and 1500.We want the GameClock to count down from two minutes, so use the following blocks to accomplish this. Additionally, we want to check if our clock has gone below zero, and if it has, then we need to open the GameOver screen and store the value of the difference between the scores as the startValue of that screen.Program the Reset button to do what it’s supposed to. Make sure to catch all the labels and variables involved.Program the Main Menu button to take you back to Screen1.Part 2: Game OverYou will now complete your Cocky Football game by preparing the user interface and code for the Game Over screen.The Layout, continued:Switch to the GameOver screen, Designer view.Upload two more images from the files you downloaded in Part 1 of this lab. The two images are winner.png and lost.png.Add a Canvas and set its background image property to gameOverTexture.png and set its height and width properties to 300 pixels each.Add an Image Sprite to the Canvas and set its width to 100 pixels and its height to 50 pixels. Position this sprite at (100, 180).Add a button to return to the main menu (Screen1).The Coding, continued:Switch to Blocks view.As soon as the screen initializes, we want the sprite to take on one of two possible images. The images will be either winner.png or lost.png.Use the “get start value” block located under Built-in -> Control within the screen initialization event-handler to set the appropriate image for the image sprite.(Think! What should the start value—passed in from the CockyFootball screen—be if you’ve won? What should it be if you’ve lost?)Test your code! Ask your instructor if you get errors or if the output is incorrect. Submitting Your FileDownload your final version of the lab and save it under the 101Labs folder on X: Rename it if you did not add your initials (F2 or right-click file->Rename).We will grade it if we see this downloaded file (.aia file) in your directory so don’t download until you are done. We cannot see any of your work until you have downloaded the file to this directory so you haven’t submitted it until it is in X:\ .If you cannot find the file downloaded then, in the browser window, Ctrl-J to get to the default download location. You should then be able to click on “Show/Open in folder” to see the file in its folder. (“Ctrl-J” means hold down Ctrl and tap J, then release Ctrl) ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- the temperature converter
- proposal university of michigan
- city university of new york
- international trade binder
- tutorial on manual development
- agenda item vdoe virginia department of education home
- ee 477 final report purdue university
- q3a player characters putting them in the game
- career research project georgetown isd
Related searches
- how does temperature affect photosynthesis
- temperature widget windows 10
- temperature and photosynthesis rate
- local time temperature phone number
- temperature and photosynthesis lab
- temperature photosynthesis experiment
- what temperature should urine specimens be
- why does temperature affect photosynthesis
- how temperature affects photosynthesis
- photosynthesis temperature graph
- optimal temperature for photosynthesis
- desktop temperature icon windows 10