Skip to content

Commit

Permalink
Added snow ball design and animation to slow effect projectile
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniSoda17 committed Sep 9, 2023
1 parent 6b0f06e commit c23cab8
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 4 deletions.
48 changes: 48 additions & 0 deletions source/core/assets/images/projectiles/snow_ball.atlas
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

snow_ball.png
size: 128, 32
format: RGBA8888
filter: Nearest, Nearest
repeat: none
projectile
rotate: false
xy: 20, 2
size: 16, 19
orig: 16, 19
offset: 0, 0
index: -1
projectile
rotate: false
xy: 56, 2
size: 16, 19
orig: 16, 19
offset: 0, 0
index: -1
projectile
rotate: false
xy: 38, 2
size: 16, 19
orig: 16, 19
offset: 0, 0
index: -1
projectileFinal
rotate: false
xy: 2, 2
size: 16, 19
orig: 16, 19
offset: 0, 0
index: -1
collision
rotate: false
xy: 92, 3
size: 16, 18
orig: 16, 18
offset: 0, 0
index: -1
collision
rotate: false
xy: 74, 3
size: 16, 18
orig: 16, 18
offset: 0, 0
index: -1
Binary file added source/core/assets/images/projectiles/snow_ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public class ForestGameArea extends GameArea {
"images/projectiles/basic_projectile.png",
"images/projectiles/mobProjectile.png",
"images/projectiles/engineer_projectile.png",
"images/projectiles/mobKing_projectile.png"
"images/projectiles/mobKing_projectile.png",
"images/projectiles/snow_ball.png"

};
private static final String[] forestTextureAtlases = {
"images/economy/econ-tower.atlas",
Expand All @@ -117,7 +119,8 @@ public class ForestGameArea extends GameArea {
"images/projectiles/basic_projectile.atlas",
"images/projectiles/mobProjectile.atlas",
"images/projectiles/engineer_projectile.atlas",
"images/projectiles/mobKing_projectile.atlas"
"images/projectiles/mobKing_projectile.atlas",
"images/projectiles/snow_ball.atlas"
};
private static final String[] forestSounds = {
"sounds/Impact4.ogg",
Expand Down Expand Up @@ -168,10 +171,10 @@ public void create() {
playMusic();

// Types of projectile
spawnEffectProjectile(new Vector2(0, 10), PhysicsLayer.HUMANS, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.BURN, true);
spawnPierceFireBall(new Vector2(2, 3), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f));
spawnRicochetFireball(new Vector2(2, 4), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f));
spawnSplitFireWorksFireBall(new Vector2(2, 5), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), 12);
spawnEffectProjectile(new Vector2(2, 6), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.SLOW, false);
// spawnProjectileTest(new Vector2(0, 8), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f));

spawnXenoGrunts();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.csse3200.game.components.projectile;

import com.csse3200.game.components.Component;
import com.csse3200.game.rendering.AnimationRenderComponent;

public class SnowBallProjectileAnimationController extends Component{
private static final String START = "startProjectile";
private static final String FINAL = "startProjectileFinal";

/** Animation name constants */
private static final String START_ANIM = "projectile";
private static final String FINAL_ANIM = "projectileFinal";
AnimationRenderComponent animator;

@Override
public void create() {
super.create();
animator = this.entity.getComponent(AnimationRenderComponent.class);
entity.getEvents().addListener(START, this::animateStart);
entity.getEvents().addListener(FINAL, this::animateFinal);

}

void animateStart() {
animator.startAnimation(START_ANIM);
}

void animateFinal() {
animator.startAnimation(FINAL_ANIM);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.csse3200.game.components.projectile.EngineerBulletsAnimationControlller;
import com.csse3200.game.components.projectile.MobProjectileAnimationController;
import com.csse3200.game.components.projectile.ProjectileAnimationController;
import com.csse3200.game.components.projectile.SnowBallProjectileAnimationController;

/**
* Responsible for creating projectiles within the game.
Expand All @@ -53,7 +54,7 @@ public class ProjectileFactory {
* @return Returns a new single-target projectile entity
*/
public static Entity createEffectProjectile(short targetLayer, Vector2 destination, Vector2 speed, ProjectileEffects effect, boolean aoe) {
Entity projectile = createFireBall(targetLayer, destination, speed);
Entity projectile = createBaseProjectile(targetLayer, destination, speed);

switch(effect) {
case FIREBALL -> {
Expand All @@ -64,6 +65,21 @@ public static Entity createEffectProjectile(short targetLayer, Vector2 destinati
}
case SLOW -> {
projectile.addComponent(new EffectsComponent(targetLayer, 3, ProjectileEffects.SLOW, aoe));
AnimationRenderComponent animator =
new AnimationRenderComponent(
ServiceLocator.getResourceService()
.getAsset("images/projectiles/snow_ball.atlas", TextureAtlas.class));
animator.addAnimation(START_ANIM, START_SPEED, Animation.PlayMode.NORMAL);
animator.addAnimation(FINAL_ANIM, FINAL_SPEED, Animation.PlayMode.NORMAL);

projectile
.addComponent(animator)
.addComponent(new SnowBallProjectileAnimationController());
// * TEMPORARY
// .addComponent(new DeleteOnMapEdgeComponent());
// .addComponent(new SelfDestructOnHitComponent(PhysicsLayer.OBSTACLE));

return projectile;
}
case STUN -> {
projectile.addComponent(new EffectsComponent(targetLayer, 3, ProjectileEffects.STUN, aoe));
Expand Down

0 comments on commit c23cab8

Please sign in to comment.