summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt7
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/main.kt2
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt2
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt2
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt2
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt7
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt2
7 files changed, 10 insertions, 14 deletions
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
index 0fc8ddb..edced5a 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
@@ -1,9 +1,6 @@
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 de.romjaki.pluggabledino.*
import org.newdawn.slick.Graphics
import org.newdawn.slick.Input
import java.awt.Rectangle
@@ -59,7 +56,7 @@ class Button(private val text: String, val x: Float, val y: Float) {
}
fun isMouseOver(input: Input): Boolean =
- rectangle.contains(input.mouseX / 5 * 4, input.mouseY / 5 * 4)
+ rectangle.contains((input.mouseX / WIDTH_RATIO).toInt(), (input.mouseY / HEIGHT_RATIO).toInt())
}
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/main.kt b/src/main/kotlin/de/romjaki/pluggabledino/main.kt
index 8be56f9..d92ba50 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/main.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/main.kt
@@ -16,6 +16,8 @@ const val WIDTH = 640
const val HEIGHT = 480
const val REAL_WIDTH = 800
const val REAL_HEIGHT = 600
+const val WIDTH_RATIO = REAL_WIDTH.toFloat() / WIDTH
+const val HEIGHT_RATIO = REAL_HEIGHT.toFloat() / HEIGHT
const val FPS = 60
const val VERSION = 1.0
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt
index ae34db5..805632c 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/GameState.kt
@@ -36,7 +36,7 @@ class GameState : BasicGameState() {
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
g!!
- g.scale(1.25f,1.25f)
+ g.scale(WIDTH_RATIO, HEIGHT_RATIO)
g.background = Color.white
if (world.hurt) {
g.background = Color.red
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt
index 88b6daf..20ccf96 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/LostState.kt
@@ -32,7 +32,7 @@ class LostState : BasicGameState() {
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
g!!
- g.scale(1.25f,1.25f)
+ g.scale(WIDTH_RATIO, HEIGHT_RATIO)
g.background = Color.lightGray
back.draw(g)
playAgain.draw(g)
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt
index 0d4d23b..c67b8ea 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/MainMenu.kt
@@ -49,7 +49,7 @@ class MainMenu : BasicGameState() {
val settingsButton = Button("SETTINGS", WIDTH / 2f, HEIGHT / 2f + 100)
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
g!!
- g.scale(1.25f,1.25f)
+ g.scale(WIDTH_RATIO, HEIGHT_RATIO)
g.background = Color.lightGray
g.drawImage(dinoAnimated.currentFrame, WIDTH / 2f - 16, HEIGHT / 2f - 16f)
playButton.draw(g)
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt b/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt
index bceb6af..3e667da 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/SettingsState.kt
@@ -1,9 +1,6 @@
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.*
import de.romjaki.pluggabledino.api.Button
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
@@ -35,7 +32,7 @@ class SettingsState : BasicGameState() {
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
g!!
- g.scale(1.25f,1.25f)
+ g.scale(WIDTH_RATIO, HEIGHT_RATIO)
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
index 717bdb2..ade76e8 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/states/SplashScreen.kt
@@ -32,7 +32,7 @@ class SplashScreen : BasicGameState() {
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
g!!
- g.scale(1.25f,1.25f)
+ g.scale(WIDTH_RATIO, HEIGHT_RATIO)
g.drawImage(splash, 0f, 0f)
g.drawStringCentered("CLICK ANYWHERE TO CONTINUE", WIDTH / 2f, HEIGHT / 2f)
}