Skip to content

Commit

Permalink
Remove libsdl/Constants.kt and modify main.kt
Browse files Browse the repository at this point in the history
This commit removes the libsdl/Constants.kt file, and consequently, updates calls in main.kt that relied on SDL constant values previously defined in the removed file. The SDL constant values are now represented with inline conversions.
  • Loading branch information
ygdrasil-io committed Feb 16, 2024
1 parent 075b76f commit f3c7cad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
16 changes: 0 additions & 16 deletions bindings/sdl/libsdl/src/main/kotlin/libsdl/Constants.kt

This file was deleted.

4 changes: 2 additions & 2 deletions bindings/sdl/libsdl/src/main/kotlin/snake/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SdlUI(width: Int, height: Int): AutoCloseable {
private val pixelHeight = height * Sprites.h

init {
if (libSDL2Library.SDL_Init(SDL_INIT_EVERYTHING) != 0) {
if (libSDL2Library.SDL_Init(SDL_INIT_EVERYTHING.toInt()) != 0) {
println("SDL_Init Error: ${libSDL2Library.SDL_GetError()}")
throw Error()
}
Expand All @@ -94,7 +94,7 @@ class SdlUI(width: Int, height: Int): AutoCloseable {

fun draw(game: Game) {
libSDL2Library.SDL_RenderClear(renderer)
libSDL2Library.SDL_SetRenderDrawColor(renderer, (200 / 2).toByte(), (230 / 2).toByte(), (151 / 2).toByte(), SDL_ALPHA_OPAQUE)
libSDL2Library.SDL_SetRenderDrawColor(renderer, (200 / 2).toByte(), (230 / 2).toByte(), (151 / 2).toByte(), SDL_ALPHA_OPAQUE.toByte())

val grassW = 256
val grassScaledW = 400 // scale grass up to reduce its resolution so that it's similar to snake sprites
Expand Down

0 comments on commit f3c7cad

Please sign in to comment.