Skip to content

Commit

Permalink
test audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Luraguse committed May 22, 2013
1 parent c48d9aa commit 710087a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 46 deletions.
Binary file removed lumpundform-html/war/WEB-INF/lib/gwt-servlet.jar
Binary file not shown.
Expand Up @@ -25,6 +25,7 @@
import com.lumpundform.actores.Personaje; import com.lumpundform.actores.Personaje;
import com.lumpundform.audio.ManejadorDeMusica; import com.lumpundform.audio.ManejadorDeMusica;
import com.lumpundform.audio.ManejadorDeSonido; import com.lumpundform.audio.ManejadorDeSonido;
import com.lumpundform.audio.MusicaDisponible;
import com.lumpundform.colision.Linea; import com.lumpundform.colision.Linea;
import com.lumpundform.colision.Poligono; import com.lumpundform.colision.Poligono;
import com.lumpundform.eventos.Escena; import com.lumpundform.eventos.Escena;
Expand Down
12 changes: 12 additions & 0 deletions lumpundform/src/com/lumpundform/escenario/EscenarioHelper.java
@@ -1,5 +1,8 @@
package com.lumpundform.escenario; package com.lumpundform.escenario;


import java.text.SimpleDateFormat;
import java.util.Calendar;

import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
Expand All @@ -11,6 +14,7 @@
import com.lumpundform.interfaz.InterfazHelper; import com.lumpundform.interfaz.InterfazHelper;
import com.lumpundform.lumpundform.CamaraJuego; import com.lumpundform.lumpundform.CamaraJuego;
import com.lumpundform.utilerias.D; import com.lumpundform.utilerias.D;
import com.lumpundform.utilerias.U;


/** /**
* Clase que ayuda con las funciones de los escenarios, como cargar el mapa, los * Clase que ayuda con las funciones de los escenarios, como cargar el mapa, los
Expand All @@ -25,6 +29,8 @@ public class EscenarioHelper {
private InterfazHelper interfazHelper; private InterfazHelper interfazHelper;
private EscenarioBase escenario; private EscenarioBase escenario;
private boolean dibujarColision; private boolean dibujarColision;
private long timeStamp;
private long soundStamp;


/** /**
* Inicializa el escenario, el mapa, las colisiones y el {@link Heroe} para * Inicializa el escenario, el mapa, las colisiones y el {@link Heroe} para
Expand Down Expand Up @@ -203,5 +209,11 @@ public void siguienteCancion() {


public void sonidoAtacar() { public void sonidoAtacar() {
escenario.ms.play(SonidosDisponibles.ATAQUE); escenario.ms.play(SonidosDisponibles.ATAQUE);
soundStamp = System.currentTimeMillis();
U.l("dif", soundStamp - timeStamp);
}

public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
} }
} }
@@ -1,5 +1,8 @@
package com.lumpundform.input; package com.lumpundform.input;


import java.text.SimpleDateFormat;
import java.util.Calendar;

import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.input.GestureDetector.GestureListener; import com.badlogic.gdx.input.GestureDetector.GestureListener;
Expand Down Expand Up @@ -78,6 +81,8 @@ public boolean keyDown(int keycode) {
Heroe heroe = escenario.getHeroe(); Heroe heroe = escenario.getHeroe();
/* Disparar */ /* Disparar */
if (keycode == Keys.SPACE) { if (keycode == Keys.SPACE) {
long timeStamp = System.currentTimeMillis();
escenario.setTimeStamp(timeStamp);
heroe.habilidad("disparar"); heroe.habilidad("disparar");
escenario.sonidoAtacar(); escenario.sonidoAtacar();
return true; return true;
Expand Down
92 changes: 46 additions & 46 deletions lumpundform/src/com/lumpundform/utilerias/LRUCache.java
@@ -1,46 +1,46 @@
package com.lumpundform.utilerias; package com.lumpundform.utilerias;


import java.util.Collection; import java.util.Collection;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;


public class LRUCache<K, V> { public class LRUCache<K, V> {
public interface CacheEntryRemovedListener<K, V> { public interface CacheEntryRemovedListener<K, V> {
void notifyEntryRemoved(K key, V value); void notifyEntryRemoved(K key, V value);
} }


private Map<K, V> cache; private Map<K, V> cache;
private CacheEntryRemovedListener<K, V> entryRemovedListener; private CacheEntryRemovedListener<K, V> entryRemovedListener;


public LRUCache(final int maxEntries) { public LRUCache(final int maxEntries) {
cache = new LinkedHashMap<K, V>(maxEntries + 1, .75f, true) { cache = new LinkedHashMap<K, V>(maxEntries + 1, .75f, true) {
public boolean removeEldestEntry(Map.Entry<K, V> eldest) { public boolean removeEldestEntry(Map.Entry<K, V> eldest) {
if (size() > maxEntries) { if (size() > maxEntries) {
if (entryRemovedListener != null) { if (entryRemovedListener != null) {
entryRemovedListener.notifyEntryRemoved( entryRemovedListener.notifyEntryRemoved(
eldest.getKey(), eldest.getValue()); eldest.getKey(), eldest.getValue());
} }
return true; return true;
} }
return false; return false;
} }
}; };
} }


public void add(K key, V value) { public void add(K key, V value) {
cache.put(key, value); cache.put(key, value);
} }


public V get(K key) { public V get(K key) {
return cache.get(key); return cache.get(key);
} }


public Collection<V> retrieaveAll() { public Collection<V> retrieaveAll() {
return cache.values(); return cache.values();
} }


public void setEntryRemovedListener( public void setEntryRemovedListener(
CacheEntryRemovedListener<K, V> entryRemovedListener) { CacheEntryRemovedListener<K, V> entryRemovedListener) {
this.entryRemovedListener = entryRemovedListener; this.entryRemovedListener = entryRemovedListener;
} }
} }

0 comments on commit 710087a

Please sign in to comment.