Sample LibGDX project setup

main
Jonah Bauer 3 years ago
parent 1b720033d9
commit 120efe098c

@ -5,6 +5,7 @@
rootProject.name = 'wizard' rootProject.name = 'wizard'
include(':wizard-common') include(':wizard-common')
include(':wizard-client:wizard-client-cli') include(':wizard-client:wizard-client-cli')
include(':wizard-client:wizard-client-libgdx') include(':wizard-client:wizard-client-libgdx:core')
include(':wizard-client:wizard-client-libgdx:desktop')
include(':wizard-server') include(':wizard-server')
include(':wizard-core') include(':wizard-core')

@ -0,0 +1,30 @@
subprojects {
ext {
gdxVersion = '1.10.0'
roboVMVersion = '2.3.12'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.3'
aiVersion = '1.8.2'
gdxControllersVersion = '2.1.0'
}
}
project(":wizard-client:wizard-client-libgdx:desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":wizard-client:wizard-client-libgdx:core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
}
}
project(":wizard-client:wizard-client-libgdx:core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}

@ -0,0 +1 @@
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

@ -0,0 +1,31 @@
package eu.jonahbauer.wizard.client.libgdx;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.ScreenUtils;
public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render () {
ScreenUtils.clear(1, 0, 0, 1);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
@Override
public void dispose () {
batch.dispose();
img.dispose();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

@ -0,0 +1,14 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GroovyAccessibility
ext {
javaMainClass = "eu.jonahbauer.wizard.client.libgdx.desktop.DesktopLauncher"
assetsDir = new File("../core/src/main/resources")
}
task run(type: JavaExec, dependsOn: classes) {
mainClass = javaMainClass
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue true
}

@ -0,0 +1,12 @@
package eu.jonahbauer.wizard.client.libgdx.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import eu.jonahbauer.wizard.client.libgdx.MyGdxGame;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new MyGdxGame(), config);
}
}
Loading…
Cancel
Save