summaryrefslogtreecommitdiff
path: root/src/main/kotlin/de/romjaki/pluggabledino/main.kt
blob: d92ba501eec633db7832d16b28f33715d2a9a7af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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.*
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 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

const val SPLASHSCREEN = 0
const val MAINMENU = 1
const val SETTINGS = 3
const val GAME = 2
const val LOST = 4

fun main(args: Array<String>) {
    PluginLoader.loadPlugins()
    Input.disableControllers()
    val app = AppGameContainer(Application())
    app.setDisplayMode(REAL_WIDTH, REAL_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())
        addState(LostState())
    }
}