Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions gdx2d-demoDesktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl3</artifactId>
<version>${libgdx.version}</version>
</dependency>

<!-- For Swing integration with LWJGL2 -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<version>${libgdx.version}</version>
</dependency>

<!-- For LWJGL2 natives required for Swing integration -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>${libgdx.version}</version>
<classifier>natives-desktop</classifier>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.hevs.gdx2d.demos.controllers
import ch.hevs.gdx2d.components.bitmaps.BitmapImage
import com.badlogic.gdx.controllers.Controller
import com.badlogic.gdx.controllers.Controllers
import com.badlogic.gdx.controllers.PovDirection

import ch.hevs.gdx2d.desktop.PortableApplication
import ch.hevs.gdx2d.desktop.Xbox
Expand Down Expand Up @@ -135,8 +134,8 @@ class DemoControllers : PortableApplication(700, 700, false) {
rightSickVal.y = value
}

override fun onControllerPovMoved(controller: Controller, povCode: Int, value: PovDirection) {
Logger.log(TAG, "POV: $value")
override fun onControllerPovMoved(controller: Controller, povCode: Int, value: Int) {
Logger.log(TAG, "POV direction value: $value")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DemoTileAdvanced : PortableApplication() {

// Camera follows the hero
g.zoom(zoom)
g.moveCamera(hero.position.x, hero.position.y, tiledLayer.width * tiledLayer.tileWidth, tiledLayer.height * tiledLayer.tileHeight)
g.moveCamera(hero.position.x.toFloat(), hero.position.y.toFloat(), (tiledLayer.width * tiledLayer.tileWidth).toFloat(), (tiledLayer.height * tiledLayer.tileHeight).toFloat())

// Render the tilemap
tiledMapRenderer.setView(g.camera)
Expand Down
13 changes: 13 additions & 0 deletions gdx2d-helloDesktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl3</artifactId>
<version>${libgdx.version}</version>
</dependency>

<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>${libgdx.version}</version>
<classifier>natives-desktop</classifier>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 2 additions & 1 deletion gdx2d-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ The `gdx2d-core` dependencies are:

The `gdx2d-desktop` dependencies are:

* `com.badlogicgames.gdx:gdx-backend-lwjgl:${libgdx.version}`
* `com.badlogicgames.gdx:gdx-backend-lwjgl3:${libgdx.version}`
* `com.badlogicgames.gdx:gdx-platform:${libgdx.version}`
* `com.badlogicgames.gdx:gdx-box2d-platform:${libgdx.version}`
* `com.badlogicgames.gdx:gdx-freetype-platform:${libgdx.version}`
* `com.badlogicgames.gdx:gdx-backend-lwjgl:${libgdx.version}` (for Swing integration)

## Library resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,16 @@ private void cameraUpdated() {
shapeRenderer.setProjectionMatrix(camera.combined);
}

/**
* Set a new camera for rendering.
*
* @param camera the new camera to use
*/
public void setCamera(OrthographicCamera camera) {
this.camera = camera;
cameraUpdated();
}

/**
* Draw the current assigned shader.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
public class Version {

/** Copyright and authors information. */
public final static String COPY = "mui, chn, mei, pim (c) 2012-2016";
public final static String COPY = "mui, chn, mei, pim (c) 2012-2025";

/**
* Current version name of the gdx2d library (major.minor.revision).
*/
public final static String VERSION = "1.2.2";
public final static String VERSION = "1.2.3";

/**
* Indicates if it is a debug or release version.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.hevs.gdx2d.lib.interfaces;

import com.badlogic.gdx.controllers.Controller;
import com.badlogic.gdx.controllers.PovDirection;
import com.badlogic.gdx.math.Vector3;

/**
Expand Down Expand Up @@ -73,9 +72,9 @@ public interface ControllersInterface {
*
* @param controller the corresponding controller
* @param povCode the POV code
* @param value the POV direction
* @param value the POV direction as an integer (removed PovDirection enum for compatibility)
*/
void onControllerPovMoved(Controller controller, int povCode, PovDirection value);
void onControllerPovMoved(Controller controller, int povCode, int value);

/**
* An x-slider on the {@link Controller} moved.
Expand Down
24 changes: 12 additions & 12 deletions gdx2d-library/gdx2d-desktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,43 @@

<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<artifactId>gdx-backend-lwjgl3</artifactId>
<version>${libgdx.version}</version>
</dependency>

<!-- Default desktop natives -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>${libgdx.version}</version>
<classifier>natives-desktop</classifier>
</dependency>


<!-- Box2D extension -->
<dependency>
<!-- Box2D extension -->
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-box2d-platform</artifactId>
<classifier>natives-desktop</classifier>
<version>${libgdx.version}</version>
</dependency>


<!-- Box2DLights extension -->
<dependency>
<!-- Box2DLights extension -->
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype-platform</artifactId>
<version>${libgdx.version}</version>
<classifier>natives-desktop</classifier>
</dependency>

<dependency>
<!-- Controllers extension -->
<groupId>com.badlogicgames.gdx</groupId>
<groupId>com.badlogicgames.gdx-controllers</groupId>
<artifactId>gdx-controllers-desktop</artifactId>
<version>${libgdx.version}</version>
</dependency>
<dependency>
<!-- Controllers extension -->
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-controllers-platform</artifactId>
<version>${libgdx.version}</version>
<classifier>natives-desktop</classifier>
<version>2.2.2</version>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.utils.GdxNativesLoader;

import ch.hevs.gdx2d.lib.GdxGraphics;
import ch.hevs.gdx2d.lib.Version;
Expand All @@ -32,12 +31,6 @@ public class Game2D implements ApplicationListener {

public static GdxGraphics g;

// Force to load native libraries (for Android Proguard)
// FIXME Is this really required?
static {
GdxNativesLoader.load();
}

public OrthographicCamera camera;
protected PortableApplication app;
protected ShapeRenderer shapeRenderer;
Expand Down Expand Up @@ -96,6 +89,10 @@ public void render() {
* Called when the screen has been resized.
*/
public void resize(int width, int height) {
// Update camera when window is resized
camera.setToOrtho(false, width, height);
camera.update();
//g.setCamera(camera);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,70 @@
package ch.hevs.gdx2d.desktop;

import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;

/**
* Default configuration for {@code gdx2d} applications running on desktop.
*
* @author Pierre-André Mudry (mui)
* @version 1.1
*/
public class GdxConfig {

// FIXME: only used for desktop applications, must not be included in the library project
/**
* Get LWJGL configuration with default settings (500x500 window)
*
* @return LWJGL application configuration
*/
public static Lwjgl3ApplicationConfiguration getLwjglConfig() {
return getLwjglConfig(500, 500, false);
}

static public LwjglApplicationConfiguration getLwjglConfig(int width, int height, boolean fullScreen) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = false;
config.useGL30 = false;
config.height = height;
config.width = width;
config.fullscreen = fullScreen;
config.title = "Gdx2d desktop application";
config.vSyncEnabled = true; // Ignored under Linux
config.foregroundFPS = 60; // Target value if vSync not working
config.backgroundFPS = config.foregroundFPS;
config.samples = 3; // Multi-sampling enables anti-alias for lines
config.forceExit = false; // Setting true calls system.exit(), with no coming back
/**
* Get LWJGL configuration
* <p/>
* Default resolution available for the windowed mode:
* <ul>
* <li>640 * 480 (4:3)
* <li>800 * 600 (4:3)
* <li>1024 * 768 (4:3)
* <li>1280 * 720 (16:9)
* <li>1366 * 768 (16:9)
* <li>1600 * 900 (16:9)
* <li>1920 * 1080 (16:9)
* </ul>
*
* @param width Window width
* @param height Window height
* @param fullScreen Create a fullscreen window
* @return The configuration for LWJGL
*/
public static Lwjgl3ApplicationConfiguration getLwjglConfig(int width, int height, boolean fullScreen) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setResizable(false);
config.useVsync(true);
config.setTitle("Gdx2d desktop application");

final String os = System.getProperty("os.name").toLowerCase();
// Set window size
config.setWindowedMode(width, height);

// Under windows, the icon *must* be the small one
if (os.contains("win")) {
config.addIcon("res/lib/icon16.png", Files.FileType.Internal);
}
if (fullScreen) {
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode());
}

config.addIcon("res/lib/icon32.png", Files.FileType.Internal);
config.addIcon("res/lib/icon64.png", Files.FileType.Internal);
// Set up initial background color to black
config.setInitialBackgroundColor(Color.BLACK);

return config;
}
// 4 samples for multi-sampling enables anti-alias for lines
config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 4);

}
// Use OpenGL 2.0 for compatibility (major=2, minor=0)
config.setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.GL20, 2, 0);

