summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromangraef <roman.graef@gmail.com>2018-05-30 12:06:31 +0200
committerromangraef <roman.graef@gmail.com>2018-05-30 12:06:31 +0200
commit2ac18d91635b023db7ff3918f5041cb51ed1c968 (patch)
tree8caffe3c5807e105eb474e2277ece57dc82823c3
downloadpluggabledino-2ac18d91635b023db7ff3918f5041cb51ed1c968.tar.gz
pluggabledino-2ac18d91635b023db7ff3918f5041cb51ed1c968.tar.bz2
pluggabledino-2ac18d91635b023db7ff3918f5041cb51ed1c968.zip
Initial commit
-rw-r--r--.editorconfig0
-rw-r--r--.gitignore5
-rw-r--r--.gradle/4.3.1/fileChanges/last-build.binbin0 -> 1 bytes
-rw-r--r--.gradle/4.3.1/fileContent/fileContent.lockbin0 -> 17 bytes
-rw-r--r--.gradle/4.3.1/fileHashes/fileHashes.binbin0 -> 21847 bytes
-rw-r--r--.gradle/4.3.1/fileHashes/fileHashes.lockbin0 -> 17 bytes
-rw-r--r--.gradle/4.3.1/fileHashes/resourceHashesCache.binbin0 -> 19177 bytes
-rw-r--r--.gradle/4.3.1/taskHistory/taskHistory.binbin0 -> 50091 bytes
-rw-r--r--.gradle/4.3.1/taskHistory/taskHistory.lockbin0 -> 17 bytes
-rw-r--r--.gradle/4.4/fileChanges/last-build.binbin0 -> 1 bytes
-rw-r--r--.gradle/4.4/fileContent/fileContent.lockbin0 -> 17 bytes
-rw-r--r--.gradle/4.4/fileHashes/fileHashes.binbin0 -> 23547 bytes
-rw-r--r--.gradle/4.4/fileHashes/fileHashes.lockbin0 -> 17 bytes
-rw-r--r--.gradle/4.4/fileHashes/resourceHashesCache.binbin0 -> 19381 bytes
-rw-r--r--.gradle/4.4/taskHistory/taskHistory.binbin0 -> 106499 bytes
-rw-r--r--.gradle/4.4/taskHistory/taskHistory.lockbin0 -> 17 bytes
-rw-r--r--.gradle/buildOutputCleanup/buildOutputCleanup.lockbin0 -> 17 bytes
-rw-r--r--.gradle/buildOutputCleanup/cache.properties2
-rw-r--r--.gradle/buildOutputCleanup/outputFiles.binbin0 -> 18983 bytes
-rw-r--r--build.gradle69
-rw-r--r--gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xgradlew172
-rw-r--r--gradlew.bat84
-rw-r--r--settings.gradle3
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt65
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Dependency.kt3
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/DependencyMissing.kt4
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Event.kt3
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/EventHandler.kt5
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Events.kt15
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/IPlugin.kt5
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Inject.kt5
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/InjectException.kt3
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/PluginFolderNotFound.kt3
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/PluginLoader.kt76
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/PluginMeta.kt5
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/assets.kt28
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/events/InitEvent.kt5
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/events/PostInitEvent.kt5
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/events/PreInitEvent.kt6
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt109
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/main.kt49
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt45
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt52
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt42
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt41
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/util.kt23
-rw-r--r--src/main/resources/images/button.pngbin0 -> 283 bytes
-rw-r--r--src/main/resources/images/cactus.pngbin0 -> 201 bytes
-rw-r--r--src/main/resources/images/characters.pngbin0 -> 1138 bytes
-rw-r--r--src/main/resources/images/groundline.pngbin0 -> 239 bytes
-rw-r--r--src/main/resources/images/splash.pngbin0 -> 14192 bytes
52 files changed, 938 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.editorconfig
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0e7936b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+assets/
+build/
+out/
+pluggablelogging/
+plugins/
diff --git a/.gradle/4.3.1/fileChanges/last-build.bin b/.gradle/4.3.1/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
--- /dev/null
+++ b/.gradle/4.3.1/fileChanges/last-build.bin
Binary files differ
diff --git a/.gradle/4.3.1/fileContent/fileContent.lock b/.gradle/4.3.1/fileContent/fileContent.lock
new file mode 100644
index 0000000..9bd0f9b
--- /dev/null
+++ b/.gradle/4.3.1/fileContent/fileContent.lock
Binary files differ
diff --git a/.gradle/4.3.1/fileHashes/fileHashes.bin b/.gradle/4.3.1/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..e2df64d
--- /dev/null
+++ b/.gradle/4.3.1/fileHashes/fileHashes.bin
Binary files differ
diff --git a/.gradle/4.3.1/fileHashes/fileHashes.lock b/.gradle/4.3.1/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..412b1fc
--- /dev/null
+++ b/.gradle/4.3.1/fileHashes/fileHashes.lock
Binary files differ
diff --git a/.gradle/4.3.1/fileHashes/resourceHashesCache.bin b/.gradle/4.3.1/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..e5c7218
--- /dev/null
+++ b/.gradle/4.3.1/fileHashes/resourceHashesCache.bin
Binary files differ
diff --git a/.gradle/4.3.1/taskHistory/taskHistory.bin b/.gradle/4.3.1/taskHistory/taskHistory.bin
new file mode 100644
index 0000000..9141d5b
--- /dev/null
+++ b/.gradle/4.3.1/taskHistory/taskHistory.bin
Binary files differ
diff --git a/.gradle/4.3.1/taskHistory/taskHistory.lock b/.gradle/4.3.1/taskHistory/taskHistory.lock
new file mode 100644
index 0000000..4249219
--- /dev/null
+++ b/.gradle/4.3.1/taskHistory/taskHistory.lock
Binary files differ
diff --git a/.gradle/4.4/fileChanges/last-build.bin b/.gradle/4.4/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
--- /dev/null
+++ b/.gradle/4.4/fileChanges/last-build.bin
Binary files differ
diff --git a/.gradle/4.4/fileContent/fileContent.lock b/.gradle/4.4/fileContent/fileContent.lock
new file mode 100644
index 0000000..77f2559
--- /dev/null
+++ b/.gradle/4.4/fileContent/fileContent.lock
Binary files differ
diff --git a/.gradle/4.4/fileHashes/fileHashes.bin b/.gradle/4.4/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..f7cf6ef
--- /dev/null
+++ b/.gradle/4.4/fileHashes/fileHashes.bin
Binary files differ
diff --git a/.gradle/4.4/fileHashes/fileHashes.lock b/.gradle/4.4/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..ef5b83e
--- /dev/null
+++ b/.gradle/4.4/fileHashes/fileHashes.lock
Binary files differ
diff --git a/.gradle/4.4/fileHashes/resourceHashesCache.bin b/.gradle/4.4/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..2f7ee1f
--- /dev/null
+++ b/.gradle/4.4/fileHashes/resourceHashesCache.bin
Binary files differ
diff --git a/.gradle/4.4/taskHistory/taskHistory.bin b/.gradle/4.4/taskHistory/taskHistory.bin
new file mode 100644
index 0000000..b0aa556
--- /dev/null
+++ b/.gradle/4.4/taskHistory/taskHistory.bin
Binary files differ
diff --git a/.gradle/4.4/taskHistory/taskHistory.lock b/.gradle/4.4/taskHistory/taskHistory.lock
new file mode 100644
index 0000000..f18d4ce
--- /dev/null
+++ b/.gradle/4.4/taskHistory/taskHistory.lock
Binary files differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
new file mode 100644
index 0000000..9964ec3
--- /dev/null
+++ b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary files differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
new file mode 100644
index 0000000..957faa6
--- /dev/null
+++ b/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
+#Mon May 28 13:47:58 CEST 2018
+gradle.version=4.4
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
new file mode 100644
index 0000000..8ca1906
--- /dev/null
+++ b/.gradle/buildOutputCleanup/outputFiles.bin
Binary files differ
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..c27f34d
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,69 @@
+buildscript {
+ ext.kotlin_version = '1.2.41'
+
+ repositories {
+ mavenCentral()
+ maven {
+ url 'http://dl.bintray.com/cjstehno/public/'
+ }
+ }
+
+ dependencies {
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+plugins {
+ id 'java'
+ id 'application'
+ id 'com.stehno.natives' version '0.3.1'
+}
+apply plugin: 'kotlin'
+
+group 'de.romjaki'
+version '1.0-SNAPSHOT'
+
+ext.platform = 'linux'
+mainClassName = "de.romjaki.pluggabledino.MainKt"
+
+compileJava {
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+}
+repositories {
+ mavenCentral()
+ jcenter()
+}
+
+dependencies {
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+ compile 'com.beust:klaxon:3.0.1'
+ compile group: 'org.slick2d', name: 'slick2d-core', version: '1.0.2'
+ compile group: 'org.jbox2d', name: 'jbox2d-library', version: '2.2.1.1'
+}
+
+
+test {
+ systemProperty 'java.library.path', file("build/natives")
+}
+
+natives {
+}
+run {
+ systemProperty 'java.library.path', file('build/natives')
+}
+
+compileKotlin {
+ kotlinOptions.jvmTarget = "1.8"
+}
+compileTestKotlin {
+ kotlinOptions.jvmTarget = "1.8"
+}
+
+task copyResources(type: Copy) {
+ from 'src/main/resources'
+ into 'assets'
+}
+
+build.dependsOn copyResources
+
+
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..3d35a1b
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sun May 27 10:11:44 CEST 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..c7e135c
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,3 @@
+rootProject.name = 'pluggabledino'
+include 'pluggablelogging'
+
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
new file mode 100644
index 0000000..9b39e4b
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
@@ -0,0 +1,65 @@
+package de.romjaki.pluggabledino.api
+
+import de.romjaki.pluggabledino.buttonImage
+import de.romjaki.pluggabledino.drawImageCentered
+import de.romjaki.pluggabledino.drawStringCentered
+import de.romjaki.pluggabledino.font
+import org.newdawn.slick.Graphics
+import org.newdawn.slick.Input
+import java.awt.Rectangle
+import kotlin.math.min
+
+class Button(private val text: String, val x: Float, val y: Float) {
+
+ val width = min(buttonImage.width, font.getWidth(text) + 10)
+ val image = buttonImage.getScaledCopy(width, buttonImage.height)
+
+ private var lastClicked = false
+
+ val leftX
+ get() = x - width / 2
+ val rightX
+ get() = x + width / 2
+ val topY
+ get() = y - image.height / 2
+ val bottomY
+ get() = y + image.height / 2
+
+ val rectangle
+ get() = Rectangle(leftX.toInt(), topY.toInt(), (rightX - leftX).toInt(), (bottomY - topY).toInt())
+
+
+ private val clickHandlers = mutableListOf<() -> Unit>()
+
+ fun addClickHandler(handler: () -> Unit) {
+ clickHandlers.add(handler)
+ }
+
+ fun draw(g: Graphics) {
+ g.drawImageCentered(image, x, y)
+ g.drawStringCentered(text, x, y)
+ }
+
+ override fun toString(): String =
+ "X: $leftX - $rightX, $topY - $bottomY, width=$width"
+
+ fun enter() {
+ lastClicked = true
+ }
+
+ fun isClicked(input: Input): Boolean =
+ input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && isMouseOver(input)
+
+ fun update(input: Input) {
+ val ret = isClicked(input)
+ if (!lastClicked && ret) {
+ clickHandlers.forEach({ it() })
+ }
+ lastClicked = ret
+ }
+
+ fun isMouseOver(input: Input): Boolean =
+ rectangle.contains(input.mouseX, input.mouseY)
+
+}
+
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Dependency.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Dependency.kt
new file mode 100644
index 0000000..65c8b06
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Dependency.kt
@@ -0,0 +1,3 @@
+package de.romjaki.pluggabledino.api
+
+data class Dependency(var dependencyName: String, var dependencyVersion: String) \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/DependencyMissing.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/DependencyMissing.kt
new file mode 100644
index 0000000..85769f7
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/DependencyMissing.kt
@@ -0,0 +1,4 @@
+package de.romjaki.pluggabledino.api
+
+class DependencyMissing(plugin: String, dependencyName: String, dependencyVersion: String) :
+ Exception("$plugin is missing dependency ${dependencyName}with version $dependencyVersion")
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Event.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Event.kt
new file mode 100644
index 0000000..4aa702d
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Event.kt
@@ -0,0 +1,3 @@
+package de.romjaki.pluggabledino.api
+
+interface Event \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/EventHandler.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/EventHandler.kt
new file mode 100644
index 0000000..989fb81
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/EventHandler.kt
@@ -0,0 +1,5 @@
+package de.romjaki.pluggabledino.api
+
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.RUNTIME)
+annotation class EventHandler \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Events.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Events.kt
new file mode 100644
index 0000000..6f43844
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Events.kt
@@ -0,0 +1,15 @@
+package de.romjaki.pluggabledino.api
+
+import java.util.*
+
+object Events {
+ fun broadcastEvent(event: Event) {
+ for (plugin in PluginLoader.plugins.values) {
+ Arrays.stream(plugin.javaClass.methods!!)
+ .filter { it.getAnnotation(EventHandler::class.java) != null }
+ .filter { it.parameterCount == 1 }
+ .filter { it.parameterTypes[0].isInstance(event) }
+ .forEach { it.invoke(plugin, event) }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/IPlugin.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/IPlugin.kt
new file mode 100644
index 0000000..e2e25fc
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/IPlugin.kt
@@ -0,0 +1,5 @@
+package de.romjaki.pluggabledino.api;
+
+open class IPlugin {
+ var meta: PluginMeta? = null
+}
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Inject.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Inject.kt
new file mode 100644
index 0000000..c3089c9
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Inject.kt
@@ -0,0 +1,5 @@
+package de.romjaki.pluggabledino.api
+
+@Target(AnnotationTarget.FIELD)
+@Retention(AnnotationRetention.RUNTIME)
+annotation class Inject(val what: String)
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/InjectException.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/InjectException.kt
new file mode 100644
index 0000000..2dc14dd
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/InjectException.kt
@@ -0,0 +1,3 @@
+package de.romjaki.pluggabledino.api
+
+class InjectException(plugin: String, dependency: String) : Exception("$plugin failed to load $dependency") \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/PluginFolderNotFound.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/PluginFolderNotFound.kt
new file mode 100644
index 0000000..5ca946f
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/PluginFolderNotFound.kt
@@ -0,0 +1,3 @@
+package de.romjaki.pluggabledino.api
+
+class PluginFolderNotFound(folder: String) : Exception("Plugin folder not found at $folder")
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/PluginLoader.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/PluginLoader.kt
new file mode 100644
index 0000000..7ce8649
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/PluginLoader.kt
@@ -0,0 +1,76 @@
+package de.romjaki.pluggabledino.api
+
+import com.beust.klaxon.Klaxon
+import java.io.File
+import java.net.URL
+import java.net.URLClassLoader
+import java.util.*
+
+
+object PluginLoader {
+ private val _plugins: MutableMap<String, IPlugin> = mutableMapOf()
+ private val klaxon = Klaxon()
+ private const val pluginFolder = "plugins"
+
+ val plugins
+ get() = _plugins.toMap()
+
+
+ fun loadPlugin(url: URL): IPlugin? {
+ val cl = URLClassLoader(arrayOf(url))
+ val pluginInfo = klaxon.parse<PluginMeta>(
+ Scanner(
+ cl.getResourceAsStream("plugin.json"))
+ .useDelimiter("\\A")
+ .next())!!
+ val pluginClass = cl.loadClass(pluginInfo.clazz)
+ if (!IPlugin::class.java.isAssignableFrom(pluginClass)) {
+ return null
+ }
+ val plugin = pluginClass.newInstance() as IPlugin
+ plugin.meta = pluginInfo
+ _plugins[pluginInfo.name] = plugin
+ return plugin
+ }
+
+ private fun checkDependencies() {
+ for ((name, instance) in _plugins) {
+ for (dep in instance.meta!!.dependencies) {
+ if (!_plugins.containsKey(dep.dependencyName)) {
+ throw DependencyMissing(name, dep.dependencyName, dep.dependencyVersion)
+ }
+ val dependency = _plugins[dep.dependencyName]!!
+ if (dep.dependencyVersion.matches(dependency.meta!!.name.toRegex())) {
+ throw DependencyMissing(name, dep.dependencyName, dep.dependencyVersion)
+ }
+ }
+ }
+ }
+
+ fun loadPlugins() = loadPlugins(File(pluginFolder))
+ fun loadPlugins(folder: File) {
+ if (!folder.isDirectory) {
+ throw PluginFolderNotFound(folder.absolutePath)
+ }
+ folder.listFiles { _, filename -> filename.endsWith(".jar") }
+ .map {
+ it.toURI().toURL()
+ }.forEach { loadPlugin(it) }
+ checkDependencies()
+ injectDependencies()
+ }
+
+
+ private fun injectDependencies() {
+ for ((name, instance) in _plugins) {
+ for (field in instance.javaClass.fields) {
+ val inject = field.getAnnotation(Inject::class.java) as Inject
+ if (_plugins.containsKey(inject.what)) {
+ field.set(instance, _plugins[inject.what])
+ } else {
+ throw InjectException(name, inject.what)
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/PluginMeta.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/PluginMeta.kt
new file mode 100644
index 0000000..aec7e35
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/PluginMeta.kt
@@ -0,0 +1,5 @@
+package de.romjaki.pluggabledino.api
+
+import com.beust.klaxon.Json
+
+data class PluginMeta(var name: String, var version: String, @Json(name = "class") var clazz: String, var dependencies: MutableList<Dependency> = mutableListOf()) \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/assets.kt b/src/main/kotlin/de/romjaki/pluggabledino/assets.kt
new file mode 100644
index 0000000..6a0e600
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/assets.kt
@@ -0,0 +1,28 @@
+package de.romjaki.pluggabledino
+
+import org.newdawn.slick.Animation
+import org.newdawn.slick.Image
+import org.newdawn.slick.SpriteSheet
+import org.newdawn.slick.UnicodeFont
+import org.newdawn.slick.opengl.TextureLoader
+import java.awt.Font
+import java.io.FileInputStream
+
+val splash = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/splash.png")))
+val dinoSprites = SpriteSheet("assets/images/characters.png", 32, 32)
+val dinoAnimated = Animation(dinoSprites, intArrayOf(
+ 0, 0,
+ 1, 0,
+ 2, 0,
+ 3, 0,
+ 4, 0,
+ 5, 0,
+ 6, 0,
+ 7, 0
+), IntArray(8) { 100 })
+val font = UnicodeFont(Font("Arial", Font.PLAIN, 14))
+val buttonImage = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/button.png")))
+
+val groundline = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/groundline.png")))
+
+val cactusImg = Image(TextureLoader.getTexture("PNG", FileInputStream("assets/images/cactus.png")))
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/events/InitEvent.kt b/src/main/kotlin/de/romjaki/pluggabledino/events/InitEvent.kt
new file mode 100644
index 0000000..e82529c
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/events/InitEvent.kt
@@ -0,0 +1,5 @@
+package de.romjaki.pluggabledino.events
+
+import de.romjaki.pluggabledino.api.Event
+
+class InitEvent : Event
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/events/PostInitEvent.kt b/src/main/kotlin/de/romjaki/pluggabledino/events/PostInitEvent.kt
new file mode 100644
index 0000000..757888e
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/events/PostInitEvent.kt
@@ -0,0 +1,5 @@
+package de.romjaki.pluggabledino.events
+
+import de.romjaki.pluggabledino.api.Event
+
+class PostInitEvent : Event
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/events/PreInitEvent.kt b/src/main/kotlin/de/romjaki/pluggabledino/events/PreInitEvent.kt
new file mode 100644
index 0000000..75d7acc
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/events/PreInitEvent.kt
@@ -0,0 +1,6 @@
+package de.romjaki.pluggabledino.events
+
+import de.romjaki.pluggabledino.api.Event
+
+
+class PreInitEvent : Event \ No newline at end of file
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt
new file mode 100644
index 0000000..cc940cf
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/game/GameWorld.kt
@@ -0,0 +1,109 @@
+package de.romjaki.pluggabledino.game
+
+import org.jbox2d.callbacks.ContactImpulse
+import org.jbox2d.callbacks.ContactListener
+import org.jbox2d.collision.Manifold
+import org.jbox2d.collision.shapes.PolygonShape
+import org.jbox2d.common.Vec2
+import org.jbox2d.dynamics.*
+import org.jbox2d.dynamics.contacts.Contact
+import org.newdawn.slick.Input
+
+class GameWorld : ContactListener {
+ override fun endContact(contact: Contact?) {
+
+ }
+
+ override fun beginContact(contact: Contact?) {
+ contact!!
+ val bodies = listOf(contact.fixtureA.body, contact.fixtureB.body)
+ if (bodies.contains(dino) && cacti.any { bodies.contains(it) }) {
+ hurt = true
+ }
+ }
+
+ override fun preSolve(contact: Contact?, oldManifold: Manifold?) {
+ }
+
+ override fun postSolve(contact: Contact?, impulse: ContactImpulse?) {
+ }
+
+ var hurt = false
+
+ val world: World
+
+ val cacti = mutableListOf<Body>()
+
+ val cactiBodyDef: BodyDef
+
+ val groundBody: Body
+
+ val dino: Body
+
+ val groundBodyDef: BodyDef
+
+ val groundBox: PolygonShape
+
+ val dinoDef: BodyDef
+
+ val dinoBox: PolygonShape
+
+ val dinoFixtureDef: FixtureDef
+
+ init {
+ val gravity = Vec2(0f, 10f)
+ world = World(gravity)
+
+ //#region GROUND
+ groundBodyDef = BodyDef()
+ groundBodyDef.position.set(0f, 50f)
+ groundBody = world.createBody(groundBodyDef)
+ groundBox = PolygonShape()
+ groundBox.setAsBox(50f, 10f)
+ groundBody.createFixture(groundBox, 0f)
+ //#endregion
+
+ //#region DINO
+ dinoDef = BodyDef()
+ dinoDef.type = BodyType.DYNAMIC
+ dinoDef.position.set(4f, 39f)
+ dino = world.createBody(dinoDef)
+ dinoBox = PolygonShape()
+ dinoBox.setAsBox(1f, 1f)
+ dinoFixtureDef = FixtureDef()
+ dinoFixtureDef.shape = dinoBox
+ dinoFixtureDef.density = 0.9f
+ dinoFixtureDef.friction = 0.3f
+ dino.createFixture(dinoFixtureDef)
+ //#endregion
+
+ cactiBodyDef = BodyDef()
+
+ createCactus()
+ }
+
+ fun createCactus() {
+ val body = world.createBody(cactiBodyDef)
+ val shape = PolygonShape()
+ shape.setAsBox(1f, 1f)
+ body.createFixture(shape, 0f)
+ cacti.add(body)
+ }
+
+
+ fun update(delta: Float, input: Input) {
+ if (input.isKeyDown(Input.KEY_UP)) {
+ if (isDinoOnGround()) {
+ print("Jump")
+ dino.applyForceToCenter(Vec2(0f, -2000f))
+ }
+ }
+ world.step(delta, 4, 3)
+ world.setContactListener(this)
+ }
+
+ private fun isDinoOnGround(): Boolean =
+ dino.linearVelocity.y == 0.0f
+
+}
+
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/main.kt b/src/main/kotlin/de/romjaki/pluggabledino/main.kt
new file mode 100644
index 0000000..a829089
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/main.kt
@@ -0,0 +1,49 @@
+package de.romjaki.pluggabledino
+
+import de.romjaki.pluggabledino.api.Events
+import de.romjaki.pluggabledino.api.PluginLoader
+import de.romjaki.pluggabledino.events.InitEvent
+import de.romjaki.pluggabledino.events.PostInitEvent
+import de.romjaki.pluggabledino.events.PreInitEvent
+import de.romjaki.pluggabledino.states.GameState
+import de.romjaki.pluggabledino.states.MainMenu
+import de.romjaki.pluggabledino.states.SettingsState
+import de.romjaki.pluggabledino.states.SplashScreen
+import org.newdawn.slick.AppGameContainer
+import org.newdawn.slick.GameContainer
+import org.newdawn.slick.Input
+import org.newdawn.slick.state.StateBasedGame
+
+
+const val WIDTH = 640
+const val HEIGHT = 480
+const val FPS = 60
+const val VERSION = 1.0
+
+const val SPLASHSCREEN = 0
+const val MAINMENU = 1
+const val SETTINGS = 3
+const val GAME = 2
+
+fun main(args: Array<String>) {
+ PluginLoader.loadPlugins()
+ Input.disableControllers()
+ val app = AppGameContainer(Application())
+ app.setDisplayMode(WIDTH, HEIGHT, false)
+ app.setTargetFrameRate(FPS)
+ app.setShowFPS(true)
+ Events.broadcastEvent(PreInitEvent())
+ Events.broadcastEvent(InitEvent())
+ Events.broadcastEvent(PostInitEvent())
+ app.start()
+
+}
+
+class Application : StateBasedGame("Dino Game v$VERSION") {
+ override fun initStatesList(container: GameContainer?) {
+ addState(SplashScreen())
+ addState(MainMenu())
+ addState(SettingsState())
+ addState(GameState())
+ }
+}
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt
new file mode 100644
index 0000000..479f7f7
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt
@@ -0,0 +1,45 @@
+package de.romjaki.pluggabledino.states
+
+import de.romjaki.pluggabledino.*
+import de.romjaki.pluggabledino.game.GameWorld
+import org.newdawn.slick.Color
+import org.newdawn.slick.GameContainer
+import org.newdawn.slick.Graphics
+import org.newdawn.slick.Input
+import org.newdawn.slick.state.BasicGameState
+import org.newdawn.slick.state.StateBasedGame
+
+class GameState : BasicGameState() {
+ override fun init(container: GameContainer?, game: StateBasedGame?) {
+ }
+
+ override fun enter(container: GameContainer?, game: StateBasedGame?) {
+ world = GameWorld()
+ }
+
+ override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
+ if (container!!.input.isKeyDown(Input.KEY_R)) {
+ world = GameWorld()
+ }
+ world.update(delta / 1000f, container.input)
+ dinoAnimated.update(delta.toLong())
+ }
+
+ lateinit var world: GameWorld
+
+ override fun getID(): Int =
+ GAME
+
+
+ override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
+ g!!
+ g.background = Color.lightGray
+ g.color = Color.red
+ g.drawImage(dinoAnimated.currentFrame, world.dino.position.x * WIDTH / 50, world.dino.position.y * HEIGHT / 50 - dinoAnimated.height)
+ g.drawImage(groundline, 0f, HEIGHT * 39 / 50f)
+ for (cactus in world.cacti) {
+ g.drawImage(cactusImg, cactus.position.x, cactus.position.y)
+ }
+ }
+
+}
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt
new file mode 100644
index 0000000..f10a470
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt
@@ -0,0 +1,52 @@
+package de.romjaki.pluggabledino.states
+
+import de.romjaki.pluggabledino.*
+import de.romjaki.pluggabledino.api.Button
+import org.newdawn.slick.Color
+import org.newdawn.slick.GameContainer
+import org.newdawn.slick.Graphics
+import org.newdawn.slick.Input
+import org.newdawn.slick.state.BasicGameState
+import org.newdawn.slick.state.StateBasedGame
+
+class MainMenu : BasicGameState() {
+ override fun init(container: GameContainer?, game: StateBasedGame?) {
+ game!!
+ settingsButton.addClickHandler {
+ game.enterState(SETTINGS)
+ }
+ playButton.addClickHandler {
+ game.enterState(GAME)
+ }
+ }
+
+ override fun enter(container: GameContainer?, game: StateBasedGame?) {
+ settingsButton.enter()
+ playButton.enter()
+ }
+
+ override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
+ container!!
+ game!!
+ dinoAnimated.update(delta.toLong())
+ if (container.input.isKeyDown(Input.KEY_Q)) {
+ System.exit(0)
+ }
+ settingsButton.update(container.input)
+ playButton.update(container.input)
+ }
+
+ override fun getID(): Int =
+ MAINMENU
+
+ val playButton = Button("PLAY", WIDTH / 2f, HEIGHT / 2f + 50)
+ val settingsButton = Button("SETTINGS", WIDTH / 2f, HEIGHT / 2f + 100)
+ override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
+ g!!
+ g.background = Color.lightGray
+ g.drawImage(dinoAnimated.currentFrame, WIDTH / 2f - 16, HEIGHT / 2f - 16f)
+ playButton.draw(g)
+ settingsButton.draw(g)
+ }
+
+}
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt
new file mode 100644
index 0000000..5003232
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt
@@ -0,0 +1,42 @@
+package de.romjaki.pluggabledino.states
+
+import de.romjaki.pluggabledino.HEIGHT
+import de.romjaki.pluggabledino.MAINMENU
+import de.romjaki.pluggabledino.SETTINGS
+import de.romjaki.pluggabledino.WIDTH
+import de.romjaki.pluggabledino.api.Button
+import org.newdawn.slick.Color
+import org.newdawn.slick.GameContainer
+import org.newdawn.slick.Graphics
+import org.newdawn.slick.state.BasicGameState
+import org.newdawn.slick.state.StateBasedGame
+
+class SettingsState : BasicGameState() {
+ override fun init(container: GameContainer?, game: StateBasedGame?) {
+ game!!
+ backButton.addClickHandler {
+ game.enterState(MAINMENU)
+ }
+ }
+
+ override fun enter(container: GameContainer?, game: StateBasedGame?) {
+ backButton.enter()
+ }
+
+ override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
+ container!!
+ backButton.update(container.input)
+ }
+
+ override fun getID(): Int =
+ SETTINGS
+
+ val backButton = Button("BACK", WIDTH / 2f, HEIGHT / 8 * 7f)
+
+ override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
+ g!!
+ g.background = Color.lightGray
+ backButton.draw(g)
+ }
+
+}
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt
new file mode 100644
index 0000000..d39b31a
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt
@@ -0,0 +1,41 @@
+package de.romjaki.pluggabledino.states
+
+import de.romjaki.pluggabledino.*
+import org.newdawn.slick.GameContainer
+import org.newdawn.slick.Graphics
+import org.newdawn.slick.Image
+import org.newdawn.slick.Input
+import org.newdawn.slick.state.BasicGameState
+import org.newdawn.slick.state.StateBasedGame
+
+
+class SplashScreen : BasicGameState() {
+ override fun init(container: GameContainer?, game: StateBasedGame?) {
+ }
+
+ override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
+ container!!
+ game!!
+ val input = container.input
+ if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
+ input.clearMousePressedRecord()
+ game.enterState(MAINMENU)
+ }
+ if (input.isKeyDown(Input.KEY_Q)) {
+ System.exit(0)
+ }
+ }
+
+ override fun getID(): Int =
+ SPLASHSCREEN
+
+
+ override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
+ g!!
+ g.drawImage(splash, 0f, 0f)
+ g.drawStringCentered("CLICK ANYWHERE TO CONTINUE", WIDTH / 2f, HEIGHT / 2f)
+ }
+
+}
+
+
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/util.kt b/src/main/kotlin/de/romjaki/pluggabledino/util.kt
new file mode 100644
index 0000000..de434e0
--- /dev/null
+++ b/src/main/kotlin/de/romjaki/pluggabledino/util.kt
@@ -0,0 +1,23 @@
+package de.romjaki.pluggabledino
+
+import org.jbox2d.common.Vec2
+import org.newdawn.slick.Graphics
+import org.newdawn.slick.Image
+import org.newdawn.slick.Input
+
+fun Graphics.drawStringCentered(s: String, x: Float, y: Float) {
+ val h = font.getHeight(s)
+ val w = font.getWidth(s)
+ drawString(s, x - w / 2f, y - h / 2f)
+}
+
+fun Graphics.drawImageCentered(image: Image, x: Float, y: Float) {
+ drawImage(image, x - image.width / 2f, y - image.height / 2)
+}
+
+operator fun Vec2.plus(vec2: Vec2): Vec2? = add(vec2)
+
+fun Graphics.drawMousePointer(input: Input) {
+ fillOval(input.mouseX - 5f, input.mouseY - 5f, 10f, 10f)
+}
+
diff --git a/src/main/resources/images/button.png b/src/main/resources/images/button.png
new file mode 100644
index 0000000..3508044
--- /dev/null
+++ b/src/main/resources/images/button.png
Binary files differ
diff --git a/src/main/resources/images/cactus.png b/src/main/resources/images/cactus.png
new file mode 100644
index 0000000..13aaabd
--- /dev/null
+++ b/src/main/resources/images/cactus.png
Binary files differ
diff --git a/src/main/resources/images/characters.png b/src/main/resources/images/characters.png
new file mode 100644
index 0000000..8113a38
--- /dev/null
+++ b/src/main/resources/images/characters.png
Binary files differ
diff --git a/src/main/resources/images/groundline.png b/src/main/resources/images/groundline.png
new file mode 100644
index 0000000..d637a5c
--- /dev/null
+++ b/src/main/resources/images/groundline.png
Binary files differ
diff --git a/src/main/resources/images/splash.png b/src/main/resources/images/splash.png
new file mode 100644
index 0000000..a0bd5dc
--- /dev/null
+++ b/src/main/resources/images/splash.png
Binary files differ