* Initialize an enemy with the given coordinates and initial velocity
* @param xPos X point
* @param yPos Y point
* @param xVel X velocity
* @param yVel Y velocity
*/
publicEnemy(intxPos,intyPos,intxVel,intyVel){
super(xPos,yPos,xVel,yVel);
}
/**
* Checks if the given points are within the sprite and reduce the health if so
* @param xx Other X point
* @param yy Other Y point
* @return True if input xx and yy are within the sprite
*/
@Override//the return doesn't really mean anything all we need is that when any of the point hit within the hit box of player, call the loose health function.
publicbooleancheckForCollision(intxx,intyy)
{
if(super.checkForCollision(xx,yy)){
loseHealth();
returntrue;
}else{
returnfalse;
}
}
/**
* Decrease the health of the player
*/
// when loseHealth drop the help to 0, call the destroy function. which we will override ltr
@@ -35,11 +35,23 @@ public class Player extends Sprite{
//get input from the joystick, and change the location
// tbh I think this is going to give us an error ltr, because we are going to call update and shoot constantly, I wonder what will happen if we write and deleting at the same time. We'll see tho
/**
* Update the position of the player based on joystick offset
* Checks if the given points are within the sprite and reduce the health if so
* @param xx Other X point
* @param yy Other Y point
* @return True if input xx and yy are within the sprite
*/
@Override//the return doesn't really mean anything all we need is that when any of the point hit within the hit box of player, call the loose health function.
publicbooleancheckForCollision(intxx,intyy)
{
@@ -51,8 +63,11 @@ public class Player extends Sprite{
}
}
/**
* Decrease the health of the player
*/
// when loseHealth drop the help to 0, call the destroy function. which we will override ltr