Question: C++ Only// In this project, you must create a simple game of air hockey. In this game, two players are trying to get an air
C++ Only//
In this project, you must create a simple game of air hockey. In this game, two players are trying to get an air hockey puck into the each others net. Each player must move their character to touch the puck. Once you touch it, it will change direction.
The puck must also change color to indicate which player touched it last (the puck starts with a neutral color).
You must draw the 2 nets, on either side of the table. The player characters, the puck and the nets can be simple shapes (e.g. you are a square, your opponent is a triangle, your puck is a circle and your nets are rectangles).
Requirements Create an object structure (and use it)
o This structure must minimally contain 3 integers: an x, a y and color. o A color can be stored in an int, as makecolor() returns an integer. Create a function that will print out a pixel-by-pixel drawn object. o Your function should have as parameters: a BITMAT * buffer, the object structure (x and y coordinate of the new object and its color), the size of the object (e.g. length and height of the rectangle).
o You must draw this object pixel by pixel. o The rectangle is the easiest to draw. Other objects (circles, triangles, angled lines) will be considered extra work. Use objects drawn using Allegro functions (circle, triangles, etc.).
Create a puck at a random location within the middle third of the table Make your puck moves automatically. o It should start with a random direction. The speed of the puck can be constant throughout the program
Include user input: use the four arrow keys to have one user move their character around, and the letters AWSD for the other user to move their character. Do basic collision detection
o Check if a user is in the vicinity of the puck by looking whether the (x,y) coordinates of the user is close to the (x,y) coordinates of the puck o If the user is near an enemy, change the pucks color, and make it change direction logically.
o Check if a puck enters a net by using the same technique. Display the winner of the game. Use the escape key to exit the program You must have at least 4 functions in addition to the main function. These must be relevant and meaningful. One of those functions can be the one to draw your object. Have fun with this. Play around with different shapes, create something nice.
The extra work component (15%) rewards project that are exceptionally well-executed detail, or where student have done extra work to the project. Extra work means going further. For instance, in a game, this could mean: Offering more user input options than required Implement difficulty levels Use randomness to create your object (e.g. size, or exact color) Having multiple pucks at once Doing multiple games in a row (instead of starting the program again) Making the display visually great This is not an exhaustive list of possibilities, nor are they of equal difficulty level. Extra work Marks will be given according to difficulty level. Each case will be evaluated individually, based on the description given in the text file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
