Added Sound effects to code
This commit is contained in:
parent
c92f3aabb2
commit
40657262a7
3 changed files with 11 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.sagi.dayan.Games.Elements;
|
package com.sagi.dayan.Games.Elements;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sagi.dayan.Games.Utils.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by sagi on 2/20/16.
|
* Created by sagi on 2/20/16.
|
||||||
|
@ -63,6 +64,7 @@ public class EnemyShip extends AnimatedSprite {
|
||||||
startExploded = System.currentTimeMillis();
|
startExploded = System.currentTimeMillis();
|
||||||
animations.add(new Animation("explosion.png", 16, 500));
|
animations.add(new Animation("explosion.png", 16, 500));
|
||||||
currentAnimation++;
|
currentAnimation++;
|
||||||
|
Utils.playSound("enemy_exp.wav");
|
||||||
}
|
}
|
||||||
System.out.println("GOT HIT " + hitsToDestroy);
|
System.out.println("GOT HIT " + hitsToDestroy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,11 @@ import java.awt.Graphics;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.rmi.CORBA.Util;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import com.sagi.dayan.Games.Stage.Level;
|
import com.sagi.dayan.Games.Stage.Level;
|
||||||
|
import com.sagi.dayan.Games.Utils.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by sagi on 3/11/16.
|
* Created by sagi on 3/11/16.
|
||||||
|
@ -56,6 +58,7 @@ public class Wave {
|
||||||
}else{
|
}else{
|
||||||
enemies.add(new EnemyShip(startX, startY, level.getStageHeight(), level.getStageHeight(), acc, "L1-ES2.png", 0, 15, 15, fireDelay, stepDelay, this, moveVector, 2, hitsToDestroy));
|
enemies.add(new EnemyShip(startX, startY, level.getStageHeight(), level.getStageHeight(), acc, "L1-ES2.png", 0, 15, 15, fireDelay, stepDelay, this, moveVector, 2, hitsToDestroy));
|
||||||
}
|
}
|
||||||
|
Utils.playSound("enemy_enter.wav");
|
||||||
lastLaunchTime = now;
|
lastLaunchTime = now;
|
||||||
currentAmount++;
|
currentAmount++;
|
||||||
}
|
}
|
||||||
|
@ -83,8 +86,10 @@ public class Wave {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireFromEnemy(EnemyShip e){
|
public void fireFromEnemy(EnemyShip e){
|
||||||
if(!e.isDead())
|
if(!e.isDead()) {
|
||||||
level.enemyFire(e.getCenterX(), (int)(e.getLocY() + e.getsHeight()), -(e.getAcceleration() + 2));
|
level.enemyFire(e.getCenterX(), (int) (e.getLocY() + e.getsHeight()), -(e.getAcceleration() + 2));
|
||||||
|
Utils.playSound("enemy_relese.wav");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector <EnemyShip> getEnemies() {
|
public Vector <EnemyShip> getEnemies() {
|
||||||
|
|
|
@ -461,7 +461,7 @@ public abstract class Level extends Scene {
|
||||||
eMTR.add(enemyMissiles.get(j));
|
eMTR.add(enemyMissiles.get(j));
|
||||||
}else{
|
}else{
|
||||||
blasts.add(new Blast((int)players.get(i).getLocX(),(int)players.get(i).getLocY(),"explosion.png",15));
|
blasts.add(new Blast((int)players.get(i).getLocX(),(int)players.get(i).getLocY(),"explosion.png",15));
|
||||||
|
Utils.playSound("player_exp.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,6 +540,7 @@ public abstract class Level extends Scene {
|
||||||
|
|
||||||
protected void playerHit(int i){
|
protected void playerHit(int i){
|
||||||
if(players.get(i).isMortal()){
|
if(players.get(i).isMortal()){
|
||||||
|
Utils.playSound((i == 0) ? "player_1_hit.wav" : "player_2_hit.wav");
|
||||||
engine.setPlayerHealth(i, -10);
|
engine.setPlayerHealth(i, -10);
|
||||||
if(i == 0){
|
if(i == 0){
|
||||||
if(engine.getP1Health() == 100){
|
if(engine.getP1Health() == 100){
|
||||||
|
|
Loading…
Reference in a new issue