add die
This commit is contained in:
parent
1dfc2b50b1
commit
8e6527afa0
5 changed files with 100 additions and 6 deletions
9
core/src/com/monjaro/gamejam/Actor.java
Normal file
9
core/src/com/monjaro/gamejam/Actor.java
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package com.monjaro.gamejam;
|
||||||
|
|
||||||
|
public abstract class Actor {
|
||||||
|
|
||||||
|
public abstract void tick();
|
||||||
|
|
||||||
|
public abstract void render();
|
||||||
|
|
||||||
|
}
|
29
core/src/com/monjaro/gamejam/Die.java
Normal file
29
core/src/com/monjaro/gamejam/Die.java
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package com.monjaro.gamejam;
|
||||||
|
|
||||||
|
public class Die extends Actor {
|
||||||
|
|
||||||
|
/*
|
||||||
|
0
|
||||||
|
1 2 3 4
|
||||||
|
5
|
||||||
|
*/
|
||||||
|
private Face[] faces = new Face[6];
|
||||||
|
|
||||||
|
public Die() {
|
||||||
|
int[] pips = {4, 6, 5, 1, 2, 3};
|
||||||
|
for (int i = 0; i < faces.length; i++) {
|
||||||
|
faces[i] = new Face(pips[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
core/src/com/monjaro/gamejam/Face.java
Normal file
38
core/src/com/monjaro/gamejam/Face.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package com.monjaro.gamejam;
|
||||||
|
|
||||||
|
public class Face {
|
||||||
|
|
||||||
|
private int pips;
|
||||||
|
|
||||||
|
public Face(int pips) {
|
||||||
|
this.pips = pips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPips() {
|
||||||
|
return pips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPips(int pips) {
|
||||||
|
this.pips = pips;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Pip {
|
||||||
|
|
||||||
|
private final double x, y;
|
||||||
|
|
||||||
|
public Pip(double x, double y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,22 +1,37 @@
|
||||||
package com.monjaro.gamejam;
|
package com.monjaro.gamejam;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationAdapter;
|
import com.badlogic.gdx.ApplicationAdapter;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.utils.ScreenUtils;
|
import com.badlogic.gdx.utils.ScreenUtils;
|
||||||
|
|
||||||
public class Game extends ApplicationAdapter {
|
public class Game extends ApplicationAdapter {
|
||||||
SpriteBatch batch;
|
|
||||||
Texture img;
|
private SpriteBatch batch;
|
||||||
|
private Texture img;
|
||||||
|
|
||||||
|
private static int TICKS_PER_SECOND;
|
||||||
|
private double tickProgress = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create () {
|
public void create() {
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
img = new Texture("badlogic.jpg");
|
img = new Texture("badlogic.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void tick() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render () {
|
public void render() {
|
||||||
|
Gdx.graphics.getDeltaTime();
|
||||||
|
while (tickProgress >= 1) { //tick as many times as needed
|
||||||
|
tick();
|
||||||
|
tickProgress--;
|
||||||
|
}
|
||||||
|
|
||||||
ScreenUtils.clear(1, 0, 0, 1);
|
ScreenUtils.clear(1, 0, 0, 1);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
batch.draw(img, 0, 0);
|
batch.draw(img, 0, 0);
|
||||||
|
@ -24,8 +39,9 @@ public class Game extends ApplicationAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose () {
|
public void dispose() {
|
||||||
batch.dispose();
|
batch.dispose();
|
||||||
img.dispose();
|
img.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,12 @@ import com.monjaro.gamejam.Game;
|
||||||
|
|
||||||
// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument
|
// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument
|
||||||
public class DesktopLauncher {
|
public class DesktopLauncher {
|
||||||
|
|
||||||
public static void main (String[] arg) {
|
public static void main (String[] arg) {
|
||||||
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
|
||||||
config.setForegroundFPS(60);
|
config.setForegroundFPS(60);
|
||||||
config.setTitle("GameJam");
|
config.setTitle("GameJam");
|
||||||
new Lwjgl3Application(new Game(), config);
|
new Lwjgl3Application(new Game(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue