diff --git a/assets/blank_die_face.png b/assets/blank_die_face.png index da758a2..47ff40e 100644 Binary files a/assets/blank_die_face.png and b/assets/blank_die_face.png differ diff --git a/assets/pip.png b/assets/pip.png index e25facf..de1c019 100644 Binary files a/assets/pip.png and b/assets/pip.png differ diff --git a/assets/raw_assets/.pip.kra-autosave.kra b/assets/raw_assets/.pip.kra-autosave.kra deleted file mode 100644 index 6fd379f..0000000 Binary files a/assets/raw_assets/.pip.kra-autosave.kra and /dev/null differ diff --git a/assets/raw_assets/blank_die_face.kra b/assets/raw_assets/blank_die_face.kra index f7cc0a7..419d532 100644 Binary files a/assets/raw_assets/blank_die_face.kra and b/assets/raw_assets/blank_die_face.kra differ diff --git a/assets/raw_assets/pip.kra b/assets/raw_assets/pip.kra index ed7a48c..b32f25e 100644 Binary files a/assets/raw_assets/pip.kra and b/assets/raw_assets/pip.kra differ diff --git a/core/src/com/monjaro/gamejam/Die.java b/core/src/com/monjaro/gamejam/Die.java index b9af9e0..a2cf27c 100644 --- a/core/src/com/monjaro/gamejam/Die.java +++ b/core/src/com/monjaro/gamejam/Die.java @@ -1,14 +1,13 @@ package com.monjaro.gamejam; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.math.Rectangle; - import java.util.List; import java.util.Random; public class Die extends Actor { - private final Rectangle shape; + private Transform transform; /* 0 @@ -19,26 +18,27 @@ public class Die extends Actor { private int faceIndex = 3; private boolean locked = false; + private static Texture lockedSprite; + private final Random random = new Random(); //TODO use central random + public Die(float x, float y, float width, float height) { + transform = new Transform(x, y, width, height); + int[] pips = {4, 6, 5, 1, 2, 3}; for (int i = 0; i < faces.length; i++) { - faces[i] = new Face(pips[i]); - faces[i].setPosition(x, y); - faces[i].setSize(width, height); + faces[i] = new Face(pips[i], transform); } - shape = new Rectangle(x, y, width, height); - } public void setPosition(float x, float y){ - shape.setX(x); - shape.setY(y); + transform.setX(x); + transform.setY(y); } public void setSize(float w, float h){ - shape.setSize(w, h); + transform.setSize(w, h); } @Override @@ -55,6 +55,10 @@ public class Die extends Actor { faceIndex = random.nextInt(6); } + public static void setLockedSprite(Texture sprite){ + lockedSprite = sprite; + } + public void decay() { //remove a pip from all faces of this die for (Face face : faces) { List pips = face.getPips(); @@ -80,6 +84,18 @@ public class Die extends Actor { } public void setLocked(boolean locked) { + if (locked != this.locked) + { + if (locked) { + transform.y += 64; + transform.rotation = 20; + } + else{ + transform.y -= 64; + transform.rotation = 0; + } + } // terrible + this.locked = locked; } diff --git a/core/src/com/monjaro/gamejam/Face.java b/core/src/com/monjaro/gamejam/Face.java index 4261db3..457199c 100644 --- a/core/src/com/monjaro/gamejam/Face.java +++ b/core/src/com/monjaro/gamejam/Face.java @@ -1,6 +1,7 @@ package com.monjaro.gamejam; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; @@ -12,23 +13,23 @@ import java.util.Random; public class Face extends Actor{ - private final Rectangle shape = new Rectangle(); + private Transform transform; private final List pips = new ArrayList<>(); private static Texture blankFaceSprite; private static Texture pipSprite; - - public Face(int pipCount) { + public Face(int pipCount, Transform transform) { addPipsForValue(pipCount); + this.transform = transform; } private void addPipsForValue(int value){ - int[][] positions = {{25, 25}, {75, 75}, {25, 75}, {75, 25}, {25, 50}, {75, 50}}; + int[][] positions = {{-25, -25}, {25, 25}, {-25, 25}, {25, -25}, {-25, 0}, {25, 0}}; if (value % 2 == 1) { - pips.add(new Pip(50, 50)); + pips.add(new Pip(0, 0)); value--; } @@ -72,12 +73,12 @@ public class Face extends Actor{ } public void setPosition(float x, float y){ - shape.setX(x); - shape.setY(y); + transform.setX(x); + transform.setY(y); } public void setSize(float w, float h){ - shape.setSize(w, h); + transform.setSize(w, h); } public static void setBlankFaceSprite(Texture sprite){ @@ -88,13 +89,15 @@ public class Face extends Actor{ pipSprite = sprite; } - public Vector2 getPipLocationFromPercentage(Vector2 percentages) - { - Vector2 position = new Vector2( - shape.x + (shape.width*percentages.x/100f) - (float)pipSprite.getWidth()/2, - shape.y + shape.width*percentages.y/100f - (float)pipSprite.getHeight()/2); + public Vector2 calculatePipLocation(Vector2 percentages) { + double radians = Math.toRadians(transform.rotation); - return position; + float x = (float) (percentages.x * Math.cos(radians) - percentages.y * Math.sin(radians)); + float y = (float) (percentages.x * Math.sin(radians) + percentages.y * Math.cos(radians)); + + return new Vector2( + transform.x + transform.width*x/100f - (float)pipSprite.getWidth()/2, + transform.y + transform.height*y/100f - (float)pipSprite.getHeight()/2); } @Override @@ -104,9 +107,14 @@ public class Face extends Actor{ @Override public void render(SpriteBatch batch) { - batch.draw(blankFaceSprite, shape.x, shape.y, shape.width, shape.height); + Sprite face = new Sprite(blankFaceSprite); + face.setOrigin(face.getWidth()/2, face.getHeight()/2); + face.rotate(transform.getRotation()); + face.setPosition(transform.x-face.getWidth()/2, transform.y-face.getHeight()/2); + face.draw(batch); + for(Pip pip : pips){ - Vector2 position = getPipLocationFromPercentage(pip.getVectorLocation()); + Vector2 position = calculatePipLocation(pip.getVectorLocation()); batch.draw(pipSprite, position.x, position.y); diff --git a/core/src/com/monjaro/gamejam/Game.java b/core/src/com/monjaro/gamejam/Game.java index d83d1d5..fb1b526 100644 --- a/core/src/com/monjaro/gamejam/Game.java +++ b/core/src/com/monjaro/gamejam/Game.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.ScreenUtils; import com.monjaro.gamejam.segment.DualSegment; import com.monjaro.gamejam.segment.KinSegment; @@ -39,9 +40,12 @@ public class Game extends ApplicationAdapter { Face.setBlankFaceSprite(new Texture("blank_die_face.png")); Face.setPipSprite(new Texture("pip.png")); + Die.setLockedSprite(new Texture("locked_die_border.png")); - for (int i = 1; i <= 5; i++) { - dice.add(new Die((i*80), 20, 64, 64)); + Vector2 dieSize = new Vector2(); + float divide = Gdx.graphics.getWidth() / 6f; + for (int i = 0; i < 5; i++) { + dice.add(new Die(divide * (i + 1), 350, 64, 64)); } for (int i = 1; i <= 5; i++) { diff --git a/core/src/com/monjaro/gamejam/Transform.java b/core/src/com/monjaro/gamejam/Transform.java new file mode 100644 index 0000000..10f8da2 --- /dev/null +++ b/core/src/com/monjaro/gamejam/Transform.java @@ -0,0 +1,23 @@ +package com.monjaro.gamejam; + +import com.badlogic.gdx.math.Rectangle; + +public class Transform extends Rectangle { + float rotation; + + public Transform(float x, float y, float width, float height){ + super(x, y, width, height); + } + + public Transform(){ + super(); + } + + public float getRotation() { + return rotation; + } + + public void setRotation(float rotation) { + this.rotation = rotation; + } +} diff --git a/desktop/src/com/monjaro/gamejam/DesktopLauncher.java b/desktop/src/com/monjaro/gamejam/DesktopLauncher.java index 628e91e..52e5074 100644 --- a/desktop/src/com/monjaro/gamejam/DesktopLauncher.java +++ b/desktop/src/com/monjaro/gamejam/DesktopLauncher.java @@ -11,7 +11,7 @@ public class DesktopLauncher { Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setForegroundFPS(60); config.setTitle("GameJam"); - config.setWindowedMode(800, 480); + config.setWindowedMode(480, 800); config.setResizable(false); new Lwjgl3Application(new Game(), config); }