From a6d00660eef22b13e53558f82dde1a951b435374 Mon Sep 17 00:00:00 2001 From: ImTallone <39484479+CristeaAndreiFlavian@users.noreply.github.com> Date: Thu, 6 Sep 2018 20:45:25 +0300 Subject: [PATCH] Initial Commit --- .classpath | 11 +++++ .project | 17 ++++++++ .settings/org.eclipse.jdt.core.prefs | 12 ++++++ .../powerhigh/addon/window/WindowUtils.java | 43 +++++++++++++++++++ .../org/powerhigh/addon/window/AddonTest.java | 26 +++++++++++ 5 files changed, 109 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 src/org/powerhigh/addon/window/WindowUtils.java create mode 100644 src/test/org/powerhigh/addon/window/AddonTest.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..5f62380 --- /dev/null +++ b/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..c6830c2 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + PowerHighWindow + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..021167a --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/src/org/powerhigh/addon/window/WindowUtils.java b/src/org/powerhigh/addon/window/WindowUtils.java new file mode 100644 index 0000000..5d15aa4 --- /dev/null +++ b/src/org/powerhigh/addon/window/WindowUtils.java @@ -0,0 +1,43 @@ +package org.powerhigh.addon.window; + +import java.awt.Color; +import java.awt.Image; +import org.lggl.SizedViewport; +import org.lggl.game.SimpleGame; +import org.lggl.graphics.Window; +import org.lggl.utils.debug.DebugLogger; + +public class WindowUtils { + + public static void launchDebug(SimpleGame game, boolean isLaunchDebugEnabled) { + game.enableLaunchDebug = isLaunchDebugEnabled; + } + + public static void setWindowIcon(Window win, Image icon) { + win.setIcon(icon); + } + + public static void createWindow(Window win, Color bgc, boolean isWindowVisible, boolean isViewportManagerEnabled, boolean isWindowResizable, int WIDTH, int HEIGHT, String TITLE) { + win.setVisible(isWindowVisible); + win.setSize(WIDTH, HEIGHT); + win.setBackground(bgc); + win.setResizable(isWindowResizable); + win.setTitle(TITLE); + if (isViewportManagerEnabled == true) { + win.setViewportManager(new SizedViewport(WIDTH, HEIGHT)); + } + } + + public static void updateWindow(Window win, boolean debugCountedFPS, boolean isViewportEnabled, int WIDTH, int HEIGHT) { + if (win.isClosed()) { + System.exit(0); + } + if (debugCountedFPS == true) { + System.out.println("FPS: " + win.getFPS()); + } + if (isViewportEnabled == true) { + win.setViewport(0, 0, WIDTH, HEIGHT); + } + } + +} \ No newline at end of file diff --git a/src/test/org/powerhigh/addon/window/AddonTest.java b/src/test/org/powerhigh/addon/window/AddonTest.java new file mode 100644 index 0000000..18654ac --- /dev/null +++ b/src/test/org/powerhigh/addon/window/AddonTest.java @@ -0,0 +1,26 @@ +package test.org.powerhigh.addon.window; + +import org.powerhigh.addon.window.WindowUtils; + +import java.awt.Color; + +import org.lggl.game.SimpleGame; +import org.lggl.graphics.Window; + +public class AddonTest extends SimpleGame { + + public static void main(String[] args) { + new AddonTest().start(); + } + + @Override + public void init(Window win) { + WindowUtils.createWindow(win, Color.BLUE, true, true, true, 800, 600, "Addon Test"); + } + + @Override + public void update(Window win, double delta) { + WindowUtils.updateWindow(win, true, false, 800, 600); + } + +}