From bac8633be7a3c15e92f86def1158c1168a19a48a Mon Sep 17 00:00:00 2001 From: Marcus Gosselin Date: Tue, 3 Mar 2015 14:44:52 -0500 Subject: [PATCH] i made a booboo --- .classpath | 2 +- .gitignore | 1 + src/MAndApps/apps/spacewars/SpaceWars.java | 3 ++- src/MAndApps/apps/spacewars/entity/Player.java | 2 +- .../apps/spacewars/entity/bullet/BasicPlayerBullet.java | 8 ++++++-- .../apps/spacewars/entity/bullet/PlayerExplodeBullet.java | 8 ++++++-- .../apps/spacewars/entity/bullet/PlayerImpactBullet.java | 8 ++++++-- .../spacewars/entity/bullet/PlayerPiercingBullet.java | 7 +++++-- src/MAndApps/apps/spacewars/entity/enemy/BlueEnemy.java | 2 +- src/MAndApps/apps/spacewars/entity/enemy/GreenEnemy.java | 2 +- src/MAndApps/apps/spacewars/entity/enemy/NormalEnemy.java | 2 +- src/MAndApps/apps/spacewars/entity/enemy/RedEnemy.java | 8 +++++--- src/MAndApps/apps/spacewars/shop/Shop.java | 4 ++-- src/MAndApps/apps/spacewars/tools/CollisionParticle.java | 6 ++++-- src/MAndApps/apps/spacewars/tools/Particle.java | 8 +++++--- 15 files changed, 47 insertions(+), 24 deletions(-) diff --git a/.classpath b/.classpath index f5785bc..b31d595 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,7 @@ - + diff --git a/.gitignore b/.gitignore index 9869677..033c73a 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ Icon Network Trash Folder Temporary Items .apdisk +/bin/ diff --git a/src/MAndApps/apps/spacewars/SpaceWars.java b/src/MAndApps/apps/spacewars/SpaceWars.java index 6c41ab9..8b537d4 100644 --- a/src/MAndApps/apps/spacewars/SpaceWars.java +++ b/src/MAndApps/apps/spacewars/SpaceWars.java @@ -8,6 +8,7 @@ import java.awt.Graphics2D; import java.awt.Image; import java.awt.Rectangle; import java.awt.RenderingHints; +import java.awt.Transparency; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.net.URL; @@ -189,7 +190,7 @@ public class SpaceWars implements BasicApp { try { background = ImageIO.read(new URL("http://wallpapersus.com/wallpapers/2012/10/Cool-Wave-600x1024.jpg")); } catch (Exception e) { - background = (Image) new BufferedImage(1024, 600, BufferedImage.TRANSLUCENT); + background = new BufferedImage(1024, 600, Transparency.TRANSLUCENT); Graphics g = background.getGraphics(); g.setColor(Color.BLUE); g.fillRect(0, 0, 1024, 600); diff --git a/src/MAndApps/apps/spacewars/entity/Player.java b/src/MAndApps/apps/spacewars/entity/Player.java index 18604b3..e48f981 100644 --- a/src/MAndApps/apps/spacewars/entity/Player.java +++ b/src/MAndApps/apps/spacewars/entity/Player.java @@ -21,7 +21,7 @@ public class Player extends Entity { private boolean goBoom = false; public Player() { - super((int) 512, (int) 550, WIDTH, HEIGHT); + super(512, 550, WIDTH, HEIGHT); } @Override diff --git a/src/MAndApps/apps/spacewars/entity/bullet/BasicPlayerBullet.java b/src/MAndApps/apps/spacewars/entity/bullet/BasicPlayerBullet.java index 120a85d..6adf5b5 100644 --- a/src/MAndApps/apps/spacewars/entity/bullet/BasicPlayerBullet.java +++ b/src/MAndApps/apps/spacewars/entity/bullet/BasicPlayerBullet.java @@ -30,6 +30,7 @@ public class BasicPlayerBullet extends Bullet { updateBoundingBox((int) this.x, (int) this.y, WIDTH, HEIGHT); } + @Override public int tick() { if (alive) { if (direction == Direction.UP) { @@ -58,6 +59,7 @@ public class BasicPlayerBullet extends Bullet { return 0; } + @Override public void render(Graphics g) { g.setColor(Color.BLACK); if (alive) @@ -74,11 +76,13 @@ public class BasicPlayerBullet extends Bullet { return 1; } - public int getWIDTH(){ + @Override + public int getWIDTH(){ return WIDTH; } - public int getHEIGHT(){ + @Override + public int getHEIGHT(){ return HEIGHT; } diff --git a/src/MAndApps/apps/spacewars/entity/bullet/PlayerExplodeBullet.java b/src/MAndApps/apps/spacewars/entity/bullet/PlayerExplodeBullet.java index f890f2e..20c79c8 100644 --- a/src/MAndApps/apps/spacewars/entity/bullet/PlayerExplodeBullet.java +++ b/src/MAndApps/apps/spacewars/entity/bullet/PlayerExplodeBullet.java @@ -19,11 +19,13 @@ public class PlayerExplodeBullet extends Bullet { private final int size; private static final double PHI = 1.618033988749894848204586; - public int getWIDTH(){ + @Override + public int getWIDTH(){ return WIDTH; } - public int getHEIGHT(){ + @Override + public int getHEIGHT(){ return HEIGHT; } @@ -45,6 +47,7 @@ public class PlayerExplodeBullet extends Bullet { } + @Override public int tick() { if (alive) { if (direction == Direction.UP) { @@ -75,6 +78,7 @@ public class PlayerExplodeBullet extends Bullet { return 0; } + @Override public void render(Graphics g) { g.setColor(Color.BLACK); if (alive) diff --git a/src/MAndApps/apps/spacewars/entity/bullet/PlayerImpactBullet.java b/src/MAndApps/apps/spacewars/entity/bullet/PlayerImpactBullet.java index 92db12d..00ddaa4 100644 --- a/src/MAndApps/apps/spacewars/entity/bullet/PlayerImpactBullet.java +++ b/src/MAndApps/apps/spacewars/entity/bullet/PlayerImpactBullet.java @@ -16,11 +16,13 @@ public class PlayerImpactBullet extends Bullet { private boolean alive = true; private final int level; - public int getWIDTH(){ + @Override + public int getWIDTH(){ return WIDTH; } - public int getHEIGHT(){ + @Override + public int getHEIGHT(){ return HEIGHT; } @@ -40,6 +42,7 @@ public class PlayerImpactBullet extends Bullet { this.level = level; } + @Override public int tick() { if (alive) { if (direction == Direction.UP) { @@ -68,6 +71,7 @@ public class PlayerImpactBullet extends Bullet { return 0; } + @Override public void render(Graphics g) { g.setColor(Color.BLACK); if (alive) diff --git a/src/MAndApps/apps/spacewars/entity/bullet/PlayerPiercingBullet.java b/src/MAndApps/apps/spacewars/entity/bullet/PlayerPiercingBullet.java index c7f593f..275b754 100644 --- a/src/MAndApps/apps/spacewars/entity/bullet/PlayerPiercingBullet.java +++ b/src/MAndApps/apps/spacewars/entity/bullet/PlayerPiercingBullet.java @@ -17,11 +17,13 @@ public class PlayerPiercingBullet extends Bullet { private final boolean INFINISHOT; final boolean lolface = true; - public int getWIDTH(){ + @Override + public int getWIDTH(){ return WIDTH; } - public int getHEIGHT(){ + @Override + public int getHEIGHT(){ return HEIGHT; } @@ -42,6 +44,7 @@ public class PlayerPiercingBullet extends Bullet { INFINISHOT = b; } + @Override public int tick() { oldX = x; oldY = y; diff --git a/src/MAndApps/apps/spacewars/entity/enemy/BlueEnemy.java b/src/MAndApps/apps/spacewars/entity/enemy/BlueEnemy.java index 62400f3..c7d73f5 100644 --- a/src/MAndApps/apps/spacewars/entity/enemy/BlueEnemy.java +++ b/src/MAndApps/apps/spacewars/entity/enemy/BlueEnemy.java @@ -137,7 +137,7 @@ public class BlueEnemy extends Enemy { g.setColor(color); int temp; try{ - temp = r.nextInt((int)(0-((double)absoluteTime/20d))+5); + temp = r.nextInt((int)(0-(absoluteTime/20d))+5); }catch(Exception e){ temp = 0; } diff --git a/src/MAndApps/apps/spacewars/entity/enemy/GreenEnemy.java b/src/MAndApps/apps/spacewars/entity/enemy/GreenEnemy.java index 62f8bfe..b4db502 100644 --- a/src/MAndApps/apps/spacewars/entity/enemy/GreenEnemy.java +++ b/src/MAndApps/apps/spacewars/entity/enemy/GreenEnemy.java @@ -142,7 +142,7 @@ public class GreenEnemy extends Enemy { g.setColor(color); int temp; try{ - temp = r.nextInt((int)(0-((double)absoluteTime/20d))+5); + temp = r.nextInt((int)(0-(absoluteTime/20d))+5); }catch(Exception e){ temp = 0; } diff --git a/src/MAndApps/apps/spacewars/entity/enemy/NormalEnemy.java b/src/MAndApps/apps/spacewars/entity/enemy/NormalEnemy.java index fa1df78..d41a8f9 100644 --- a/src/MAndApps/apps/spacewars/entity/enemy/NormalEnemy.java +++ b/src/MAndApps/apps/spacewars/entity/enemy/NormalEnemy.java @@ -137,7 +137,7 @@ public class NormalEnemy extends Enemy { g.setColor(color); int temp; try{ - temp = r.nextInt((int)(0-((double)absoluteTime/20d))+5); + temp = r.nextInt((int)(0-(absoluteTime/20d))+5); }catch(Exception e){ temp = 0; } diff --git a/src/MAndApps/apps/spacewars/entity/enemy/RedEnemy.java b/src/MAndApps/apps/spacewars/entity/enemy/RedEnemy.java index 7b9a412..abf2e5b 100644 --- a/src/MAndApps/apps/spacewars/entity/enemy/RedEnemy.java +++ b/src/MAndApps/apps/spacewars/entity/enemy/RedEnemy.java @@ -27,7 +27,8 @@ public class RedEnemy extends Enemy { } - public int tick() { + @Override + public int tick() { // epic AI if((int)healthBar <= 0){ alive = false; @@ -130,11 +131,12 @@ public class RedEnemy extends Enemy { private Random r = new Random(); private int absoluteTime = 0; - public void render(Graphics g) { + @Override + public void render(Graphics g) { g.setColor(color); int temp; try{ - temp = r.nextInt((int)(0-((double)absoluteTime/20d))+5); + temp = r.nextInt((int)(0-(absoluteTime/20d))+5); }catch(Exception e){ temp = 0; } diff --git a/src/MAndApps/apps/spacewars/shop/Shop.java b/src/MAndApps/apps/spacewars/shop/Shop.java index d318857..bf2019d 100644 --- a/src/MAndApps/apps/spacewars/shop/Shop.java +++ b/src/MAndApps/apps/spacewars/shop/Shop.java @@ -22,9 +22,9 @@ public class Shop { public void tick(){ if(state == ON && !(animationTime > BOX_WIDTH)){ - animationTime+=(double)(MAX_ANIMATION_TIME-animationTime)/6; + animationTime+=(MAX_ANIMATION_TIME-animationTime)/6; }else if(state == OFF && !(animationTime < 0)){ - animationTime+=(double)(0-animationTime)/6; + animationTime+=(0-animationTime)/6; } if(animationTime < 0.49d){ selection = 0; diff --git a/src/MAndApps/apps/spacewars/tools/CollisionParticle.java b/src/MAndApps/apps/spacewars/tools/CollisionParticle.java index 4ee169c..50c6f75 100644 --- a/src/MAndApps/apps/spacewars/tools/CollisionParticle.java +++ b/src/MAndApps/apps/spacewars/tools/CollisionParticle.java @@ -70,10 +70,11 @@ public class CollisionParticle extends Entity { this.damage = damage; } + @Override public int tick() { if (life < moveLife) { - x += Math.cos(((double) angleDeg * Math.PI) / 180d) * speed; - y += Math.sin(((double) angleDeg * Math.PI) / 180d) * speed; + x += Math.cos((angleDeg * Math.PI) / 180d) * speed; + y += Math.sin((angleDeg * Math.PI) / 180d) * speed; } speed /= DECAY; if (life > renderLife) @@ -100,6 +101,7 @@ public class CollisionParticle extends Entity { return 0; } + @Override public void render(Graphics g) { if (alive) { g.setColor(color); diff --git a/src/MAndApps/apps/spacewars/tools/Particle.java b/src/MAndApps/apps/spacewars/tools/Particle.java index 65cc29f..b5ffaf2 100644 --- a/src/MAndApps/apps/spacewars/tools/Particle.java +++ b/src/MAndApps/apps/spacewars/tools/Particle.java @@ -63,16 +63,17 @@ public class Particle extends Entity{ } else { color = new Color(rand(0, 256), rand(0, 256), rand(0, 256)); } - updateBoundingBox((int)x, (int)y, size , size); + updateBoundingBox(x, y, size , size); } private static final double PHI = 1.618033988749894848204586; + @Override public int tick() { if (life < moveLife) { - x += Math.cos(((double) angleDeg * Math.PI) / 180d) * speed; - y += Math.sin(((double) angleDeg * Math.PI) / 180d) * speed; + x += Math.cos((angleDeg * Math.PI) / 180d) * speed; + y += Math.sin((angleDeg * Math.PI) / 180d) * speed; } speed /= PHI; if (life > renderLife) @@ -87,6 +88,7 @@ public class Particle extends Entity{ return 0; } + @Override public void render(Graphics g) { if (alive) { g.setColor(color);