diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8bd40c --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Keep Engine + +[![Test and Publish](https://github.com/RowDaBoat/keep-engine/actions/workflows/ci.yml/badge.svg)](https://github.com/RowDaBoat/keep-engine/actions/workflows/ci.yml) + +**Keep Engine** is a game engine for text based adventure games written in Kotlin. It features an easy to read and write domain specific language to design scenes, items, characters, actions, and state machines. + +## Kobold Lexer + +## Setup +Add the JitPack to your repositories and `keep-keep` to your dependencies on your project's `build.gradle.kts`. + +```kotlin +repositories { + maven { url "https://jitpack.io" } +} + +dependencies { + implementation "com.github.RowDaBoat:keep-engine:1.0" +} +``` + +## A simple game + +To create a simple `Game` you need: an `InOut` object for input and output, a `Character` object for your main character, and a `Scene` for your initial scene. + +First create an `InOut` that will handle the game's input and output: + +```kotlin +val inOut = InOut() +``` + +Then create a main character, it requires a key (`"player"`) to identify it, and a name to display (`"you"`): +```kotlin +val mainCharacter = mainCharacter("player", "you") +``` + +Then create a scene, it requires a key (`"hello-keep""`) to identify it, and a title name to display (`"Hello Keep""`), scenes usually also have a `narration` as third argument to provide context to the player. The last argument is very important, but we won't use it for now so we just use an empty list. + +```kotlin +val welcome = Scene( + "hello-keep", + "Hello Keep", + "Keep is a text-based game engine for adventure games.", + emptyList() +) +``` + +Then create a game using the previously declared objects. The last argument is the `key` of the initial scene. + +```kotlin +val scenes = listOf(welcome) +val game = Game(inOut, mainCharacter, scenes, "hello-keep") +``` + +Finally, start the game: + +```kotlin +game.start() + +while (true) { + game.draw() +} +``` diff --git a/build.gradle.kts b/build.gradle.kts index 6b0a160..e8bb7ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { mavenCentral() } -group = "tech.alephia" +group = "com.github.RowDaBoat" version = "1.0" dependencies { diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts new file mode 100644 index 0000000..5cbebf0 --- /dev/null +++ b/samples/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + kotlin("jvm") +} + +group = "com.github.RowDaBoat" +version = "1.0" + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":")) +} diff --git a/samples/src/main/kotlin/tech/alephia/keep/samples/hellokeep/main.kt b/samples/src/main/kotlin/tech/alephia/keep/samples/hellokeep/main.kt new file mode 100644 index 0000000..5e53752 --- /dev/null +++ b/samples/src/main/kotlin/tech/alephia/keep/samples/hellokeep/main.kt @@ -0,0 +1,29 @@ +package tech.alephia.keep.samples.hellokeep + +import tech.alephia.keep.core.Game +import tech.alephia.keep.core.entities.characters.mainCharacter +import tech.alephia.keep.core.scenes.Scene +import tech.alephia.keep.delivery.InOut + +fun main() { + val inOut = InOut() + + val mainCharacter = mainCharacter("player", "you") + + val welcome = Scene( + "hello-keep", + "Hello Keep", + "Keep is a text-based game engine for adventure games.", + emptyList() + ) + + val scenes = listOf(welcome) + + val game = Game(inOut, mainCharacter, scenes, "hello-keep") + + game.start() + + while (true) { + game.draw() + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index b2328f8..fdf8d61 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,8 +11,6 @@ pluginManagement { } } -rootProject.name = "kobold-keep" +rootProject.name = "keep-engine" -include("keep-engine") -include("kobold-keep") -include("kobold-keep-game") +include("samples")