Skip to content

Commit

Permalink
Bump to v0.7.2, fix example project for SDK v1.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
samdze committed Feb 23, 2023
1 parent 6f13595 commit 1543e48
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion playdate.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.7.0"
version = "0.7.2"
author = "Samuele Zolfanelli"
description = "Playdate Nim bindings with extra features."
license = "MIT"
Expand All @@ -10,3 +10,4 @@ srcDir = "src"
# Dependencies

requires "nim >= 1.6.10"
# requires "nimble < 0.14.0"
5 changes: 2 additions & 3 deletions playdate_example/src/playdate_example.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ proc update(): int =
let goalX = x.toFloat
let goalY = y.toFloat
let res = sprite.moveWithCollisions(goalX, goalY)
# + 32 to account for the C SDK ignoring the sprite center point (bug)
x = (res.actualX + 32).int
y = (res.actualY + 32).int
x = res.actualX.int
y = res.actualY.int
if res.collisions.len > 0:
# fmt allows the "{variable}" syntax for formatting strings
playdate.system.logToConsole(fmt"{res.collisions.len} collision(s) occurred!")
Expand Down
27 changes: 15 additions & 12 deletions src/playdate/build/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ type BuildFail = object of Defect

proc playdatePath(): string =
## Returns the path of the playdate nim module
let (path, exitCode) = gorgeEx("nimble path playdate")
let (paths, exitCode) = gorgeEx("nimble path playdate")
if exitCode != 0:
raise BuildFail.newException("Could not find the playdate nimble module!")
let pathsSeq = paths.split("\n")
# If multiple package paths are found, use the last one
let path = pathsSeq[pathsSeq.len - 1]
if path.strip == "" or not path.strip.dirExists:
raise BuildFail.newException("Playdate nimble module is not a directory: " & path)
return path
Expand Down Expand Up @@ -60,27 +63,31 @@ proc make(target: string) =
let arch = if defined(macosx): "arch -arm64 " else: ""
exec(arch & "make " & target & " -f " & makefile)

task cdevice, "build project":
task clean, "Clean the project folders":
exec "rm -fR " & nimcacheDir()
make "clean"

task cdevice, "Generate C files for the device":
nimble "-d:playdate", "build"

task csim, "build project":
task csim, "Generate C files for the simulator":
nimble "-d:simulator", "build"

task simulator, "build project":
task simulator, "Build for the simulator":
nimble "clean"
nimble "-d:simulator", "build"
make "pdc"

task simulate, "build project the project and run the simulator":
task simulate, "Build and run in the simulator":
nimble "simulator"
exec( (sdkPath() / "bin" / "PlaydateSimulator") & " " & pdxName())

task device, "build project":
task device, "Build for the device":
nimble "clean"
nimble "-d:playdate", "build"
make "device"

task all, "build all":
task all, "Build for both the simulator and the device":
nimble "clean"
nimble "csim"
make "simulator"
Expand All @@ -89,11 +96,7 @@ task all, "build all":
make "device"
exec(sdkPath() & "/bin/pdc Source " & pdxName())

task clean, "clean project":
exec "rm -fR " & nimcacheDir()
make "clean"

task setup, "Initializes the build structure":
task setup, "Initialize the build structure":
## Creates a default source directory if it doesn't already exist

# Calling `sdkPath` will ensure the SDK environment variable is saved
Expand Down

0 comments on commit 1543e48

Please sign in to comment.