coding with “processing”

coding with “processing”
Instructions
Objective
The objective of this assignment is to get more practice with a larger more complex program requiring multiple functions to manage complexity. For full credit you will also need to make use of an array.
Program Specification
You are going to create a game like the battle room in Ender’s Game. In a very simplified variation of that game the player is trying to propel him/herself around the room in free-fall. S/he can only change direction by pushing off from an object. There are numerous objects in the room that provide both protection from enemy fire and places to change direction. In this version, the enemy is firing at random times in the direction of the player, but of course the enemies laser is blocked by the objects in the room. If the laser hits the player, their score goes down. If the score gets to zero the player loses. If the player makes it to the winning gate while his/her score is still above zero, s/he wins.
When the game starts the player has just entered the battle room halfway down the wall on the right hand side. The objective is for the player to move to the gate, located halfway down the wall on the left hand side. The player launches him/herself by clicking anywhere in the room. The player’s avatar will then begin moving at a constant velocity in the direction of the click until the player’s avatar bumps into something (the edge of the room, a “rock”, the enemy station, or the winning gate). If the player hits a rock or the edge of the room they grab on and stop moving until a new click sends them in a new direction. If they manage to hit the enemy station, they immediately launch off again in some random direction at some random speed similar to their normal launch speed.
When the game is over the win/lose condition should be clearly indicated (displaying a text message is fine – that does not mean printing it to the debug console with println()).
The score should be displayed constantly somewhere in the display. It can be done with numeric text or with some type of progress bar.
Each time the game is played, the position of the enemy station and the rocks should be determined randomly.
The enemy fire will be displayed by drawing a line from the enemy station in the direction of where it is fired that persists for about 1/6 second. It stops at a rock. If it hits the player they lose one point and the laser disappears immediately.
All collision detection will be done in a simplified manner using the color of the pixel under the player’s center position to determine if s/he has run into something or been hit by the laser.
You are free allow for adjustments in the difficulty of the game (more or fewer rocks, more rapid laser fire, faster/slower flight of the player, more/fewer initial points). You are welcome to add other variations or score adjustments (e.g. what happens if the player manages to touch the enemy base?).
You are encouraged to use an array to store the position and sizes of the rocks, but you can get it working without any arrays by just assuming a very small number of rocks (one is a good starting point).
The comments should make it clear how to easily modify the game parameters to allow for easy winning so that it can be tested quickly.
A short video of a very basic solution to the problem is available in the resources: endersDemo.
Getting Started
You will detect collisions by first drawing everything except the player’s avatar (which can be just a circle). After updating the player’s position, but before drawing the player’s avatar, use get(playerX,playerY) to get the pixel color of what is at that point.
If the color of that is the gate color, you have won.
If it is the color of the enemy station, head off in a random direction.
If it is laser colored, then you have been hit by the enemy laser.
If the color is that of a rock, you have hit a rock so stop.
You should also get it working completely with just one or two blocking objects. Add an array of objects as one of the final adjustments to the game.
Here is a method you can use to draw a laser beam.
/*
Draw a laser beam from the start point in the direction of the end point
but have it stop if it bumps into a rock.
*/
void drawBeam(int startX, int startY, int endX, int

💡 Buy the answer for only $12 Get it now →

endY) {
float laserX, laserY, laserDX, laserDY;
stroke(laserColor);
strokeWeight(5);
float distance = dist(endX, endY, startX, startY);
// expand the reach of the beam about 1 pixel per loop iteration
// so it doesn’t skip over anything
laserDX = (endX-startX)/distance;
laserDY = (endY-startY)/distance;
// make sure both laserDX and laserDY aren’t zero or the loop will never end
if (laserDX == 0 && laserDY == 0) {
return; // don’t draw anything
}
// lx,ly track where the beam will end
float lx = startX;
float ly = startY;
// move along in the direction of the beam until you hit the edge or an object
while (get ( (int)lx, (int)ly) != rockColor && lx > 0 && lx 0 && ly < height) { lx = lx + laserDX; ly = ly + laserDY; } // found the end of the laser beam – draw it line(startX, startY, lx, ly); } The math you need to compute the player's position each frame is the same as that used to compute the points (lx,ly) looking for the end of the laser shot. There of course won't be a loop, just update playerX and playerY (like lx and ly) each frame. The variables laserDX and laserDY correspond to what I call playerXvel and playerYvel. I recommend you follow these steps as you develop the game: Make sure you understand the laser function and write a program that uses it to draw a laser beam from some arbitrary "enemy station" x,y to where the mouse is clicked. Get the laser to display for just a few frames each time you click. Get the laser to fire at random times in the direction of the mouse. Get the player avatar to move in a straight line to where the mouse is clicked, using the math from the above laser function. Get the player avatar to move until it hits the edge. Add a rock and get the avatar to stop when it hits a rock. Add the enemy station and have it start firing the laser at the player location. Have the player immediately relaunch if it hits the enemy station. Add the enemy gate and detect winning. Add the score and the lose condition. Add more rocks, maybe an array of rocks. Repeated from the course info page: The programs you submit this quarter should be original programs created just for this class. It is NOT acceptable to submit programs that you (or someone else) has written previously. As indicated above, if you incorporate any portions of programs written by someone else, or by you for a prior course or assignment, then that should be clearly noted in the program via comments. (See "Giving Credit Where Credit is Due".) What To Turn In You will be submitting your program source file (.pde) in CrowdGrader. The link for the assignment in CrowdGrader is http://www.crowdgrader.org/crowdgrader/venues/view_venue/228 The direct link to where you make the submission is http://www.crowdgrader.org/crowdgrader/submission/view_own_submission/v/228 After the due date you will need to review 5 submissions by going to http://www.crowdgrader.org/crowdgrader/rating/reviews/228 As soon as you have met with your partner to confirm you can work together you should follow the assignment link above and enter the email address for your partner in the group field. The must be done at least 48 hours before the due date. When you and your partner have completed your sketch (program): submit the .pde file as your CrowdGrader submission. Submit ONLY the .pde file (e.g. MySketch.pde). On your personal computer that file is probably in Documents/Processing/MySketch. In BE109 it should be in x:Processing/MySketch (follow userName's home directory on the Desktop then Processing). BOTH of you should paste a programming log into the text area on the submission page in ecommons. Use one of the sample logs as a template. If you have added any files to your project (fonts or images) then you will need to create a zip file of the sketch folder including both the .pde file(s) and the data folder found there. For instructions on how to create the zip file see the resources. Grading See the grading rubric in CrowdGrader. Although not part of the student review grading process in CrowdGrader, you will lose one point if you fail to submit a program log in ecommons. Attachments: img_6807.jpg Computer Science homework help This is property of termpaperchampions.com. Log in to Buy an essay online from us.

💡 Buy the answer for only $12 Get it now →