diff --git a/core/assets/badlogic.jpg b/core/assets/badlogic.jpg deleted file mode 100644 index 4390da6..0000000 Binary files a/core/assets/badlogic.jpg and /dev/null differ diff --git a/core/assets/doorOpen.wav b/core/assets/doorOpen.wav new file mode 100644 index 0000000..73b84d6 Binary files /dev/null and b/core/assets/doorOpen.wav differ diff --git a/core/assets/drop.wav b/core/assets/drop.wav new file mode 100644 index 0000000..9b6fde6 Binary files /dev/null and b/core/assets/drop.wav differ diff --git a/core/assets/explode.wav b/core/assets/explode.wav new file mode 100644 index 0000000..36fd4c4 Binary files /dev/null and b/core/assets/explode.wav differ diff --git a/core/assets/hurt.wav b/core/assets/hurt.wav new file mode 100644 index 0000000..8ec91a5 Binary files /dev/null and b/core/assets/hurt.wav differ diff --git a/core/assets/pickup.wav b/core/assets/pickup.wav new file mode 100644 index 0000000..b652139 Binary files /dev/null and b/core/assets/pickup.wav differ diff --git a/core/assets/step.wav b/core/assets/step.wav new file mode 100644 index 0000000..660b725 Binary files /dev/null and b/core/assets/step.wav differ diff --git a/core/assets/throw.wav b/core/assets/throw.wav new file mode 100644 index 0000000..c279f6c Binary files /dev/null and b/core/assets/throw.wav differ diff --git a/core/src/com/toasted/chuck/Audio.java b/core/src/com/toasted/chuck/Audio.java new file mode 100644 index 0000000..05f16ba --- /dev/null +++ b/core/src/com/toasted/chuck/Audio.java @@ -0,0 +1,15 @@ +package com.toasted.chuck; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.files.FileHandle; + +public class Audio { + public static Sound getSound(String filename){ + return Gdx.audio.newSound(Gdx.files.internal(filename)); + } + public static Music getMusic(String filename){ + return Gdx.audio.newMusic(Gdx.files.internal(filename)); + } +} diff --git a/core/src/com/toasted/chuck/Level.java b/core/src/com/toasted/chuck/Level.java index e2cdb86..d93806d 100644 --- a/core/src/com/toasted/chuck/Level.java +++ b/core/src/com/toasted/chuck/Level.java @@ -5,6 +5,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.maps.MapLayer; import com.badlogic.gdx.maps.MapObject; import com.badlogic.gdx.maps.MapProperties; @@ -32,6 +33,8 @@ public class Level { private HashMap collisionLookupTable = new HashMap(); private ArrayList secretRooms = new ArrayList(); + private Sound doorOpening = Audio.getSound("doorOpen.wav"); + public Level(String filename, Graphics graphics){ tiledMap = new TmxMapLoader().load("testmap.tmx"); tmRenderer = new OrthogonalTiledMapRenderer(tiledMap, graphics.getBatch()); @@ -109,9 +112,13 @@ public class Level { public void revealSecretRoom(String name){ + MapLayer layer = tiledMap.getLayers().get(name); if(layer != null){ layer.setVisible(true); + doorOpening.play(); + + } else { System.err.println("Failed to reveal room: " + name); } @@ -140,7 +147,7 @@ public class Level { if(o.getProperties().containsKey("customColor")){ LightEmitter le = (LightEmitter)newEntity; String[] rgbValues = ((String)o.getProperties().get("customColor")).split(","); - System.out.println("Setting CUSTOM RGB"); +// System.out.println("Setting CUSTOM RGB"); le.getLight().setLightColor(Float.parseFloat(rgbValues[0]), Float.parseFloat(rgbValues[1]), Float.parseFloat(rgbValues[2])); } } diff --git a/core/src/com/toasted/chuck/entities/Entity.java b/core/src/com/toasted/chuck/entities/Entity.java index a176dfa..91efad0 100644 --- a/core/src/com/toasted/chuck/entities/Entity.java +++ b/core/src/com/toasted/chuck/entities/Entity.java @@ -2,8 +2,11 @@ package com.toasted.chuck.entities; import java.util.ArrayList; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; +import com.toasted.chuck.Audio; import com.toasted.chuck.EntityController; import com.toasted.chuck.Graphics; import com.toasted.chuck.Level; @@ -20,6 +23,10 @@ public abstract class Entity { protected float stunTimer = 0; protected float weight = 0; //used for destruction capabilities and pressure plate triggering protected int health = 3; + + protected static Sound hurt = Audio.getSound("hurt.wav"); + protected static Sound drop = Audio.getSound("drop.wav"); + protected static Sound step = Audio.getSound("step.wav"); public Entity(){ } @@ -102,6 +109,8 @@ public abstract class Entity { return getY(); } public void stun(float duration){ + if(stunTimer > 0) return; + hurt.play(); this.stunTimer = duration; } } diff --git a/core/src/com/toasted/chuck/entities/EntityBox.java b/core/src/com/toasted/chuck/entities/EntityBox.java index 8bf8921..17c5bef 100644 --- a/core/src/com/toasted/chuck/entities/EntityBox.java +++ b/core/src/com/toasted/chuck/entities/EntityBox.java @@ -16,9 +16,15 @@ public class EntityBox extends Entity{ weight = 1; } public void update(float delta, Level lvl) { + float preFly = flyLength; flyLength -= delta; - if(flyLength <= 0) + if(preFly > 0 && flyLength <= 0){ + drop.play(1f, (1- weight) + .5f, 0); + + } + if(flyLength <= 0){ velocity.mulAdd(velocity, -delta * decel); + } Rectangle r = doCollisions(delta, lvl.getCollisions()); if(r != null){ if(lvl.isCollisionBoxDestructable(r) && weight > .75f){ diff --git a/core/src/com/toasted/chuck/entities/EntityPlayer.java b/core/src/com/toasted/chuck/entities/EntityPlayer.java index 1f811c0..fe3d154 100644 --- a/core/src/com/toasted/chuck/entities/EntityPlayer.java +++ b/core/src/com/toasted/chuck/entities/EntityPlayer.java @@ -3,10 +3,12 @@ package com.toasted.chuck.entities; import java.util.ArrayList; import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; +import com.toasted.chuck.Audio; import com.toasted.chuck.EntityController; import com.toasted.chuck.Graphics; import com.toasted.chuck.Level; @@ -24,6 +26,12 @@ public class EntityPlayer extends Entity implements LightEmitter{ private int lastDirectionalUsed; private ArrayList directionals = new ArrayList();//Don't think I'll use this private boolean[] arrowKeys = new boolean[4]; //UDLR + + private float stepTimerFull = .25f; + private float stepTimer = stepTimerFull; + private static Sound pickup = Audio.getSound("pickup.wav"); + private static Sound throwing = Audio.getSound("throw.wav"); + public EntityPlayer(){ weight = 1; isChuckable = false; @@ -47,10 +55,9 @@ public class EntityPlayer extends Entity implements LightEmitter{ if(e.collision.overlaps(collision) && e.isChuckable){ holding = e; holding.shouldDrawSelf = false; - + pickup.play(); if(holding instanceof LightEmitter){ LightEmitter le = (LightEmitter)holding; - System.err.println(le.getLight()); } @@ -62,7 +69,7 @@ public class EntityPlayer extends Entity implements LightEmitter{ holding.velocity.add(velocity).mulAdd(getDirectionalVector(), throwSpeed); holding.flyLength = .5f; holding.shouldDrawSelf = true; - + throwing.play(); holding = null; } break; @@ -176,8 +183,14 @@ public class EntityPlayer extends Entity implements LightEmitter{ doControls(); - - + float vectorMag = (float)Math.sqrt(Math.pow(velocity.x, 2) + Math.pow(velocity.y, 2)); + if(vectorMag != 0){ + stepTimer -= delta; + if(stepTimer <= 0){ + stepTimer = stepTimerFull; + step.play(.5f, 1, 0); + } + } doCollisions(delta, lvl.getCollisions()); diff --git a/core/src/com/toasted/chuck/entities/EntityPressurePad.java b/core/src/com/toasted/chuck/entities/EntityPressurePad.java index ae55a12..72b602c 100644 --- a/core/src/com/toasted/chuck/entities/EntityPressurePad.java +++ b/core/src/com/toasted/chuck/entities/EntityPressurePad.java @@ -1,9 +1,6 @@ package com.toasted.chuck.entities; -import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.Rectangle; -import com.badlogic.gdx.math.Vector2; import com.toasted.chuck.Graphics; import com.toasted.chuck.Level; import com.toasted.chuck.Light;