// Set window icons
config.setWindowIcon("res/lib/icon16.png", "res/lib/icon32.png", "res/lib/icon64.png");

return config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,29 @@ public boolean axisMoved(Controller controller, int axisCode, float value) {
return false;
}

@Override
public boolean povMoved(Controller controller, int povCode, PovDirection value) {
// PovDirection was removed in gdx-controllers 2.x, replaced with direct button handling
// This method no longer exists in the API
public boolean povMoved(Controller controller, int povCode, int value) {
app.onControllerPovMoved(controller, povCode, value);
return false;
}

@Override
// Methods below no longer exist in the gdx-controllers 2.x API
// Kept for compatibility with old code but no longer called

// No longer in the API
public boolean xSliderMoved(Controller controller, int sliderCode, boolean value) {
app.onControllerXSliderMoved(controller, sliderCode, value);
return false;
}

@Override
// No longer in the API
public boolean ySliderMoved(Controller controller, int sliderCode, boolean value) {
app.onControllerYSliderMoved(controller, sliderCode, value);
return false;
}

@Override
// No longer in the API
public boolean accelerometerMoved(Controller controller, int accelerometerCode, Vector3 value) {
app.onControllerAccelerometerMoved(controller, accelerometerCode, value);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) {
}

@Override
public boolean scrolled(int amount) {
app.onScroll(amount);
public boolean scrolled(float amountX, float amountY) {
app.onScroll((int)amountY); // Convert to int for backwards compatibility
return false;
}

Expand Down
Loading