From e9fbff6cbee61dad9a557a81130e90d24d29d138 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Feb 2025 12:08:56 -0400 Subject: [PATCH] feat: Enemigo torreta terminado --- assets/tiled/maps/gameMap.tmx | 13 ++++++------- assets/world/entities/turret/turretEnemy.png | Bin 767 -> 751 bytes core/src/main/java/src/main/Main.java | 2 +- .../src/world/entities/EntityFactory.java | 4 ++-- .../src/world/entities/enemies/Enemy.java | 2 +- .../entities/enemies/turret/TurretEnemy.java | 14 ++------------ .../turret/states/AttackStateTurret.java | 4 ++-- .../turret/states/IdleStateTurret.java | 5 ++--- .../TurretEnemyProyectil.java | 18 +++++++++++++----- 9 files changed, 29 insertions(+), 33 deletions(-) diff --git a/assets/tiled/maps/gameMap.tmx b/assets/tiled/maps/gameMap.tmx index 0da4be5..99936c7 100644 --- a/assets/tiled/maps/gameMap.tmx +++ b/assets/tiled/maps/gameMap.tmx @@ -1,5 +1,5 @@ - + @@ -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, @@ -741,9 +741,8 @@ - - - + + @@ -806,8 +805,8 @@ - - + + diff --git a/assets/world/entities/turret/turretEnemy.png b/assets/world/entities/turret/turretEnemy.png index 7948303bcd3991401cc82785c2b4ae61a92a4cc9..29b1fd295f7dda64544cc1594786fb93d747ccbf 100644 GIT binary patch delta 701 zcmV;u0z&=&1@8rrBv`gdL_t(|obA{lZ`(i^hw-P=z(JRtS#Ru$nz5EG(ujvv*lHjP ztTfW0X>hb;QehR8!WPW~lhSX{l$q_u?wF6wECZR{bVGBp+Ti_3krJQJ`A7F&d}on= z9e;%QZML1u zHWBuJ=sN#e7dA>Q08U1ym^8)ev}r4X$9d2BL22aPsy& zc63NFx#HEk<3}HazT|(>rqg)GF0#D=F?yDSxX`GfFM87elJTp+ZHa6@N}kfT1=`yRwEPN!d>HgMZ38 zevv);4Cqt-_N$<>M1=}~S#W&+HiJEL-+t$K_Hsx@x;#&pgu)SZ0(XH*N1}!4P2M`f zT6&Vd{Q%qr96u?D02GDi?9I4oKK<|sfElhx9-~yVhVF7>)~Eby zZ^SGK1(9rTKouf-|A6Oq0I*!v*_GX8;mPN>6ko48sr)|X-^ingp*HCK16qJ)V^gjC zH!7Wwm|dRR0am9>Z*nfLr=35Z=tKUsAI8<;WAt!SG{@EINg)tIWEMT_XX}3DMs=Nk jBQv0_zRZBOHj)1qkk?^YTk**b00000NkvXXu0mjfaO!37 delta 719 zcmV;=0xhT*rx=Gkx*N??XHk)+vwuJ%2$^|@_ZiyR zc^qm!{4hHYnW2hJIBD~GAKl?5}zv}m>Yb9(${(BEvD>c8l91wqXk1_pETzz~`GM$v|oud=H&tNt~ zx8kyjit4eG6dDbJpvmxhu<=!}E%~2R9Z2u|Ey-j|pr3PdIpC~&L3^)-_Zhjd0L;82 z3Y$dTW1_Ih%sT*bWAQ$tz1O0yjk)gpl{evHQ(`tFS#DA^8sx^JTuzQ>I2|y&9>Do+ zzc_!?%l5@4m#$RbCe@w4(gX~?BxR*2mt#rEokxWM%H;s0&hq_p3VZstq8_ z(?CQ}-dk*1wmfyZWo8+}EE0m*biM1aB9_8_(m`PXMQ z0iB~0P7d1`moYXIy!}S*ZmURzLHXbU;6`7|-`u+Yil{UHTK|kQE+ZW!<*`n!HaZ75 zJO&OU!u 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); @@ -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); diff --git a/core/src/main/java/src/world/entities/enemies/Enemy.java b/core/src/main/java/src/world/entities/enemies/Enemy.java index 3a1f599..71e4d3c 100644 --- a/core/src/main/java/src/world/entities/enemies/Enemy.java +++ b/core/src/main/java/src/world/entities/enemies/Enemy.java @@ -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() ); diff --git a/core/src/main/java/src/world/entities/enemies/turret/TurretEnemy.java b/core/src/main/java/src/world/entities/enemies/turret/TurretEnemy.java index 535c94c..044a6ae 100644 --- a/core/src/main/java/src/world/entities/enemies/turret/TurretEnemy.java +++ b/core/src/main/java/src/world/entities/enemies/turret/TurretEnemy.java @@ -26,7 +26,6 @@ public enum AnimationType { } private final Animation idleAnimation; - private final Animation attackAnimation; public TurretEnemy(World world, Rectangle shape, AssetManager assetManager, Integer id, GameScreen game) { @@ -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(); @@ -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 diff --git a/core/src/main/java/src/world/entities/enemies/turret/states/AttackStateTurret.java b/core/src/main/java/src/world/entities/enemies/turret/states/AttackStateTurret.java index 7cab28c..7737938 100644 --- a/core/src/main/java/src/world/entities/enemies/turret/states/AttackStateTurret.java +++ b/core/src/main/java/src/world/entities/enemies/turret/states/AttackStateTurret.java @@ -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 diff --git a/core/src/main/java/src/world/entities/enemies/turret/states/IdleStateTurret.java b/core/src/main/java/src/world/entities/enemies/turret/states/IdleStateTurret.java index acb2a6f..96474fb 100644 --- a/core/src/main/java/src/world/entities/enemies/turret/states/IdleStateTurret.java +++ b/core/src/main/java/src/world/entities/enemies/turret/states/IdleStateTurret.java @@ -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); } } diff --git a/core/src/main/java/src/world/entities/projectiles/enemyProyectiles/TurretEnemyProyectil.java b/core/src/main/java/src/world/entities/projectiles/enemyProyectiles/TurretEnemyProyectil.java index ba6455a..1fb7414 100644 --- a/core/src/main/java/src/world/entities/projectiles/enemyProyectiles/TurretEnemyProyectil.java +++ b/core/src/main/java/src/world/entities/projectiles/enemyProyectiles/TurretEnemyProyectil.java @@ -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; @@ -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(); @@ -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 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(); } }