Java processing 4
Assignment 3 – A Game of Shoot ’em up Total Points: 34 (accounting for 10% of your final grade) Assignment Summary In this assignment, you will create your own game from 2 custom classes and 3 subclasses. You will practice the concepts of methods, parameters, arguments, if else statements, for loops, ArrayLists, PVector, object, inheritance and polymorphism. The basic game must have this rough form: - The human user controls a Player character (aka avatar) using the keys on the keyboard - There are two types of “target/enemy” objects onscreen. The player’s objective is to fire some kind of projectile at the targets/enemies. The types of targets differ in how many times the player needs to hit them with the projectile before they are removed from the game. Learning objectives By the end of this assignment, you will have earned the following skills: a) Create a subclass that extends a general class, so that you can create new functionality by building on existing functionality you have already written b) Use method overriding in your subclass to allow the subclass to implement some methods differently than its parent c) Detect collisions between different objects in your application d) Enable users to control the onscreen objects using the keyboard Also with this assignment, you have the opportunity to: a) Explore different kinds of game mechanics using a simple game base b) Begin developing your programmer-intuitions about how to efficiently design and organize the coding logic of your applications to facilitate extension and iterative development Assignment (30 points) Because the overall purpose of this assignment is to start you the process of using OOP concepts and techniques to design and implement your program, we’ve imposed a lot of requirements on how you need to create the game. I have described each of these requirements in the table below. Be sure to read them very carefully and use them to design and implement your various classes and methods! Application Requirements: 4 points • Visual collision between enemies and player (and the player projectile) must be done accurately. -1 If a player projectile damages the enemy without reaching it visually, or does not damage after reaching it. The same with the player when hit the enemy. • Visual collision between the boss and player (and their projectile) must be done accurately. -1 If player or boss projectiles damages their target without reaching it visually, or does not damage after reaching it. The same with the player when hit the boss. • When enemies or boss hit the player, player must lose one health for each collision. -1 If enemies or boss reduce the player’s health continually as long as they are in contact with the player. • Each of the Player, Basic Enemy, Boss Enemy, and Projectiles objects must be displayed on the screen to get credit -1 application requirement point + minus half of the coding requirement points (see the table below) if any of the objects above is not displayed Coding Requirements: 20 points A Character superclass Requirement points: 3 A Player subclass Requirement points: 5 A “Basic Enemy” subclass Requirement points: 3 A “Boss Enemy” subclass Requirement points: 4 A Projectile class Requirement points: 3 Your Main Sketch Requirement points: 2 -at least five fields for: • position (PVector) • velocity (PVector) • health • width • height -.25 for any missing field. -a moveCharacter method that moves the Character, using its velocity and position fields -.5 if you don’t have this method in Character or if you don’t use the Character fields. -an accelerate method that changes the Character’s velocity using an accelerator (PVector) -.5 if you don’t have this method in Character or if you don’t change the Character’s velocity using an accelerator (PVector) -a “dummy” drawCharacter method that just draws a placeholder shape, which will be overridden by subclasses -.5 is drawCharacter method missing from Character -a hitCharacter method that detects when two Characters have collided: • has a single parameter of type Character • returns a boolean indicating whether or not the two Characters collided. -.25 parameter has wrong type -.25 method doesn’t return a boolean -.5 method doesn’t work when the parameter Character has collided with this Character. -a decreaseHealth method that decreases the health of the Character • has a single parameter of type int, representing the -extends the Character class -1 Player isn’t a subclass of Character or redefines fields of superclass -human user can move the Character using four keys (either WASD or the arrow keys) -.75 Player doesn’t move by keypress -the player character can move freely through the screen, horizontally, vertically, or diagonally -.5 Player only moves in one drection at a time - can fire and keep track of projectile objects • Player uses a typed ArrayList to store its projectile objects. -.5 ArrayList to track projectiles doesn’t exist OR is defined outside the Player class -player class has a method, checkProjectiles, which iterates through each projectile object in its projectile list and checks against each enemy to see if it hits the enemy. If the projectile hit the enemy, the player class damages the enemy. In addition, the projectiles should check whether they hit the boss and damage the boss if so • use a nested for- -extends the Character class -1 Enemy isn’t a subclass of Character or redefines fields of superclass -must NOT FIRE projectiles -.5 enemy fires projectiles -player takes damage if they collide with the basic enemy -.5 any logic error that prevents this from occurring. -player needs to fire between 2-3 projectiles at the basic enemy and hit it before it “dies” (has 0 health) -.5 basic enemies die after one hit -when basic enemy health is 0, it appears dead/captured/different in some way for 1 second before it is removed from the game. -.5 dies instantly or doesn’t change appearance during pre-death period -basic enemy overrides Character update method so that it checks whether it collides with the player and damages the player if so. -.5 collisions with player checked anywhere other than in enemy’s update method or not at all -basic enemy overrides Character draw method. -.5 no overridden draw method * Total deduction for Basic Enemy class Requirements caps at 3 pts even if the add- up goes over it -extends the Basic Enemy class -1 Boss isn’t a subclass of Basic Enemy class or redefines fields of superclass (those of either Basic Enemy or Character) -can fire and keeps track of projectile objects in a typed ArrayList • The Boss projectiles are either the same class as the Player’s Projectiles OR they are a subclass of Projectile that extends the functionality in some way. -.5 ArrayList to track projectiles doesn’t exist OR is defined outside the Boss Enemy class -.5 Boss projectiles look identical to Player’s ones -Boss has a method, checkProjectiles, which through each projectile object in its projectile list and uses the Projectile’s hit method to check whether it hits the PLAYER only and damage the player if so -.5 checks collisions against anything other than Player (i.e. with Basic Enemies) -0.5 Player isn’t damaged by the Boss bullets -player takes damage if they collide with the boss enemy -.5 any logic error that prevents this from occurring. -player needs to fire 6 to 8 projectiles at the boss enemy and hit it before basic enemy “dies” (has 0 health) -.5 dies after fewer than 6- 8 hits -when boss enemy health is 0, it appears dead/captured/different in some way for 3 seconds before it is removed from -Projectile is a standalone class. -1 Projectile is a subclass of Character -has fields for position and velocity -has a constructor with a parameter that represents initial velocity -.25 for any missing field. -a move method that moves the projectile -.5 method missing -a checkWalls method that checks if the projectile has gone out of the screen. -.5 method missing -an update method that calls the move, draw and checkWalls methods. -projectiles that go out of the screen should be removed from the list that holds it. -.5 update method missing or fails to invoke move, checkWalls and draw methods -.5 projectiles aren’t removed from list when they go offscreen -a method that draws the projectile -.5 missing method -a hit method that checks if this projectile hit a Character • has a single parameter, typed Character • returns a boolean indicating whether or not -keep track of basic enemies in a typed ArrayList. -.5 basic enemies not in a typed ArrayList -keep track of player’s score (related somehow to the number of enemies killed) in a global int variable or define a class for score -display the score somewhere on the screen -.5 score isn’t tracked at all -.5 score is tracked but doesn’t appear on screen -there is only one boss. • Store the boss in the same ArrayList for the basic enemies along the line of inclusion polymorphism. -1 boss stored in a single variable or inside its own ArrayList instead of the same ArrayList for basic enemies damage. -.5 method missing from Character class. -.25 missing parameter -.25 body of method doesn’t use parameter to decrement health field -a checkWalls method that checks whether the character has gone off the screen boundaries and compensates in some way (i.e., reappear on opposite side, bounce/reverse velocity) -.5 method missing from Character class. -.25 any error in collision logic, including use of wrong type of collision (bounding box vs radial) or failure to factor Character’s dimensions into the calculation of the bounds check -has an update method that calls the move, and check walls -.5 method missing from Character class. -.25 update method body doesn’t invoke move, checkWalls * Total deduction for Character class Requirements caps at 3 pts even if the add-up goes over it loop to check the projectiles against eh basic enemies • call the projectile’s hit method to check whether the projectile hit the enemy. -.75 Player can’t shoot projectiles at all or projectiles don’t damage the enemies when they hit -.5 No nested for- loop -.25 check against the boss is also inside of the nested for loop (instead of just happening once for each projectile) -player overrides Character update method so that it calls checkProjectiles. -.25 logic to check the projectiles isn’t inside a method called checkProjectiles -.25 method called from anywhere other than an overriden update -player overrides Character’s drawCharacter method. -.5 no overriden draw method * Total deduction for Player class Requirements caps at 5 pts even if the add-up goes over it the game. -.5 dies instantly or doesn’t change appearance during pre- death period -boss enemy overrides Basic Enemy’s update method so that it: • checks whether it collides with the player and damages the player if so. • calls the checkProjectiles method -.5 code that