Create packages for enemies, shots and items.

This commit is contained in:
Jan Philipp Timme 2014-11-04 19:33:30 +01:00
parent e713ee4817
commit 881b802e7a
22 changed files with 111 additions and 81 deletions

View File

@ -1,4 +1,4 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.background.item;
import java.util.Random;

View File

@ -1,6 +1,10 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.background.item;
import java.util.LinkedList;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.LivingEntity;
import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.screen.Screen;
public abstract class Items extends LivingEntity{

View File

@ -1,4 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.background.item;
import de.teamteamteam.spacescooter.entity.Player;
public class TestItem1 extends Items{

View File

@ -1,4 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.background.item;
import de.teamteamteam.spacescooter.entity.Player;
public class TestItem2 extends Items{

View File

@ -1,4 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.background.item;
import de.teamteamteam.spacescooter.entity.Player;
public class TestItem3 extends Items{

View File

@ -1,4 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.background.item;
import de.teamteamteam.spacescooter.entity.Player;
public class TestItem4 extends Items{

View File

@ -3,6 +3,10 @@ package de.teamteamteam.spacescooter.entity;
import java.awt.Rectangle;
import java.util.LinkedList;
import de.teamteamteam.spacescooter.background.item.Items;
import de.teamteamteam.spacescooter.entity.enemy.Enemy;
import de.teamteamteam.spacescooter.entity.explosion.Explosion;
import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.screen.Screen;
import de.teamteamteam.spacescooter.utility.GameConfig;

View File

@ -4,6 +4,7 @@ import java.awt.event.KeyEvent;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.control.KeyboardListener;
import de.teamteamteam.spacescooter.entity.shot.Shot;
import de.teamteamteam.spacescooter.utility.GameConfig;
public class Player extends ShootingEntity implements KeyboardListener {

View File

@ -1,5 +1,6 @@
package de.teamteamteam.spacescooter.entity;
import de.teamteamteam.spacescooter.entity.shot.SingleBlueShot;
import de.teamteamteam.spacescooter.screen.Screen;
public abstract class ShootingEntity extends LivingEntity {

View File

@ -1,6 +1,9 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.enemy;
import java.util.Random;
import de.teamteamteam.spacescooter.entity.ShootingEntity;
import de.teamteamteam.spacescooter.entity.shot.Shot;
public abstract class Enemy extends ShootingEntity {
public Enemy(int x, int y) {

View File

@ -1,61 +1,61 @@
package de.teamteamteam.spacescooter.entity;
import java.awt.Point;
import java.util.ArrayList;
public class EnemyFour extends Enemy{
private ArrayList<Point> points;
private int index =0;
private Point nextPoint;
private double x;
private double y;
private double vektorX;
private double vektorY;
public EnemyFour(int x, int y, ArrayList<Point> points) {
super(x, y);
this.setImage("images/nyancat.png");
this.setShootSpeed(4);
this.setShootDelay(42);
this.setShootSpawn(-10, 10);
this.setHealthPoints(5);
this.points = points;
this.x = x;
this.y = y;
this.setCollisionDamage(this.getHealthPoints());
getNextPoint();
}
@Override
public void update() {
super.update();
this.x -= vektorX;
this.y -= vektorY;
this.setPosition((int)x, (int)y);
if(this.getX() == (int)nextPoint.getX() && this.getY() == (int)nextPoint.getY()){
getNextPoint();
}
}
private void neuerVektor(){
vektorX = (this.getX() - nextPoint.getX());
vektorY = (this.getY() - nextPoint.getY());
double laenge = Math.sqrt(this.vektorX * this.vektorX + this.vektorY * this.vektorY);
vektorX = vektorX/laenge;
vektorY = vektorY/laenge;
}
private void getNextPoint(){
try{
nextPoint = points.get(index);
index++;
neuerVektor();
}catch(IndexOutOfBoundsException e){
this.remove();
}
}
}
package de.teamteamteam.spacescooter.entity.enemy;
import java.awt.Point;
import java.util.ArrayList;
public class EnemyFour extends Enemy{
private ArrayList<Point> points;
private int index =0;
private Point nextPoint;
private double x;
private double y;
private double vektorX;
private double vektorY;
public EnemyFour(int x, int y, ArrayList<Point> points) {
super(x, y);
this.setImage("images/nyancat.png");
this.setShootSpeed(4);
this.setShootDelay(42);
this.setShootSpawn(-10, 10);
this.setHealthPoints(5);
this.points = points;
this.x = x;
this.y = y;
this.setCollisionDamage(this.getHealthPoints());
getNextPoint();
}
@Override
public void update() {
super.update();
this.x -= vektorX;
this.y -= vektorY;
this.setPosition((int)x, (int)y);
if(this.getX() == (int)nextPoint.getX() && this.getY() == (int)nextPoint.getY()){
getNextPoint();
}
}
private void neuerVektor(){
vektorX = (this.getX() - nextPoint.getX());
vektorY = (this.getY() - nextPoint.getY());
double laenge = Math.sqrt(this.vektorX * this.vektorX + this.vektorY * this.vektorY);
vektorX = vektorX/laenge;
vektorY = vektorY/laenge;
}
private void getNextPoint(){
try{
nextPoint = points.get(index);
index++;
neuerVektor();
}catch(IndexOutOfBoundsException e){
this.remove();
}
}
}

View File

@ -1,4 +1,4 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.enemy;
public class EnemyOne extends Enemy {

View File

@ -1,9 +1,12 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.enemy;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Random;
import de.teamteamteam.spacescooter.background.item.Items;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.screen.Screen;
import de.teamteamteam.spacescooter.utility.GameConfig;

View File

@ -1,4 +1,4 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.enemy;
import java.util.Random;

View File

@ -1,7 +1,8 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.explosion;
import java.util.Random;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.screen.Screen;

View File

@ -1,4 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.explosion;
import de.teamteamteam.spacescooter.entity.Entity;
public class ExplosionOne extends Entity {

View File

@ -1,4 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.explosion;
import de.teamteamteam.spacescooter.entity.Entity;
public class ExplosionTwo extends Entity {

View File

@ -1,5 +1,6 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.shot;
import de.teamteamteam.spacescooter.entity.LivingEntity;
import de.teamteamteam.spacescooter.utility.GameConfig;
public abstract class Shot extends LivingEntity {

View File

@ -1,4 +1,4 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.shot;
public class SingleBlueShot extends Shot {

View File

@ -1,4 +1,4 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.shot;
public class SingleRedShot extends Shot {

View File

@ -1,4 +1,4 @@
package de.teamteamteam.spacescooter.entity;
package de.teamteamteam.spacescooter.entity.shot;
public class SingleShot extends Shot {

View File

@ -8,13 +8,13 @@ import java.util.Iterator;
import java.util.LinkedList;
import de.teamteamteam.spacescooter.background.StarBackground;
import de.teamteamteam.spacescooter.background.item.ItemChance;
import de.teamteamteam.spacescooter.control.Keyboard;
import de.teamteamteam.spacescooter.entity.EnemyFour;
import de.teamteamteam.spacescooter.entity.EnemyThree;
import de.teamteamteam.spacescooter.entity.Entity;
import de.teamteamteam.spacescooter.entity.HealthBar;
import de.teamteamteam.spacescooter.entity.ItemChance;
import de.teamteamteam.spacescooter.entity.Player;
import de.teamteamteam.spacescooter.entity.enemy.EnemyFour;
import de.teamteamteam.spacescooter.entity.enemy.EnemyThree;
public class GameScreen extends Screen {