Skip to content

Commit

Permalink
Last changes to main:p
Browse files Browse the repository at this point in the history
lastChanges
  • Loading branch information
delfi-fenoy authored Nov 15, 2024
2 parents 81a679c + 9e8415a commit 16598cb
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/entities/Alien1.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public Alien1(float x, float y) {
// ====================> GET | SET <====================

// ====================> METODOS <====================
@Override
public void draw(Graphics g){
g.drawImage(
animations[state][getAniIndex()],
Expand Down
1 change: 1 addition & 0 deletions src/entities/Alien2.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public Alien2(float x, float y) {
// ====================> GET | SET <====================

// ====================> METODOS <====================
@Override
public void draw(Graphics g){
g.drawImage(
animations[state][getAniIndex()],
Expand Down
1 change: 1 addition & 0 deletions src/entities/Alien3.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Alien3(float x, float y) {
// ====================> GET | SET <====================

// ====================> METODOS <====================
@Override
public void draw(Graphics g){
g.drawImage(
animations[state][getAniIndex()],
Expand Down
1 change: 1 addition & 0 deletions src/entities/Alien4.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public Alien4(float x, float y) {
// ====================> GET | SET <====================

// ====================> METODOS <====================
@Override
public void draw(Graphics g){
g.drawImage(
animations[state][getAniIndex()],
Expand Down
8 changes: 6 additions & 2 deletions src/entities/BulletManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
public class BulletManager implements IRenderable {
// ====================> ATRIBUTOS <====================
private Playing playing;
public ArrayList<Bullet> bulletPlayerArr = new ArrayList<>(); // Arraylist con las balas
public ArrayList<Bullet> bulletAlienArr = new ArrayList<>(); // Arraylist con las balas
public ArrayList<Bullet> bulletPlayerArr; // Arraylist con las balas
public ArrayList<Bullet> bulletAlienArr; // Arraylist con las balas
private float bulletSpeed = 5.0f; // Velocidad de la bala
private boolean updatingBullets = false;

// ====================> CONSTRUCTOR <====================
public BulletManager(Playing playing) {
this.playing = playing;
bulletPlayerArr = new ArrayList<>();
bulletAlienArr = new ArrayList<>();
}

// ====================> GET | SET <====================
Expand Down Expand Up @@ -96,12 +98,14 @@ public <T extends Enemy> void createBulletAlien(T alien) {
}

/** Interface IRenderable */
@Override
public void update(){
if (!updatingBullets) {
move();
}
}

@Override
public void draw(Graphics g){
// Balas Jugadador
g.setColor(Color.yellow);
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Enemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected void updateAnimationTick() {
}
}

@Override
public void update(){
updateAnimationTick();
}

}
9 changes: 6 additions & 3 deletions src/entities/EnemyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import gameState.Playing;
import main.Game;
import utilz.IRenderable;
import utilz.LevelConfig;

import static main.Game.GAME_WIDTH;
Expand All @@ -13,10 +14,10 @@
import static utilz.Constants.PlayerConstants.EXPLODE;
import static utilz.HelpMethods.DetectCollision;

public class EnemyManager <T extends Enemy> {
public class EnemyManager <T extends Enemy> implements IRenderable {
// ====================> ATRIBUTOS <====================
private Playing playing; // Traemos el State Playing
private ArrayList<T> enemies = new ArrayList<>(); // ArrayList con los aliens
private ArrayList<T> enemies; // ArrayList con los aliens
private int alienColumns = 5; // Cantidad de Columnas de aliens
private int aniTick; // Contador para el disparo de enemigo
private float alienVelocityX = 1f; // Velocidad de los aliens
Expand All @@ -25,6 +26,7 @@ public class EnemyManager <T extends Enemy> {
// ====================> CONSTRUCTOR <====================
public EnemyManager(Playing playing) {
this.playing = playing;
enemies = new ArrayList<>();
}

// ====================> GET | SET <====================
Expand Down Expand Up @@ -169,6 +171,7 @@ private T spawnAlien(String alienType, int x, int y) {
}

/// Interface IRenderable
@Override
public void update(){
// Remover enemigos inactivos antes de actualizar
enemies.removeIf(enemy -> !enemy.active); // Elimina enemigos inactivos
Expand All @@ -188,6 +191,7 @@ public void update(){
}
}

@Override
public void draw(Graphics g){
// Crear una copia inmutable de la lista de enemigos activos
List<T> enemiesSnapshot = List.copyOf(enemies);
Expand All @@ -198,5 +202,4 @@ public void draw(Graphics g){
}
}
}

}
4 changes: 2 additions & 2 deletions src/entities/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public Rectangle2D.Float getHitbox() {

// ====================> METODOS <====================
/** drawHitbox() ==> Metodo Auxiliar para visualizar la hitbox */
protected void drawHitbox(Graphics g) {
/*protected void drawHitbox(Graphics g) {
// Unicamente sirve para ver la Hitbox
g.setColor(Color.RED);
g.drawRect((int) hitbox.x, (int) hitbox.y, (int) hitbox.width, (int) hitbox.height);
}
}*/

/** initHitbox() ==> Instancia la hitbox. */
public void initHitbox(float x, float y, int width, int height) {
Expand Down
2 changes: 2 additions & 0 deletions src/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ public void resetDirBooleans() {
}

/// Interface IRenderable
@Override
public void update(){
move();
updateAnimationTick();
}

@Override
public void draw(Graphics g){
// drawHitbox(g);
if(active){
Expand Down
5 changes: 4 additions & 1 deletion src/ui/ClassButton.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package ui;

import utilz.IRenderable;
import utilz.LoadSave;

import java.awt.*;
import java.awt.image.BufferedImage;

import static utilz.Constants.UI.PauseButtons.*;

public class ClassButton {
public class ClassButton implements IRenderable {
// ====================> ATRIBUTOS <====================
private int xPos, yPos, rowIndex, index;
private int xOffsetCenter = PB_SIZE / 2;
Expand Down Expand Up @@ -62,11 +63,13 @@ public void loadImgs() {
}

// Dibujamos el Boton
@Override
public void draw(Graphics g) {
g.drawImage(imgs[index], xPos - xOffsetCenter, yPos, PB_SIZE, PB_SIZE, null);
}

// Index, controla cuál de las imágenes del botón se muestra, según el estado del mouse.
@Override
public void update() {
index = 0; // Inactivo
if (mouseOver)
Expand Down
5 changes: 4 additions & 1 deletion src/ui/MenuButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import gameState.GameState;
import utilz.IRenderable;
import utilz.LoadSave;
import static utilz.Constants.UI.Buttons.*;

Expand All @@ -11,7 +12,7 @@
*
* Creamos los botones pricipales del menu, Jugar, Opciones y Salir
*/
public class MenuButton {
public class MenuButton implements IRenderable {
// ====================> ATRIBUTOS <====================
private int xPos, yPos, rowIndex, index; // rowIndex: Define la fila en la que se encuentran las imágenes del botón
private int xOffsetCenter = B_WIDTH / 2; // El centro a lo ancho
Expand Down Expand Up @@ -65,11 +66,13 @@ private void loadImgs() {
}

// Dibujamos el Boton
@Override
public void draw(Graphics g) {
g.drawImage(imgs[index], xPos - xOffsetCenter, yPos, B_WIDTH, B_HEIGHT, null);
}

// Index, controla cuál de las imágenes del botón se muestra, según el estado del mouse.
@Override
public void update() {
index = 0; // Inactivo
if (mouseOver)
Expand Down
11 changes: 6 additions & 5 deletions src/ui/PauseOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import gameState.GameState;
import gameState.Playing;
import main.Game;
import utilz.IRenderable;
import utilz.LoadSave;

public class PauseOverlay {
public class PauseOverlay implements IRenderable {
// ====================> ATRIBUTOS <====================
private Playing playing;
private BufferedImage backgroundImg;
private int bgX, bgY, bgW, bgH;
private int bgX, bgY, bgW, bgH; // Posicion y tamaño de backroundImg
private ClassButton[] buttons = new ClassButton[2];

private ResumeButton resumeB;
Expand Down Expand Up @@ -60,14 +61,16 @@ private boolean isIn(MouseEvent e, ResumeButton b) {
return b.getHitbox().contains(e.getX(), e.getY());
}

// ====================> METODOS COMUNES <====================
// ====================> METODOS SOBRESCRITOS <====================
@Override
public void update() {
resumeB.update();
for(ClassButton cb : buttons) {
cb.update();
}
}

@Override
public void draw(Graphics g) {
// Fondo
g.drawImage(backgroundImg, bgX, bgY, bgW, bgH, null);
Expand Down Expand Up @@ -123,6 +126,4 @@ public void mouseMoved(MouseEvent e) {
break; // Rompe el ciclo para que solo un botón esté en estado `mouseOver`
}
}


}
5 changes: 4 additions & 1 deletion src/ui/ResumeButton.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ui;


import utilz.IRenderable;
import utilz.LoadSave;

import java.awt.*;
Expand All @@ -10,7 +11,7 @@
import static utilz.Constants.UI.PauseButtons.PB_DEFAULT_SIZE;
import static utilz.Constants.UI.PauseButtons.PB_SIZE;

public class ResumeButton{
public class ResumeButton implements IRenderable {
// ====================> ATRIBUTOS <====================
private int xPos, yPos, index;
private int xOffsetCenter = B_WIDTH / 2;
Expand Down Expand Up @@ -69,11 +70,13 @@ public void loadImgs() {
}

// Dibujamos el Boton
@Override
public void draw(Graphics g) {
g.drawImage(imgs[0][index], xPos - xOffsetCenter, yPos, B_WIDTH, B_HEIGHT, null);
}

// Index, controla cuál de las imágenes del botón se muestra, según el estado del mouse.
@Override
public void update() {
index = 0; // Inactivo
if (mouseOver)
Expand Down

0 comments on commit 16598cb

Please sign in to comment.