-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow examples to load custom sprite and level
- Loading branch information
1 parent
7fc8b73
commit a272b11
Showing
13 changed files
with
144 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/SprLibExamples.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.github.minigdx.tiny.lua | ||
|
||
//language=Lua | ||
const val SPR_PGET_EXAMPLE = """ | ||
function _draw() | ||
local pos = ctrl.touch() | ||
gfx.cls() | ||
spr.sdraw() | ||
shape.circlef(pos.x - 4, pos.y - 4, 8, 3) | ||
local color = spr.pget(pos.x, pos.y) | ||
if(color ~= nil) then | ||
print("index color: "..color, 7, 0) | ||
shape.rectf(0, 0, 6, 6, color) | ||
shape.circlef(pos.x - 4, pos.y - 4, 6, color) | ||
end | ||
end | ||
""" | ||
|
||
//language=Lua | ||
const val SPR_PSET_EXAMPLE = """ | ||
function _draw() | ||
local pos = ctrl.touch() | ||
local touching = ctrl.touching(0) | ||
gfx.cls() | ||
spr.sdraw() | ||
if touching ~= nil then | ||
spr.pset(touching.x, touching.y, 9) | ||
end | ||
print("click to alter", 45, 96) | ||
shape.circle(64 + 8, 128 + 8, 32, 1) | ||
shape.circlef(128 + 8, 128 + 8, 32, 1) | ||
spr.draw(100, 128, 128) | ||
shape.circlef(pos.x, pos.y, 2, 3) | ||
end | ||
""" | ||
|
||
//language=Lua | ||
const val SPR_DRAW_EXAMPLE = """ | ||
function _init() | ||
id = 1 | ||
end | ||
function _draw() | ||
if ctrl.pressed(keys.left) then | ||
id = id - 1 | ||
elseif ctrl.pressed(keys.right) then | ||
id = id + 1 | ||
end | ||
gfx.cls() | ||
print("sprite index "..id.. " (press left or right to change)", 50, 112) | ||
spr.draw(id, 120, 120) | ||
end | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters