Added Sound effects to code

This commit is contained in:
Sagi Dayan 2016-03-20 21:16:01 +02:00
parent c92f3aabb2
commit 40657262a7
3 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package com.sagi.dayan.Games.Elements;
import com.sagi.dayan.Games.Utils.Utils;
/**
* Created by sagi on 2/20/16.
@ -63,6 +64,7 @@ public class EnemyShip extends AnimatedSprite {
startExploded = System.currentTimeMillis();
animations.add(new Animation("explosion.png", 16, 500));
currentAnimation++;
Utils.playSound("enemy_exp.wav");
}
System.out.println("GOT HIT " + hitsToDestroy);
}

View file

@ -4,9 +4,11 @@ import java.awt.Graphics;
import java.util.Random;
import java.util.Vector;
import javax.rmi.CORBA.Util;
import javax.swing.JPanel;
import com.sagi.dayan.Games.Stage.Level;
import com.sagi.dayan.Games.Utils.Utils;
/**
* Created by sagi on 3/11/16.
@ -56,6 +58,7 @@ public class Wave {
}else{
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;
currentAmount++;
}
@ -83,8 +86,10 @@ public class Wave {
}
public void fireFromEnemy(EnemyShip e){
if(!e.isDead())
level.enemyFire(e.getCenterX(), (int)(e.getLocY() + e.getsHeight()), -(e.getAcceleration() + 2));
if(!e.isDead()) {
level.enemyFire(e.getCenterX(), (int) (e.getLocY() + e.getsHeight()), -(e.getAcceleration() + 2));
Utils.playSound("enemy_relese.wav");
}
}
public Vector <EnemyShip> getEnemies() {

View file

@ -461,7 +461,7 @@ public abstract class Level extends Scene {
eMTR.add(enemyMissiles.get(j));
}else{
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){
if(players.get(i).isMortal()){
Utils.playSound((i == 0) ? "player_1_hit.wav" : "player_2_hit.wav");
engine.setPlayerHealth(i, -10);
if(i == 0){
if(engine.getP1Health() == 100){