Adding some comments

This commit is contained in:
Licht 2014-11-25 11:42:20 +01:00
parent e17e3414cd
commit 4e5d6bcd52
6 changed files with 141 additions and 16 deletions

View File

@ -2,6 +2,9 @@ package de.teamteamteam.spacescooter.background;
import de.teamteamteam.spacescooter.entity.Entity;
/**
* Class for all backgrounds that are painted in the background of the level
*/
public abstract class Background extends Entity {
public Background(int x, int y) {

View File

@ -2,19 +2,30 @@ package de.teamteamteam.spacescooter.background;
import java.awt.Graphics2D;
/**
* The StarBackground of the first level
*/
public class StarBackground extends Background {
private int y;
/**
* Constructor for the background
*/
public StarBackground(int x, int y) {
super(x, y);
this.y = y;
this.setImage("images/starbackground.png");
}
/**
* offset in x-direction for the painting
*/
private int offset = 0;
/**
* standart update method
*/
public void update() {
this.offset -= 2;
//System.out.println(this.offset);
@ -23,6 +34,9 @@ public class StarBackground extends Background {
}
}
/**
* standart paint method
*/
public void paint(Graphics2D g) {
g.drawImage(this.getImage(), (0+this.offset), this.y, null);
g.drawImage(this.getImage(), (this.getImage().getWidth()+this.offset), this.y, null);

View File

@ -1,18 +1,33 @@
package de.teamteamteam.spacescooter.datastructure;
/**
* Score Class to represent the Player's Score
*/
public class Score {
/**
* Score can be between 0 and 99999999
*/
private static int score = 0;
private static int maxScore = 99999999;
/**
* Getter for the Score
*/
public static int getScore() {
return score;
}
/**
* Setter for the Score
*/
public static void setScore(int score) {
Score.score = score;
}
/**
* Method for adding Score
*/
public static void addScore(int score) {
if (Score.score + score >= Score.maxScore) {
Score.setScore(Score.maxScore);
@ -20,7 +35,10 @@ public class Score {
Score.score += score;
}
}
/**
* Method for removing Score
*/
public static void removeScore(int score) {
if (Score.score - score <= 0) {
Score.setScore(0);

View File

@ -10,13 +10,35 @@ import de.teamteamteam.spacescooter.entity.spi.Collidable;
import de.teamteamteam.spacescooter.sound.SoundSystem;
import de.teamteamteam.spacescooter.utility.GameConfig;
/**
* Class that represents the Player, and handle all the KeyboardActions
*/
public class Player extends ShootingEntity implements KeyboardListener {
/**
* the Player's Keyboard
*/
private Keyboard keyboard = null;
private double healthPercent = 0;
private double shieldPercent = 0;
private int rocketAmount = 1;
/**
* the Players Health Points in percent
*/
private double healthPercent = 0;
/**
* the Players ShieldPoints in percent
*/
private double shieldPercent = 0;
/**
* the Players Rocket Ammunition
*/
private int rocketAmount = 1;
/**
* Constructor for initializing the Player on the GameScreen
*/
public Player(int x, int y) {
super(x, y);
this.setImage("images/ship.png");
@ -32,11 +54,17 @@ public class Player extends ShootingEntity implements KeyboardListener {
this.registerOnKeyboard(Keyboard.getInstance());
}
/**
* Method for register the Player on the Keyboard
*/
private void registerOnKeyboard(Keyboard keyboard) {
this.keyboard = keyboard;
this.keyboard.addListener(this);
}
/**
* Standard update method
*/
public void update() {
if (StaticValue.HealthPoints != 0) {
this.healthPercent = ((double) this.getHealthPoints() / (double) StaticValue.HealthPoints) * 100;
@ -83,12 +111,18 @@ public class Player extends ShootingEntity implements KeyboardListener {
}
}
/**
* Explode method that trigger the ShootingEntity.explode() method and play a nice sound
*/
@Override
public void explode() {
super.explode();
SoundSystem.playSound("sounds/abgang.wav");
}
/**
* createShot method that trigger the ShootingEntity.createShot() method and play a nice sound
*/
@Override
public void createShot() {
super.createShot();
@ -107,6 +141,9 @@ public class Player extends ShootingEntity implements KeyboardListener {
super.remove();
}
/**
* keyPressed method, comes in handy when a key on the keyboard is pressed
*/
public void keyPressed(KeyEvent e) {
//spontaneous fire happens here
if(e.getKeyCode() == KeyEvent.VK_SPACE) {
@ -114,6 +151,9 @@ public class Player extends ShootingEntity implements KeyboardListener {
}
}
/**
* keyReleased method, reacts if a key on the keyboard is released
*/
public void keyReleased(KeyEvent e) {
//space up -> reset shot cooldown
if(e.getKeyCode() == KeyEvent.VK_SPACE) {
@ -121,16 +161,28 @@ public class Player extends ShootingEntity implements KeyboardListener {
}
}
/**
* empty keyTyped method, maybe useful for cheatcodes later
*/
public void keyTyped(KeyEvent e) {}
/**
* return the Healthpercentage of the Player
*/
public int getHealthPercent() {
return (int) this.healthPercent;
}
/**
* return the Shieldpercentage of the Player
*/
public int getShieldPercent() {
return (int) this.shieldPercent;
}
/**
* method for increasing the HealthPoints with the Heal-Item
*/
public void increaseHealthPoints(int inc) {
if (this.getHealthPoints() <= 85) {
this.setHealthPoints(getHealthPercent() + inc);

View File

@ -1,18 +1,39 @@
package de.teamteamteam.spacescooter.entity;
/**
* Static Values for the Player and the Shop
*
*/
public class StaticValue {
//Player
/**
* Values for the player
* the ShootDamage of the Player
*/
public static int ShootDamage = 5;
public static int HealthPoints = 100;
public static int ShieldPoints = 100;
/**
* Values for the shop
* the HealthPoints of the Player may be changed by the 1Up-Item
*/
public static int HealthPoints = 100;
/**
* the ShieldPoints of the Player
*/
public static int ShieldPoints = 100;
//Shop
/**
* The Damage Value of the Shop
*/
public static int schaden = 0;
/**
* the Shield value of the Shop
*/
public static int schild = 0;
/**
* the Health value of the Shop
*/
public static int leben = 0;
}

View File

@ -4,9 +4,16 @@ import de.teamteamteam.spacescooter.entity.ShootingEntity;
import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.sound.SoundSystem;
import de.teamteamteam.spacescooter.utility.Random;
/**
* The Enemy class that handle all the Enemies out there.
* Including bosses and minibosses.
* This class inherit all the properties of the enemies to every subclass
*/
public abstract class Enemy extends ShootingEntity {
/**
* Constructor for one Enemy, which will construct a ShootingEntity
*/
public Enemy(int x, int y) {
super(x, y);
this.name = "EnemyOne";
@ -15,9 +22,19 @@ public abstract class Enemy extends ShootingEntity {
this.setShootDamage(5);
}
/**
* Name of the Enemy
*/
protected String name;
/**
* boolean value that will determine whether a new spawned enemy will shoot or not
*/
protected boolean willShoot;
/**
* standard update method
*/
public void update() {
super.update();
if(willShoot == true)