diff --git a/android/ic_launcher-playstore.png b/android/ic_launcher-playstore.png new file mode 100644 index 0000000000000000000000000000000000000000..e195e67b3400d52deda7afa4611ff70682624874 Binary files /dev/null and b/android/ic_launcher-playstore.png differ diff --git a/android/res/drawable/ic_launcher_background.xml b/android/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..ca3826a46ce070f906d0d3fbe6987df882134381 --- /dev/null +++ b/android/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<vector + android:height="108dp" + android:width="108dp" + android:viewportHeight="108" + android:viewportWidth="108" + xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#3DDC84" + android:pathData="M0,0h108v108h-108z"/> + <path android:fillColor="#00000000" android:pathData="M9,0L9,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,0L19,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,0L29,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,0L39,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,0L49,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,0L59,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,0L69,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,0L79,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M89,0L89,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M99,0L99,108" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,9L108,9" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,19L108,19" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,29L108,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,39L108,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,49L108,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,59L108,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,69L108,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,79L108,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,89L108,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M0,99L108,99" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,29L89,29" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,39L89,39" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,49L89,49" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,59L89,59" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,69L89,69" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M19,79L89,79" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M29,19L29,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M39,19L39,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M49,19L49,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M59,19L59,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M69,19L69,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> + <path android:fillColor="#00000000" android:pathData="M79,19L79,89" + android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> +</vector> diff --git a/android/res/mipmap-anydpi-v26/ic_launcher.xml b/android/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000000000000000000000000000000000000..c4a603d4cce78b2fbd8094bd0224d4778bc8c976 --- /dev/null +++ b/android/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/android/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000000000000000000000000000000000000..c4a603d4cce78b2fbd8094bd0224d4778bc8c976 --- /dev/null +++ b/android/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> + <background android:drawable="@drawable/ic_launcher_background"/> + <foreground android:drawable="@mipmap/ic_launcher_foreground"/> +</adaptive-icon> \ No newline at end of file diff --git a/android/res/mipmap-hdpi/ic_launcher.png b/android/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..5aac51a3a762fe902e6e1ccc26154991664be5e7 Binary files /dev/null and b/android/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/res/mipmap-hdpi/ic_launcher_foreground.png b/android/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..088d9f88c09cd86a02f808693e8412529d4a5adc Binary files /dev/null and b/android/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/android/res/mipmap-hdpi/ic_launcher_round.png b/android/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..d571a0a99235700882bde78ec8fa0fab78804763 Binary files /dev/null and b/android/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/res/mipmap-mdpi/ic_launcher.png b/android/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..72b8b9dd82c9739c145fbd12ec72c172164a316f Binary files /dev/null and b/android/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/res/mipmap-mdpi/ic_launcher_foreground.png b/android/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..88249782307ad4e3ad8343637380180cce86aa20 Binary files /dev/null and b/android/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/android/res/mipmap-mdpi/ic_launcher_round.png b/android/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..ab97cb2b44c00ee6ba1a935accb2be93bc623e9e Binary files /dev/null and b/android/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/res/mipmap-xhdpi/ic_launcher.png b/android/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..9e6592534e27643c7b11b7dfc98f00f776519f4f Binary files /dev/null and b/android/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..8841b4a1ef5b559d77dad138e212351d0fef2790 Binary files /dev/null and b/android/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/android/res/mipmap-xhdpi/ic_launcher_round.png b/android/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..6cb050557d5d6846c32045a12557a63adfdb2d9f Binary files /dev/null and b/android/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/res/mipmap-xxhdpi/ic_launcher.png b/android/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..7777f8cf91a11268d6235d69dc3751ffc56f37e3 Binary files /dev/null and b/android/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..0569148de2ae75106d4ac12b1ff85121602d3b45 Binary files /dev/null and b/android/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/res/mipmap-xxhdpi/ic_launcher_round.png b/android/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..24ff6ab2fe1c1c354a44c2ba3e3bfc1c5cc3b6c0 Binary files /dev/null and b/android/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/res/mipmap-xxxhdpi/ic_launcher.png b/android/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..caa2dcc8d238f3bbe7cb04aa3e49ca3e935c949c Binary files /dev/null and b/android/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..843d649ba22938c0bea4383da1283ad7603c213f Binary files /dev/null and b/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..b200e14e71c5ef7c7c8bdd5bfab13e48fb7dd2e7 Binary files /dev/null and b/android/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/core/src/body/Water.java b/core/src/body/Water.java index ddd9a8a1b09fb1f4968c69fc9ae351916d3ef5f0..35c9be0940ea6004e48abc3366c4b356b8455c36 100644 --- a/core/src/body/Water.java +++ b/core/src/body/Water.java @@ -19,14 +19,14 @@ public class Water { BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyDef.BodyType.StaticBody; - bodyDef.position.set(x, y); + bodyDef.position.set(x, y ); Body structBody = world.createBody(bodyDef); FixtureDef fixtureDefStruct = new FixtureDef(); shapeStruct = new PolygonShape(); - ptsStruct = new Vector2[]{new Vector2(0, 0), new Vector2(10/PPM, 0), new Vector2(10/PPM, 10/PPM), new Vector2(0, 10/PPM)}; + ptsStruct = new Vector2[]{new Vector2(0, 0/PPM), new Vector2(10/PPM, 0/PPM), new Vector2(10/PPM, 8/PPM), new Vector2(0, 8/PPM)}; shapeStruct.set(ptsStruct); fixtureDefStruct.shape = shapeStruct; diff --git a/core/src/com/mygdx/game/PlatVenture.java b/core/src/com/mygdx/game/PlatVenture.java index 768e58ea19b8f39997a63e271a0813e34f150aff..b76e8212176382c3abe3d1739fd19370d36b7848 100644 --- a/core/src/com/mygdx/game/PlatVenture.java +++ b/core/src/com/mygdx/game/PlatVenture.java @@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.ScreenUtils; + +import handlers.Content; import handlers.GameStateManager; import handlers.InputPerso; import handlers.InputProcessorPerso; @@ -26,10 +28,13 @@ public class PlatVenture extends ApplicationAdapter { private GameStateManager gsm; + public static Content res; + @Override public void create () { Gdx.input.setInputProcessor(new InputProcessorPerso()); batch = new SpriteBatch(); + res = new Content(); cam = new OrthographicCamera(); cam.setToOrtho(false, largeur, hauteur); hudCam = new OrthographicCamera(); diff --git a/core/src/etat/Play.java b/core/src/etat/Play.java index 8c4565e873cdef57152240e9a6ac4b19c2815070..60aec26979d8caa3bc83662d43d4338e1735e75f 100644 --- a/core/src/etat/Play.java +++ b/core/src/etat/Play.java @@ -36,6 +36,7 @@ public class Play extends GameState { private float totalTimeSinceAction = 0; private int level = 1; private boolean isChangingLevel = false; + private float timeDoubleTap = 0f; private Body player; @@ -55,25 +56,37 @@ public class Play extends GameState { b2dCam = new OrthographicCamera(); b2dCam.setToOrtho(false, PlatVenture.largeur /PPM, PlatVenture.hauteur/PPM); } - @Override + public void handleInput() { - if (InputPerso.isPressed(0)){ + if (InputPerso.isPressed(0)) { if (cl.isPlayerOnGround()) { - player.applyForceToCenter(0, 2 / PPM, true); + player.applyForceToCenter(0, 2f / PPM, true); } } - if (InputPerso.isDown(2)){ + if (InputPerso.isDown(2)) { if (cl.isPlayerOnGround()) { - player.setLinearVelocity(0.5f, player.getLinearVelocity().y); + player.setLinearVelocity(0.6f, player.getLinearVelocity().y); } } - if (InputPerso.isDown(1)){ + if (InputPerso.isDown(1)) { if (cl.isPlayerOnGround()) { - player.setLinearVelocity(-1*0.5f, player.getLinearVelocity().y); + player.setLinearVelocity(-1 * 0.6f, player.getLinearVelocity().y); } } + + if (InputPerso.isDown()) { + if (InputPerso.x <= Gdx.graphics.getWidth() / 2) { + if (cl.isPlayerOnGround()) { + player.setLinearVelocity(-1 * 0.6f, player.getLinearVelocity().y); + } + } else { + if (cl.isPlayerOnGround()) { + player.setLinearVelocity(0.6f, player.getLinearVelocity().y); + } + } + } } @Override @@ -94,8 +107,11 @@ public class Play extends GameState { if (!isInside()){ if (cl.isTriggerEndLevel()){ isChangingLevel = true; + cl.setTriggerEndLevel(false); }else{ - death(dt); + if (!isChangingLevel) { + death(dt); + } } } @@ -106,22 +122,25 @@ public class Play extends GameState { if (isChangingLevel){ changeLevel(dt); } - // Bouger la caméra en x - if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM <= (float) (PlatVenture.hauteur / 2) - && largeur > 16) { - b2dCam.position.set(player.getPosition().x, PlatVenture.hauteur/PPM / 2, 0); + + if (isInside()) { + // Bouger la caméra en x + if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM <= (float) (PlatVenture.hauteur / 2) + && largeur > 16) { + b2dCam.position.set(player.getPosition().x, PlatVenture.hauteur / PPM / 2, 0); } - // Bouger la caméra en x et y - if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2) - && largeur > 16 && hauteur > 12){ + // Bouger la caméra en x et y + if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2) + && largeur > 16 && hauteur > 12) { b2dCam.position.set(player.getPosition().x, player.getPosition().y, 0); } - //bouger la caméra en y - if ( player.getPosition().x * PPM < (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2) - && hauteur > 12) { + //bouger la caméra en y + if (player.getPosition().x * PPM < (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2) + && hauteur > 12) { - b2dCam.position.set(PlatVenture.largeur / PPM / 2, player.getPosition().y, 0); + b2dCam.position.set(PlatVenture.largeur / PPM / 2, player.getPosition().y, 0); + } } b2dCam.update(); @@ -205,14 +224,14 @@ public class Play extends GameState { FixtureDef body = new FixtureDef(); PolygonShape bodyShape = new PolygonShape(); - Vector2[] pts = new Vector2[]{new Vector2(0, (10/8)/PPM), new Vector2(2.5f/PPM, (30/8)/PPM), new Vector2(0, (70/8)/PPM), new Vector2(-2.5f/PPM, (30/8)/PPM)}; + Vector2[] pts = new Vector2[]{new Vector2(0, (10/8f)/PPM), new Vector2(2.5f/PPM, (30/8f)/PPM), new Vector2(0, (70/8f)/PPM), new Vector2(-2.5f/PPM, (30/8f)/PPM)}; bodyShape.set(pts); body.shape = bodyShape; player.createFixture(body).setUserData("body"); FixtureDef foot = new FixtureDef(); CircleShape footShape = new CircleShape(); - footShape.setRadius((10/8)/PPM); + footShape.setRadius((10/8f)/PPM); foot.shape = footShape; foot.density = 0.5f; @@ -230,7 +249,15 @@ public class Play extends GameState { private boolean isInside(){ boolean isinside = true; - if (player.getPosition().x < -5/PPM){ // Si la totalité du corps du joueur sort + if (player.getPosition().x < 0/PPM){ // Si la totalité du corps du joueur sort + isinside = false; + } + + if (player.getPosition().x > largeur / 10f) { + isinside = false; + } + + if (player.getPosition().y < 0){ isinside = false; } @@ -245,7 +272,7 @@ public class Play extends GameState { totalTimeSinceAction = 0; } else{ totalTimeSinceAction += dt; - player.setLinearVelocity(0, 0); + // player.setLinearVelocity(0, 0); } } @@ -266,7 +293,7 @@ public class Play extends GameState { level++; // Incrémente le level loadLevel(level); createPlayer(); - player.setLinearVelocity(0, 0); // annule la vitesse linéaire du personnage + //player.setLinearVelocity(0, 0); // annule la vitesse linéaire du personnage System.out.println("changing level"); isChangingLevel = false; diff --git a/core/src/handlers/Animation.java b/core/src/handlers/Animation.java new file mode 100644 index 0000000000000000000000000000000000000000..0ee148a50c8196cde11bef13f3039ad3f19aff25 --- /dev/null +++ b/core/src/handlers/Animation.java @@ -0,0 +1,54 @@ +package handlers; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +public class Animation { + private TextureRegion[] frames; + private float time; + private float delay; + private int currentFrame; + private int timesPlayed; + + public Animation(){} + + public Animation (TextureRegion[] frames){ + this(frames, 1/12f); + } + + public Animation(TextureRegion[] frames, float delay){ + setFrames(frames, delay); + } + + public void setFrames(TextureRegion[] frames, float delay){ + this.frames = frames; + this.delay = delay; + time = 0; + currentFrame = 0; + timesPlayed = 0; + } + + public void update(float dt){ + if (delay<=0) return; + time += dt; + while (time >= delay){ + step(); + } + } + + private void step(){ + time -= delay; + currentFrame++; + if (currentFrame == frames.length){ + currentFrame = 0; + timesPlayed++; + } + } + + public TextureRegion[] getFrames() { + return frames; + } + + public int getTimesPlayed() { + return timesPlayed; + } +} diff --git a/core/src/handlers/ContactListenerPerso.java b/core/src/handlers/ContactListenerPerso.java index bfeed3f7cfb0bb6cb9d043e2b1a619c7f2d26566..e72dbd5b15d5b197c680ddc84ce9e0011a68115d 100644 --- a/core/src/handlers/ContactListenerPerso.java +++ b/core/src/handlers/ContactListenerPerso.java @@ -49,6 +49,7 @@ public class ContactListenerPerso implements ContactListener { touchWater = false; } + } /** @@ -64,12 +65,9 @@ public class ContactListenerPerso implements ContactListener { numPlayerOnGround--; } - if (fa.getUserData() != null && fa.getUserData().equals("panneau") && fb.getUserData() != null && fb.getUserData().equals("body")){ + if ((fa.getUserData() != null && fa.getUserData().equals("panneau")) || (fb.getUserData() != null && fb.getUserData().equals("panneau"))){ triggerEndLevel = true; } - else{ - triggerEndLevel = false; - } } /** @@ -108,6 +106,10 @@ public class ContactListenerPerso implements ContactListener { return triggerEndLevel; } + public void setTriggerEndLevel(boolean v){ + triggerEndLevel = v; + } + public boolean isTouchWater() { return touchWater; } diff --git a/core/src/handlers/Content.java b/core/src/handlers/Content.java new file mode 100644 index 0000000000000000000000000000000000000000..b118a89818c5fb33365b81e1c695ff4129d0fad5 --- /dev/null +++ b/core/src/handlers/Content.java @@ -0,0 +1,31 @@ +package handlers; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Texture; + +import java.util.HashMap; + +public class Content { + private HashMap<String, Texture> textures; + + public Content(){ + textures = new HashMap<String, Texture>(); + } + + public void loadTexture(String path, String key){ + Texture tex = new Texture(Gdx.files.internal(path)); + textures.put(key, tex); + } + + + public Texture getTexture(String key){ + return textures.get(key); + } + + public void disposeTexture(String key){ + Texture tex = textures.get(key); + if (tex != null){ + tex.dispose(); + } + } +} diff --git a/core/src/handlers/InputPerso.java b/core/src/handlers/InputPerso.java index 7ffb00f457760b681dda92554f47f8c1c1c228a5..44d1ca7e1020e058025ad9fbb1ec0d99cbd76330 100644 --- a/core/src/handlers/InputPerso.java +++ b/core/src/handlers/InputPerso.java @@ -3,6 +3,11 @@ package handlers; public class InputPerso { public static boolean[] keys; public static boolean[] pkeys; + public static boolean down; + public static boolean pdown; + + public static int x; + public static int y; public static final int NUM_KEYS = 3; @@ -25,6 +30,7 @@ public class InputPerso { } public static void update(){ + pdown = down; for (int i = 0; i <NUM_KEYS; i++){ pkeys[i] = keys[i]; } @@ -46,4 +52,8 @@ public class InputPerso { public static boolean isPressed(int i){ return keys[i] && !pkeys[i]; } + + public static boolean isDown() { return down; } + public static boolean isPressed() { return down && !pdown; } + public static boolean isReleased() { return !down && pdown; } } diff --git a/core/src/handlers/InputProcessorPerso.java b/core/src/handlers/InputProcessorPerso.java index 37c884681cb7e4ff9ff2188d521008cd710b5245..39881088d68b375eb683841b4db6719341640a48 100644 --- a/core/src/handlers/InputProcessorPerso.java +++ b/core/src/handlers/InputProcessorPerso.java @@ -5,7 +5,28 @@ import com.badlogic.gdx.InputAdapter; public class InputProcessorPerso extends InputAdapter { - @Override + public boolean touchDragged(int x, int y, int pointer) { + InputPerso.x = x; + InputPerso.y = y; + InputPerso.down = true; + return true; + } + + public boolean touchDown(int x, int y, int pointer, int button) { + InputPerso.x = x; + InputPerso.y = y; + InputPerso.down = true; + return true; + } + + public boolean touchUp(int x, int y, int pointer, int button) { + InputPerso.x = x; + InputPerso.y = y; + InputPerso.down = false; + return true; + } + + @Override public boolean keyDown(int k){ if (k == Input.Keys.UP){ InputPerso.setKey(InputPerso.BUTTON1, true);