Skip to content

Commit

Permalink
Add README.md, samples, and publish to JitPack
Browse files Browse the repository at this point in the history
  • Loading branch information
RowDaBoat committed Jun 22, 2024
1 parent 7c71741 commit d29060b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 5 deletions.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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()
}
```
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {
mavenCentral()
}

group = "tech.alephia"
group = "com.github.RowDaBoat"
version = "1.0"

dependencies {
Expand Down
14 changes: 14 additions & 0 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
kotlin("jvm")
}

group = "com.github.RowDaBoat"
version = "1.0"

repositories {
mavenCentral()
}

dependencies {
implementation(project(":"))
}
Original file line number Diff line number Diff line change
@@ -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()
}
}
6 changes: 2 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit d29060b

Please sign in to comment.