Skip to content

Commit

Permalink
docs: Update readme to latest syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Mar 17, 2024
1 parent 42a418c commit 0d2c8ae
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# Geary
[![Java CI with Gradle](https://github.com/MineInAbyss/Geary/actions/workflows/gradle-ci.yml/badge.svg)](https://github.com/MineInAbyss/Geary/actions/workflows/gradle-ci.yml)
[![Package](https://img.shields.io/maven-metadata/v?metadataUrl=https://repo.mineinabyss.com/releases/com/mineinabyss/geary-core/maven-metadata.xml)](https://repo.mineinabyss.com/#/releases/com/mineinabyss/geary-core)
[![Package](https://img.shields.io/maven-metadata/v?metadataUrl=https://repo.mineinabyss.com/releases/com/mineinabyss/geary-core/maven-metadata.xml&color=light_green)](https://repo.mineinabyss.com/#/releases/com/mineinabyss/geary-core)
[![Package](https://img.shields.io/maven-metadata/v?metadataUrl=https://repo.mineinabyss.com/snapshots/com/mineinabyss/geary-core/maven-metadata.xml&label=prerelease)](https://repo.mineinabyss.com/#/snapshots/com/mineinabyss/geary-core)
[![Wiki](https://img.shields.io/badge/-Project%20Wiki-blueviolet?logo=Wikipedia&labelColor=gray)](https://wiki.mineinabyss.com/geary)
[![Contribute](https://shields.io/badge/Contribute-e57be5?logo=github%20sponsors&style=flat&logoColor=white)](https://wiki.mineinabyss.com/contribute)
</div>
Expand All @@ -19,44 +20,47 @@ Geary is an Entity Component System (ECS) written in Kotlin. The engine design i
- Persistent components and loading prefabs from files thanks to [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization/)
- Addon system to use only what you need

## Example
## Usage


We host a WIP wiki, the best way to get up-to-date info is reading the [quickstart-guide](https://wiki.mineinabyss.com/geary/guide/quickstart/), here's an excerpt, a simple velocity system:


A simple ssytem that iterates over all entities with a position and velocity, updating the position every engine tick.
```kotlin
data class Position(var x: Double, var y: Double)
data class Velocity(var x: Double, var y: Double)

class UpdatePositionSystem : TickingSystem(interval = 20.milliseconds) {
// Specify all components we want (Geary also supports branched AND/OR/NOT statements for selection)
val Pointer.position by get<Position>()
val Pointer.velocity by get<Velocity>()

override fun Pointer.tick() {
// We can access our components like regular variables!
position.x += velocity.x
position.y += velocity.y
}
fun GearyModule.updatePositionSystem() = system(object: Query() {
val position by get<Position>()
val velocity by get<Velocity>()
}).every(interval = 20.milliseconds).exec {
// We can access our components like regular variables!
position.x += velocity.x
position.y += velocity.y
}


fun main() {
// Set up geary
geary(ArchetypeEngineModule) {
// configure engine here
install(Prefabs)
}

geary.pipeline.addSystem(UpdatePositionSystem())
val posSystem = geary.updatePositionSystem()

// Create an entity the system can run on
entity {
setAll(Position(0.0, 0.0), Velocity(1.0, 0.0))
}

posSystem.tick() // exec just this system
geary.engine.tick() // exec all registered repeating systems, interval used to calculate every n ticks to run

val positions: List<Position> = posSystem.map { position }
}

```
## Usage

A WIP wiki can be found at [wiki.mineinabyss.com](https://wiki.mineinabyss.com/geary/)

### Gradle
```kotlin
Expand All @@ -76,5 +80,4 @@ dependencies {
As the project matures, our primary goal is to make it useful to more people. Here are a handful of features we hope to achieve:
- Multiplatform support, with js, jvm, and native targets
- Publish numbers for benchmarks and cover more parts of the engine with them
- Component data migrations
- Complex queries (including relations like parent/child)
- Relation queries, ex. entities with a parent that has X component.

0 comments on commit 0d2c8ae

Please sign in to comment.