so these happened
parent
24a2056c34
commit
b30711e2cf
|
|
@ -51,9 +51,9 @@ public class SpaceWars implements BasicApp {
|
||||||
if (e1.isCollidable()) {
|
if (e1.isCollidable()) {
|
||||||
for (int j = i + 1; j < entities.size(); j++) {
|
for (int j = i + 1; j < entities.size(); j++) {
|
||||||
Entity e2 = entities.get(j);
|
Entity e2 = entities.get(j);
|
||||||
if(e2.isCollidable()) {
|
if (e2.isCollidable()) {
|
||||||
|
|
||||||
//because efficiency.
|
// because efficiency.
|
||||||
e1.collidedWith(e2);
|
e1.collidedWith(e2);
|
||||||
e2.collidedWith(e1);
|
e2.collidedWith(e1);
|
||||||
|
|
||||||
|
|
@ -123,10 +123,9 @@ public class SpaceWars implements BasicApp {
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
try {
|
try {
|
||||||
background = ImageIO.read(new URL("http://wallpaperswiki.org/wallpapers/2012/11/Wallpaper-Abstract-Wallpaper-Background-Texture-Texture-Yellow-Pictures-600x1024.jpg"));
|
background = ImageIO.read(new URL("http://wallpaperswiki.org/2012/11/Wallpaper-Abstract-Wallpaper-Background-Texture-Texture-Yellow-Pictures-600x1024.jpg"));
|
||||||
entities.add(player);
|
entities.add(player);
|
||||||
entities.add(new NormalEnemy(0, 0));
|
for (int i = 0; i < 100; i++)
|
||||||
entities.add(new NormalEnemy(0, 0));
|
|
||||||
entities.add(new NormalEnemy(0, 0));
|
entities.add(new NormalEnemy(0, 0));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
background = (Image) new BufferedImage(1024, 600, BufferedImage.TRANSLUCENT);
|
background = (Image) new BufferedImage(1024, 600, BufferedImage.TRANSLUCENT);
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,6 @@ public abstract class Enemy extends Entity {
|
||||||
public abstract boolean getAlive();
|
public abstract boolean getAlive();
|
||||||
public abstract Color getColor();
|
public abstract Color getColor();
|
||||||
|
|
||||||
public int getWorth() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void damage(int damage);
|
public abstract void damage(int damage);
|
||||||
|
|
||||||
public abstract boolean isCollidable();
|
public abstract boolean isCollidable();
|
||||||
|
|
|
||||||
|
|
@ -171,11 +171,6 @@ public class BlueEnemy extends Enemy {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWorth(){
|
|
||||||
return r.nextInt(3)+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,11 +178,6 @@ public class GreenEnemy extends Enemy {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWorth() {
|
|
||||||
return r.nextInt(3) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,11 +172,6 @@ public class NormalEnemy extends Enemy {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWorth() {
|
|
||||||
return r.nextInt(3) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,11 +168,6 @@ public class RedEnemy extends Enemy {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWorth(){
|
|
||||||
return (int)(Math.random() * 3)+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue