Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added shooting star destroyers
- Loading branch information
Showing
12 changed files
with
222 additions
and
21 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package entity; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Rectangle; | ||
//used for Star Destroyer | ||
public interface EntityTypeC { | ||
|
||
public void tick(); | ||
public void render(Graphics g); | ||
public Rectangle getBounds(); | ||
public double getX(); | ||
public double getY(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package entity; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Rectangle; | ||
|
||
public interface EntityTypeD { | ||
|
||
public void tick(); | ||
public void render(Graphics g); | ||
public Rectangle getBounds(); | ||
public double getX(); | ||
public double getY(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Rectangle; | ||
|
||
import entity.EntityTypeD; | ||
|
||
public class EnemyLaser extends GameObject implements EntityTypeD{ | ||
|
||
private Skins skin; | ||
public EnemyLaser(double x, double y, Skins skin, Game game){ | ||
super(x,y); | ||
this.skin = skin; | ||
|
||
} | ||
|
||
public void tick(){ | ||
x-=4; | ||
} | ||
public void render(Graphics g){ | ||
g.drawImage(skin.enemyLaser, (int)x, (int)y, null); | ||
} | ||
public double getX(){ | ||
return x; | ||
} | ||
|
||
public double getY() { | ||
return y; | ||
} | ||
public Rectangle getBounds(){ | ||
return new Rectangle((int)x, (int) y, 64, 64); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main; | ||
|
||
import java.awt.Graphics; | ||
import java.awt.Rectangle; | ||
import java.util.Random; | ||
|
||
import entity.EntityTypeA; | ||
import entity.EntityTypeC; | ||
|
||
public class StarDestroyer extends GameObject implements EntityTypeC{ | ||
|
||
private Skins skin; | ||
private Game game; | ||
private Controller controller; | ||
private double speed = 0.3; | ||
private int health = 10; | ||
private int is_shooting = 0; | ||
Random r = new Random(); | ||
|
||
public StarDestroyer(double x, double y, Skins skin, Controller c, Game game){ | ||
super(x,y); | ||
this.game = game; | ||
this.controller = c; | ||
this.skin = skin; | ||
} | ||
public double getX(){ | ||
return x; | ||
} | ||
|
||
public void tick(){ | ||
x -= speed; | ||
shoot(); | ||
for(int n = 0; n < game.ea.size(); n++){ | ||
EntityTypeA tempa = game.ea.get(n); | ||
|
||
if(GamePhysics.Collision(this, tempa)){ | ||
if(health ==1) | ||
{controller.removeEntity(this); | ||
game.setKills(game.getKills()+1);} | ||
else{health--;} | ||
controller.removeEntity(tempa); | ||
} | ||
} | ||
|
||
} | ||
public void shoot(){ | ||
if(is_shooting == 0){ | ||
controller.addEntity(new EnemyLaser(x, y, skin, game)); | ||
is_shooting++; | ||
} | ||
else if(is_shooting == r.nextDouble()* 60 + 60){ | ||
is_shooting = 0; | ||
} | ||
else{ | ||
is_shooting++; | ||
} | ||
} | ||
public void render(Graphics g){ | ||
g.drawImage(skin.starDestroyer, (int)x, (int)y, null); | ||
} | ||
public double getY() { | ||
return y; | ||
} | ||
public Rectangle getBounds(){ | ||
return new Rectangle((int)x, (int) y, 64, 64); | ||
} | ||
} |