Graphics Version of Angry Birds!

The images you will need are the angry bird and the green pig. These are available at the top of the program 2 assignment page. Just right click on them and save image as.... Make sure they are saved as gif files. You are free to choose other images as you like, but the filenames must be bird.gif and pig.gif.

The bird "animation" is having the bird gif be drawn at 2 new places on the screen. The first new place is halfway between the bird on the left edge of the screen and the distance that the program has calculated that the bird will travel in total. The second new place is at the distance that the program calculated the bird will travel. Those are the x values. The y values for the first and third images can be very close to the lower edge of the screen, something like 10. (Using zero here would mean half the bird isn't visible.) The y value for the middle image is the height calculated by the program. If you want to add in more bird images, you are free to.

There are several inputs for this game. In the graphics version they will need to be done with Entry input boxes. The first two (number of rounds and difficulty) will only be done one time, at the start of the game. These two numbers are integers. The angle and velocity inputs will be done repeatedly for each round. These two numbers are floats.

You must write a function besides the main function, which will have the job of inputting two pieces of data from the graphics window and returning them. It will have 5 parameters: the graphics window, the two prompts you want to display for the two pieces of data, and the location (as x and y) on the screen where you want the first prompt to start. The rest of the graphics objects should be displayed at some fixed distance from that location. It returns the two pieces of data as STRINGS. Do NOT typecast them to numbers inside the function. Let the code that calls this function to decide what type the data should be and typecast it at that time.

Make sure that the function cleans up after itself. All prompts and Entry boxes should be undrawn before the function returns.

Add in a bit of code at that time that protects your program somewhat from empty strings being returned. If an empty string is returned, pick some default value for that item.

Feel free to be creative with the design of the game. Colors, fonts, locations, etc. are up to you. The only requirements are that you have the information on the screen at the appropriate times as shown in the screenshots below.

Note that the pig location changes on each round. That means that the pig icon will need to be undrawn and redrawn.

Screen Shots

Cleanup

You notice in the screen captures that all the information that is displayed is "clean". This means that it is NOT just displayed on top of the old values that were there. When the Points changes from 2 to 3, the 3 is not displayed on top of the 2. You can use setText very nicely here. Hint: set up your Text objects before you enter the main game loop. Put blank strings in them and give them their locations.

  • If you need for the message to stay on the screen most of the time, like "Points", draw the Text object before the loop starts. When you are ready in the loop to change the value of the Points, and use setText to change the string in the object.
  • If you want a message to stay on the screen only until they click, for example, then do not draw the Text object before the loop starts. In the loop, when you are ready to display the message, like "Distance", then setText the correct value in the string in the object, then draw it. When they click to go on, then you can undraw it.
    If you would rather use these images, rename the files to bird.gif and pig.gif. You can certainly find others that you like on the net.