Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ff6003
commit 9cf6d1e
Showing
23 changed files
with
471 additions
and
494 deletions.
There are no files selected for viewing
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,59 @@ | ||
package com.ks2002br.entities; | ||
|
||
/* | ||
* By Elisandro 12/2021 revisao geral | ||
*/ | ||
import java.awt.*; | ||
import java.util.LinkedList; | ||
|
||
import com.ks2002br.frameworks.*; | ||
|
||
public class Bullet extends GameObject { | ||
|
||
private GameController gc; | ||
|
||
public Bullet(float x, float y, int velX, long timer, GameController gc, ObjectId id) { | ||
super(x, y, id); | ||
this.spdX = velX; | ||
this.timer = timer; | ||
this.gc = gc; | ||
} | ||
|
||
@Override | ||
public void tick(LinkedList<GameObject> obj) { | ||
x += spdX; | ||
isCollision(); | ||
} | ||
|
||
private void isCollision() { | ||
|
||
for (int i = 0; i < gc.obj.size(); i++) { | ||
GameObject objTemp = gc.obj.get(i); | ||
|
||
if (objTemp.getId() == ObjectId.BLOCO) { | ||
if (getBounds().intersects(objTemp.getBounds())) { | ||
gc.removeObj(this); | ||
} | ||
} | ||
|
||
if (objTemp.getId() == ObjectId.ENEMY) { | ||
if (getBounds().intersects(objTemp.getBounds())) { | ||
gc.removeObj(gc.obj.get(i)); | ||
gc.removeObj(this); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void render(Graphics g) { | ||
g.setColor(new Color(255, 0, 0)); | ||
g.fillOval((int) x, (int) y, 16, 16); | ||
} | ||
|
||
@Override | ||
public Rectangle getBounds() { | ||
return new Rectangle((int) x, (int) y, 16, 16); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,74 +1,61 @@ | ||
package com.ks2002br.entities; | ||
|
||
/* | ||
* By Elisandro | ||
* By Elisandro 12/2021 revisao geral | ||
*/ | ||
import java.awt.*; | ||
import java.util.LinkedList; | ||
|
||
import com.ks2002br.frameworks.Animation; | ||
import com.ks2002br.frameworks.GameObject; | ||
import com.ks2002br.frameworks.ObjectId; | ||
import com.ks2002br.frameworks.*; | ||
import com.ks2002br.game.Game; | ||
import com.ks2002br.graficos.Texturas; | ||
|
||
public class Enemy extends GameObject { | ||
|
||
private int tipo; | ||
private Texturas tex = Game.getInstance(); | ||
|
||
private Animation animIdle; | ||
|
||
private int posInit = 0; | ||
private int dir = 1; | ||
private int pixelsTemp = 64; | ||
private int pixelsTemp = 64; | ||
|
||
public Enemy(float x, float y, int t, ObjectId id) { | ||
private Texturas tex = Game.getInstance(); | ||
private Animation animIdle; | ||
|
||
public Enemy(float x, float y, ObjectId id) { | ||
super(x, y, id); | ||
this.tipo = t; | ||
|
||
posInit = (int) x; | ||
|
||
animIdle = new Animation(10,tex.bat_idle); | ||
|
||
animIdle = new Animation(10, tex.bat_idle); | ||
} | ||
|
||
public void tick(LinkedList<GameObject> obj) { | ||
x += spdX; | ||
y += spdY; | ||
|
||
animIdle.runAnimation(); | ||
|
||
iaBurra(); | ||
|
||
|
||
iaEnemy(); | ||
} | ||
|
||
private void iaBurra() { | ||
|
||
if(dir == 1) { | ||
if(x <= posInit + pixelsTemp) spdX = 1; // 50 <= 50+64=114 | ||
private void iaEnemy() { | ||
if (dir == 1) { | ||
if (x <= posInit + pixelsTemp) spdX = 1; | ||
else dir = -1; | ||
}else { | ||
if(x >= posInit) spdX = -1; | ||
} else { | ||
if (x >= posInit) spdX = -1; | ||
else dir = 1; | ||
} | ||
|
||
} | ||
|
||
public void render(Graphics g) { | ||
g.setColor(Color.red); | ||
// g.fillRect((int) x, (int) y, 64, 64); | ||
g.drawString("X = "+x+ " dir = "+dir, (int) x,(int) y); | ||
//if(tipo== 0) g.drawImage(tex.enemy[0],(int) x,(int) y,null); | ||
//if(tipo== 1) g.drawImage(tex.enemy[1],(int) x,(int) y, null); | ||
|
||
//Animacao idle teste | ||
animIdle.renderAnimation(g,(int) x, (int) y); | ||
animIdle.renderAnimation(g, (int) x, (int) y); | ||
|
||
//g.setColor(Color.red); | ||
// g.fillRect((int) x, (int) y, 64, 64); | ||
//g.drawString("X = " + x + " dir = " + dir, (int) x, (int) y); | ||
// if(tipo== 0) g.drawImage(tex.enemy[0],(int) x,(int) y,null); | ||
// if(tipo== 1) g.drawImage(tex.enemy[1],(int) x,(int) y, null); | ||
|
||
} | ||
|
||
@Override | ||
public Rectangle getBounds() { | ||
return new Rectangle((int) x, (int) y, 32, 64); | ||
return new Rectangle((int) x, (int) y, 32, 32); | ||
} | ||
|
||
} |
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
Oops, something went wrong.