Skip to content

Commit

Permalink
Added new Engineer Bullets for Engineers to shoot
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniSoda17 committed Sep 9, 2023
1 parent 23d5db0 commit 3f5b644
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
26 changes: 10 additions & 16 deletions source/core/assets/images/projectiles/engineer_projectile.atlas
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,11 @@ filter: Nearest, Nearest
repeat: none
bullet
rotate: false
xy: 68, 2
xy: 47, 2
size: 19, 19
orig: 19, 19
offset: 0, 0
index: -1
bullet
rotate: false
xy: 25, 2
size: 20, 19
orig: 20, 19
offset: 0, 0
index: -1
default
rotate: false
xy: 25, 2
size: 20, 19
orig: 20, 19
offset: 0, 0
index: -1
bullet
rotate: false
xy: 2, 2
Expand All @@ -34,8 +20,16 @@ bullet
index: -1
bulletFinal
rotate: false
xy: 47, 2
xy: 68, 2
size: 19, 19
orig: 19, 19
offset: 0, 0
index: -1
bullet
rotate: false
xy: 25, 2
size: 20, 19
orig: 20, 19
offset: 0, 0
index: -1

Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public class ForestGameArea extends GameArea {
"images/towers/TNTTower.atlas",
"images/projectiles/basic_projectile.atlas",
"images/projectiles/mobProjectile.atlas",
"images/projectiles/engineer_bullets.atlas"
"images/projectiles/engineer_projectile.atlas"
};
private static final String[] forestSounds = {
"sounds/Impact4.ogg",
Expand Down Expand Up @@ -162,7 +162,8 @@ public void create() {

// Types of projectile
spawnEffectProjectile(new Vector2(0, 10), PhysicsLayer.HUMANS, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.BURN, true);
spawnMobBall(new Vector2(15,10), PhysicsLayer.NPC, towardsTowers, new Vector2(2f, 2f));
spawnMobBall(new Vector2(0, 8), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f));

spawnXenoGrunts();

spawnGhosts();
Expand Down Expand Up @@ -300,7 +301,7 @@ private void spawnProjectile(Vector2 position, short targetLayer, int direction,
*
*/
private void spawnMobBall(Vector2 position, short targetLayer, int direction, Vector2 speed) {
Entity Projectile = ProjectileFactory.createMobBall(targetLayer, new Vector2(direction, position.y), speed);
Entity Projectile = ProjectileFactory.createEngineerBullet(targetLayer, new Vector2(direction, position.y), speed);
Projectile.setPosition(position);
spawnEntity(Projectile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.services.ServiceLocator; //used for sound

public class EngineerBullets extends Component{
public class EngineerBulletsAnimationControlller extends Component{
/** Event name constants */

AnimationRenderComponent animator;
Expand All @@ -13,8 +13,8 @@ public class EngineerBullets extends Component{
public void create() {
super.create();
animator = this.entity.getComponent(AnimationRenderComponent.class);
entity.getEvents().addListener("start", this::animateStart);
entity.getEvents().addListener("final", this::animateFinal);
entity.getEvents().addListener("startProjectile", this::animateStart);
entity.getEvents().addListener("startProjectileFinal", this::animateFinal);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ public void updateEngineerState() {
Entity newProjectile = ProjectileFactory.createEngineerBullet(PhysicsLayer.NPC,
new Vector2(100, owner.getEntity().getPosition().y),
new Vector2(4f, 4f));
newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.75), (float) (owner.getEntity().getPosition().y + 0.4));
newProjectile.setScale(0.8f, 0.8f);
newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.3), (float) (owner.getEntity().getPosition().y + 0.15));
ServiceLocator.getEntityService().register(newProjectile);
shotsFired += 1;
reloadTime = timeSource.getTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.csse3200.game.physics.components.PhysicsComponent;
import com.csse3200.game.physics.components.PhysicsMovementComponent;
import com.badlogic.gdx.math.Vector2;
import com.csse3200.game.components.projectile.EngineerBulletsAnimationControlller;
import com.csse3200.game.components.projectile.MobProjectileAnimationController;
import com.csse3200.game.components.projectile.ProjectileAnimationController;

Expand Down Expand Up @@ -129,13 +130,13 @@ public static Entity createEngineerBullet(short targetLayer, Vector2 destination
AnimationRenderComponent animator =
new AnimationRenderComponent(
ServiceLocator.getResourceService()
.getAsset(BASE_PROJECTILE_ATLAS, TextureAtlas.class));
.getAsset("images/projectiles/engineer_projectile.atlas", TextureAtlas.class));
animator.addAnimation("bullet", START_SPEED, Animation.PlayMode.NORMAL);
animator.addAnimation("bulletFinal", FINAL_SPEED, Animation.PlayMode.NORMAL);

projectile
.addComponent(animator)
.addComponent(new ProjectileAnimationController());
.addComponent(new EngineerBulletsAnimationControlller());
// .addComponent(new SelfDestructOnHitComponent(PhysicsLayer.OBSTACLE));

return projectile;
Expand Down

0 comments on commit 3f5b644

Please sign in to comment.