Skip to content

Commit

Permalink
addAlien4
Browse files Browse the repository at this point in the history
  • Loading branch information
delfi-fenoy committed Nov 11, 2024
1 parent ceef5f9 commit 10684e1
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
Binary file added res/alien4_sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions src/entities/Alien4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package entities;

import main.Game;
import utilz.LoadSave;

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

import static utilz.Constants.EnemyConstants.*;

public class Alien4 extends Enemy {

// ====================> ATRIBUTOS <====================

// ====================> CONTRUCTOR <====================
public Alien4(float x, float y) {
super(x, y, Alien_WIDTH, Alien_HEIGHT, Alien4);
initHitbox(x, y, (int) (20 * Game.SCALE), (int) (20 * Game.SCALE));
loadImgs();
}

// ====================> GET | SET <====================

// ====================> METODOS <====================
public void draw(Graphics g){
g.drawImage(
animations[state][getAniIndex()],
(int)(x - xDrawOffset),
(int)(y - yDrawOffset),
Alien_WIDTH,
Alien_HEIGHT,
null);
}

/** loadImgs() ==> Separa el SpriteSheat y los ubica en una matriz. */
private void loadImgs() {
animations = new BufferedImage[2][5];
BufferedImage temp = LoadSave.GetSpritesAtlas(LoadSave.Alien4_ATLAS);
for (int j = 0; j < animations.length; j++)
for (int i = 0; i < animations[j].length; i++)
animations[j][i] = temp.getSubimage(i * Alien_WIDHT_DEFAULT, j * Alien_HEIGHT_DEFAULT, Alien_WIDHT_DEFAULT, Alien_HEIGHT_DEFAULT);
}
}
4 changes: 2 additions & 2 deletions src/entities/EnemyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void loadConfigLevel(Map<String, LevelConfig> levelManager){
Map<String, Integer> aliensHard = new HashMap<>();
aliensHard.put("alien2", 5);
aliensHard.put("alien3", 10);
// aliensHard.put("alien4", 5);
aliensHard.put("alien4", 5);
levelManager.put("hard", new LevelConfig(aliensHard));
}

Expand Down Expand Up @@ -120,7 +120,7 @@ private T spawnAlien(String alienType, int x, int y) {
case "alien1" -> (T) new Alien1(x, y);
case "alien2" -> (T) new Alien2(x, y);
case "alien3" -> (T) new Alien3(x, y);
//case "alien4" -> (T) new Alien4(x, y);
case "alien4" -> (T) new Alien4(x, y);
default -> null;
};
return alien;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void update(){
}

public void draw(Graphics g){
drawHitbox(g); // COMENTAR DESPUES !!!!!!!!!!!!!!!
// drawHitbox(g); // COMENTAR DESPUES !!!!!!!!!!!!!!!
g.drawImage(animations[state][aniIndex],
(int) (x - xDrawOffset),
(int) (y - yDrawOffset),
Expand Down
7 changes: 7 additions & 0 deletions src/utilz/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public static int GetSpriteAmount(int enemy_type, int enemy_state){
case DEAD:
return 1;
}
case Alien4:
switch (enemy_state){
case MOVING:
return 5;
case DEAD:
return 1;
}
}
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/utilz/LoadSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class LoadSave {
public static final String Alien1_ATLAS = "alien1_sprites.png";
public static final String Alien2_ATLAS = "alien2_sprites.png";
public static final String Alien3_ATLAS = "alien3_sprites.png";
public static final String Alien4_ATLAS = "alien4_sprites.png";
public static final String MENU_BUTTONS = "button_atlas.png";

// Funcion que retorna esas imagenes
Expand Down

0 comments on commit 10684e1

Please sign in to comment.