The Chip-Flinger Game – Project 4

DIG 3134 – Fall 2012 - Moshell

A popular(?) recreation in some parts of the country, before video games, was the tossing of ‘cowpies’. There are varying opinions as to what a “cowpie” is (see images below), but back where I came from, they consisted (after an appropriate drying period) of a dry, crunchy disk, about frisbee-sized, of (shall we say) “reprocessed grass”.

Here are some artist’s ideas of what a cowpie should look like. (Credits below)

You, the Videogame Generation, are about to be RE-introduced to the joys of this ancient sport. The Starter Kit provides the basic skeleton of the game. The user specifies two things – the angle and the velocity of the toss – and clicks on a button: “Launch Cowpie!”. The software then draws an arc, and shows (with an X) where the pie lands.

Your mission (should you choose to accept it (and what choice do you have?) is to take this basic game and enhance it in a number of ways.

PHASE 1: ADD THESE “IN ORDER”

Step 0: Run my Demo. (60 pts) Download cowpie1.txt; save it as cowpie1.php in your WAMP or MAMP’s docroot directory. When this code runs without modification on Sulley, you are at the 60 point level. There is just one button: (LAUNCH COWPIE!) and two numeric inputs: angle (1 to 89 degrees) and velocity (1 to 500 meters/second.) Try cowpie1.php.

Step 1: Database Memory (70 pts) The first and required enhancement is that each “shot” is recorded, so that the user can request a replay of all the previous shots. You must provide the following controls:

LAUNCH COWPIE! (as before)

SHOW HISTORY, which displays all the previous shots in the library.

ERASE HISTORY, which clears all the previous shots from the history.

The database table will be very simple; it just needs to record the angle and velocity that was used for each shot. To play back the shots, the system just calls the ‘drawtrajectory’ function in a loop, once for each stored (angle,velocity) pair. HINT 1: I already gave you a ‘starter kit’ for database activities, in the small “address book” application. It contains everything you need to do this step. Also, I’ll help if needed. NOTE the Appendix below about how I will TEST the database functionality.

Step 2: Obstacles (75 pts) (and I’m practically giving you this one, in cowpie2.php). Put one or more visual obstacles in the way of the flying pies. Also provide a visible target area (just another colored rectangle) so that the pie (the X) must touch the target area to be counted as a successful toss. These simple obstacles don’t actually stop flying pies, and a hit on the target is determined visually, not by the software.

PHASE 2: ADD THESE IN ANY ORDER YOU DESIRE

Pies that Plop. (+3 pts). Show an actual pie (your choice of images) at the landing point, instead of an X. I will provide HINT 2 to help you do this.

Whose turn is it? (+2 pts). The usual “Gold’s turn, Black’s turn” announcement.

Obstacles that WORK (+5pts.) Figure out how to make your trajectory stop when it hits an obstacle. I will provide HINT 3 to help with this.

Switchable Obstacles and Grass (+2 pts.) Make your obstacle, and the grass, “switchable on or off” as in my cowpie demo, via a checkbox. HINT 4 will help you with this. The checkboxes must be persistent to get the points.

Collisions (+5 pts) When the trajectory hits an obstacle, don’t just stop drawing it. Give us a puff of dust, a nuclear explosion, something interesting, at the point of the collision. HINT 2 can also help you do this.

Scoring (+5 pts). Provide two or more target zones of different sizes, awarding the player 1 point for touching the larger, and 2 points for touching the smaller zone. Keep score for both teams. HINT 3 will also be useful for this task.

You may also propose other enhancements, for negotiated amounts of credit.

PHASE 3: FOR THE ELITE

At most a few of you will go this far… but I like to provide some sky’s-the-limit options.

Brick-out. (+5 pts.) The thrown pies, although they are stopped by obstacles, knock holes in the obstacles through which future pies can travel.

AUV Pies, or Trick Shots (+5 pts.) We move beyond simple ballistics. Your pie-shots can now controlled by an XML file that specifies a series of (x,y) locations, in this form:

<trajectory>

<x>10</x<y>10</y>

<x>10</x<y>20</y>

<trajectory>

Your software includes a window into which to type the name of a file, such as ‘flight1.xml’. When the program detects a filename in this window, instead of a ballistic pie-shot, the series of (x,y) points are used to generate an interesting flight of the pie. They can do loop-de-loops, or fly straight up and turn abruptly eastward, etc.

AND … you may think of other game-play ideas and propose them to me.

APPENDIX: Scoring the Database Activity.

It should have occurred to you that one might try to ‘fake’ the database storage by just creating an array and keeping it in a Session Variable. Aha, I’m onto your wiley tricks.

Wikipedia.org; © Warner Brothers.

I will use TWO browsers. I will first open your project in Browser A, and store a few pie-shots. I will then open your project in Browser B, and click on “Show History”. Any sneaky session variables that tried to store the history will be associated with the cookie in Browser A but not with one in Browser B. So the only way your program would work, would be if the history were truly in a database (or other persistent file of some kind.)

Credits for cowpie images are (left to right):

Markbeam.com

memeart.tripod.com

sh**tyimage.com