Skip to content

Commit

Permalink
feat: Enemigo torreta terminado
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielCarrenoMar committed Feb 2, 2025
1 parent 75ff718 commit e9fbff6
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 33 deletions.
13 changes: 6 additions & 7 deletions assets/tiled/maps/gameMap.tmx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.1" orientation="orthogonal" renderorder="left-down" width="240" height="160" tilewidth="16" tileheight="16" infinite="0" nextlayerid="19" nextobjectid="1233">
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="left-down" width="240" height="160" tilewidth="16" tileheight="16" infinite="0" nextlayerid="19" nextobjectid="1234">
<tileset firstgid="1" source="Bosque.tsx"/>
<tileset firstgid="626" source="temple.tsx"/>
<tileset firstgid="818" source="crypt.tsx"/>
Expand Down Expand Up @@ -472,7 +472,7 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2906,0,0,0,0,0,0,0,0,3221228322,2930,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2684355499,86,2147483780,0,0,0,536871851,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,952,913,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2251,2268,2255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2318,2225,2241,0,0,0,0,0,0,0,0,0,2261,2261,2261,2261,536871825,0,0,0,0,0,536871825,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2906,0,0,0,0,0,0,0,0,0,2147486554,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2684355499,0,0,0,0,0,536871851,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,952,913,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2251,3221227738,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3221227825,2310,2310,2310,2353,0,0,0,0,0,0,0,0,0,0,3221227825,2310,2310,2310,2353,0,0,0,0,0,2318,2225,2332,0,2684356862,0,0,0,0,0,0,0,0,0,536871825,536871825,536871825,536871825,0,0,0,0,0,0,0,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2906,0,0,0,0,0,0,0,0,0,2147486554,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2684355499,0,0,0,0,0,536871851,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,952,913,86,86,86,0,0,0,0,0,0,0,86,86,86,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2280,2281,2282,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2684356913,2684356913,2684356913,0,0,0,0,0,0,0,0,0,0,0,0,2684356913,2684356913,2684356913,0,0,0,0,2318,2225,2332,0,0,0,2240,2225,2225,2241,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2933,0,0,0,0,0,0,0,0,0,2147486554,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147486550,0,0,0,132,86,2902,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2958,2958,2958,2958,952,913,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2224,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,3221227754,0,0,0,0,0,0,0,1073744106,2225,2225,2225,2225,2225,2225,3221227754,0,0,0,0,0,0,0,1073744106,2225,2332,0,0,0,0,0,0,0,0,2684356862,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2933,0,0,0,0,0,0,0,0,0,2147486554,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147486550,0,0,0,132,86,2902,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2958,2958,2958,2958,952,913,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2224,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,2225,3221227754,0,0,0,0,0,0,0,1073744106,2225,2225,2225,2225,2225,2225,3221227754,0,0,0,0,0,0,0,1073744106,2225,2332,0,0,0,0,0,0,0,0,2684356862,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2926,2926,2926,2926,2926,2926,0,0,0,0,2147486554,0,3221228322,3221228322,3221228322,2930,0,2147486578,3221228322,3221228322,3221228322,2930,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147486550,0,0,0,0,0,2902,0,0,0,0,0,0,0,0,0,0,0,0,2958,2958,2958,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147484561,952,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2255,880,880,880,880,880,880,880,2147485903,0,0,0,0,0,0,2255,880,880,880,880,880,880,880,2147485903,0,0,0,0,0,0,0,0,0,0,2684356862,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2906,0,0,0,0,3221228322,3221228322,0,0,0,3221228322,3221228322,3221228322,0,0,0,3221228322,2930,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147486550,0,0,0,0,0,2902,0,0,0,0,0,0,0,0,0,0,2958,2958,0,0,0,0,0,0,0,0,0,0,0,0,0,86,86,86,86,86,0,0,0,0,2147484561,952,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2255,1073742704,1073742704,1073742704,1073742704,1073742704,1073742704,1073742704,2147485903,0,0,0,0,0,0,2255,1073742704,1073742704,1073742704,1073742704,1073742704,1073742704,1073742704,2147485903,0,0,0,0,0,0,0,0,0,0,2240,2225,2225,2225,2225,2225,3221227754,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1073744807,2958,2933,3012,2984,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147486554,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147486550,86,2147483780,0,0,0,2902,0,0,0,0,0,0,0,2958,2958,2958,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147484561,952,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2280,3221227753,3221227753,3221227753,3221227753,3221227753,3221227753,3221227753,2147485928,0,0,0,0,0,0,2280,3221227753,3221227753,3221227753,3221227753,3221227753,3221227753,3221227753,2147485928,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2147485903,2147485903,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Expand Down Expand Up @@ -741,9 +741,8 @@
<object id="1041" name="Enemigo Mosca" type="FLYBUG" x="2784" y="1840" width="16" height="16"/>
<object id="1042" name="Enemigo Espada" type="SWORD" x="3392" y="2032" width="16" height="16"/>
<object id="1043" name="Enemigo Rueda" type="WHEEL" x="3248" y="2128" width="16" height="16"/>
<object id="1044" name="Enemigo Torreta" type="TURRET" x="2432" y="2048" width="16" height="16"/>
<object id="1045" name="Enemigo Torreta" type="TURRET" x="2432" y="2096" width="16" height="16"/>
<object id="1046" name="Enemigo Torreta" type="TURRET" x="3520" y="2128" width="16" height="16"/>
<object id="1044" name="Enemigo Torreta" type="TURRET" x="2424" y="2056" width="16" height="16"/>
<object id="1045" name="Enemigo Torreta" type="TURRET" x="2424" y="2104" width="16" height="16"/>
<object id="1047" name="Enemigo Durmiente" type="SLEEPY" x="1984" y="896" width="16" height="16"/>
<object id="1048" name="Enemigo Durmiente" type="SLEEPY" x="1856" y="864" width="16" height="16"/>
<object id="1049" name="Enemigo Durmiente" type="SLEEPY" x="1856" y="992" width="16" height="16"/>
Expand Down Expand Up @@ -806,8 +805,8 @@
<object id="265" name="plataform" type="PLATAFORM" x="2976" y="1792" width="48" height="8"/>
<object id="266" name="plataform" type="PLATAFORM" x="2976" y="1744" width="48" height="8"/>
<object id="267" name="plataform" type="PLATAFORM" x="3456" y="2048" width="64" height="8"/>
<object id="268" name="plataform" type="PLATAFORM" x="2912" y="2096" width="48" height="8"/>
<object id="269" name="plataform" type="PLATAFORM" x="2672" y="2096" width="48" height="8"/>
<object id="268" name="plataform" type="PLATAFORM" x="2908.25" y="2096" width="55.5" height="8"/>
<object id="269" name="plataform" type="PLATAFORM" x="2668.36" y="2096" width="55.2727" height="8"/>
<object id="270" name="plataform" type="PLATAFORM" x="2448" y="2032" width="80" height="8"/>
<object id="326" name="plataform" type="PLATAFORM" x="1888" y="1392" width="80" height="8"/>
<object id="327" name="plataform" type="PLATAFORM" x="1984" y="1440" width="48" height="8"/>
Expand Down
Binary file modified assets/world/entities/turret/turretEnemy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion core/src/main/java/src/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void create() {
initAssets();

soundManager = SingleSoundManager.getInstance();
soundManager.setVolumeMusic(0.0f);
soundManager.setVolumeMusic(0.1f);
initSounds();
fonts = new Fonts();
initScreens();
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/src/world/entities/EntityFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Entity create(Entity.Type type, World world, Vector2 position, Integer id
case WHEEL -> new WheelEnemy(world, new Rectangle(position.x, position.y, 1.5f, 1.5f), assetManager, id, game);
case BOMBER -> new BombEnemy(world, new Rectangle(position.x, position.y, 1.5f, 1.5f), assetManager, id, game);
case DRAGON -> new DragonEnemy(world, new Rectangle(position.x, position.y, 1.5f, 1.5f), assetManager, id, game);
case TURRET -> new TurretEnemy(world, new Rectangle(position.x, position.y, 1.5f, 1.5f), assetManager, id, game);
case TURRET -> new TurretEnemy(world, new Rectangle(position.x, position.y, 2f, 2f), assetManager, id, game);
case MIRROR -> new Mirror(world, new Rectangle(position.x, position.y, 2f, 2f), assetManager, id);
case CLOUD -> new CloudProyectil(world, new Rectangle(position.x, position.y, 1f, 1f), assetManager, id, game);
case STAR -> new StarProyectil(world, new Rectangle(position.x, position.y, 1f, 1f), assetManager, id, game);
Expand All @@ -53,7 +53,7 @@ public Entity create(Entity.Type type, World world, Vector2 position, Integer id
case SWORDPROPLAYER -> new SwordProyectil(world, new Rectangle(position.x, position.y, 1f, 1.2f), assetManager, id, Entity.Type.SWORDPROPLAYER, game, assetManager.get("world/particles/kirbySwordParticle.png"));
case SWORDRUNPROPLAYER -> new SwordRunProyectil(world, new Rectangle(position.x, position.y, 1f, 1.2f), assetManager, id, Entity.Type.SWORDRUNPROPLAYER, game);
case SWORDPROENEMY -> new SwordEnemyProyectil(world, new Rectangle(position.x, position.y, 1f, 1.2f), assetManager, id, Entity.Type.SWORDPROENEMY, game, assetManager.get("world/particles/swordParticle.png"));
case TURRETPROENEMY -> new TurretEnemyProyectil(world, new Rectangle(position.x, position.y, 1f, 1f), assetManager, id, Entity.Type.TURRETPROENEMY, game, assetManager.get("world/particles/turretParticle.png"));
case TURRETPROENEMY -> new TurretEnemyProyectil(world, new Rectangle(position.x, position.y, 2f, 2f), assetManager, id, Entity.Type.TURRETPROENEMY, game, assetManager.get("world/particles/turretParticle.png"));
case COIN -> new CoinOdsPoint(world, new Rectangle(position.x, position.y, 0.75f, 0.75f), assetManager, id, game);
case POWERSWORD -> new PowerItem(world, new Rectangle(position.x, position.y, 1f, 1f), assetManager, id, game, PowerUp.Type.SWORD, assetManager.get("world/entities/powers/swordPowerItem.png"), 0.1f, 8);
case POWERWHEEL -> new PowerItem(world, new Rectangle(position.x, position.y, 1f, 1f), assetManager, id, game, PowerUp.Type.WHEEL, assetManager.get("world/entities/powers/wheelPowerItem.png"), 0.2f, 2);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/src/world/entities/enemies/Enemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Boolean checkChangeState() {
public void throwEntity(Entity.Type type, Float impulseX, Float impulseY){
float linearX = Math.abs(body.getLinearVelocity().x);
game.addEntityNoPacket(type,
body.getPosition().add(isFlipX() ? -1.2f : 1.2f,0),
body.getPosition().add(isFlipX() ? -2.2f : 1.2f,-0.5f),
new Vector2((isFlipX() ? -impulseX - linearX : impulseX + linearX),impulseY),
isFlipX()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public enum AnimationType {
}

private final Animation<TextureRegion> idleAnimation;
private final Animation<TextureRegion> attackAnimation;

public TurretEnemy(World world, Rectangle shape, AssetManager assetManager, Integer id, GameScreen game)
{
Expand All @@ -35,7 +34,7 @@ public TurretEnemy(World world, Rectangle shape, AssetManager assetManager, Inte

BodyDef def = new BodyDef();
def.position.set(shape.x + shape.width / 2, shape.y + shape.height / 2);
def.type = BodyDef.BodyType.DynamicBody;
def.type = BodyDef.BodyType.StaticBody;
body = world.createBody(def);

PolygonShape box = new PolygonShape();
Expand All @@ -58,16 +57,7 @@ public TurretEnemy(World world, Rectangle shape, AssetManager assetManager, Inte

idleAnimation = new Animation<>(1f,
SheetCutter.cutHorizontal(assetManager.get("world/entities/turret/turretEnemy.png"), 2));

attackAnimation = new Animation<>(1f,
SheetCutter.cutHorizontal(assetManager.get("world/entities/turret/turretEnemy.png"), 2));
}

public void setAnimation(TurretEnemy.AnimationType type){
switch (type){
case IDLE -> setCurrentAnimation(idleAnimation);
case ATTACK -> setCurrentAnimation(attackAnimation);
}
setCurrentAnimation(idleAnimation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public AttackStateTurret(TurretEnemy enemy)

@Override
public void start() {
enemy.setAnimation(TurretEnemy.AnimationType.ATTACK);
//enemy.throwEntity(Entity.Type.TURRETPROENEMY, 8f, 0f);
super.start();
enemy.throwEntity(Entity.Type.TURRETPROENEMY, 8f, 0f);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ public IdleStateTurret(TurretEnemy enemy) {

@Override
public void start() {
enemy.setAnimation(TurretEnemy.AnimationType.IDLE);

super.start();
}

@Override
public void update(Float delta) {
if (enemy.getActCrono() > 5) {
if (enemy.getActCrono() > 3) {
enemy.setState(Enemy.StateType.ATTACK);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Filter;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import src.screens.game.GameScreen;
import src.utils.animation.SheetCutter;
import src.utils.constants.CollisionFilters;
import src.world.ActorBox2d;
import src.world.entities.enemies.Enemy;
Expand All @@ -20,7 +23,6 @@ public class TurretEnemyProyectil extends Projectil {
public TurretEnemyProyectil(World world, Rectangle shape, AssetManager assetManager, Integer id, Type type, GameScreen game, Texture texture)
{
super(world, shape, assetManager, id, Type.BOMB, game, 3);
sprite.setTexture(assetManager.get("world/particles/turretParticle.png"));
time = 0f;

BodyDef def = new BodyDef();
Expand All @@ -29,25 +31,31 @@ public TurretEnemyProyectil(World world, Rectangle shape, AssetManager assetMana
body = world.createBody(def);

PolygonShape box = new PolygonShape();
box.setAsBox(shape.width / 4, shape.height / 4);
box.setAsBox(shape.width / 8, shape.height / 8);
fixture = body.createFixture(box, 2);
fixture.setUserData(this);
box.dispose();
body.setFixedRotation(true);
body.setGravityScale(0);

setSpritePosModification(0f, getHeight()/4);
setSpritePosModification(0f, getHeight()/3);

Filter filter = new Filter();
filter.categoryBits = CollisionFilters.PROJECTIL;
filter.maskBits = (short)(~CollisionFilters.ITEM & ~CollisionFilters.ENEMY);
filter.maskBits = (short)(~CollisionFilters.ITEM & ~CollisionFilters.STATIC & ~CollisionFilters.ENEMY & ~CollisionFilters.PROJECTIL);
fixture.setFilterData(filter);

Animation<TextureRegion> idleAnimation = new Animation<>(0.07f,
SheetCutter.cutHorizontal(assetManager.get("world/particles/turretParticle.png"), 2));
idleAnimation.setPlayMode(Animation.PlayMode.LOOP);
setCurrentAnimation(idleAnimation);

}

@Override
public void act(float delta) {
time += delta;
if (time > 3f) {
if (time > 2.5f) {
despawn();
}
}
Expand Down

0 comments on commit e9fbff6

Please sign in to comment.