-
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.
Add example on how to use debug features
- Loading branch information
1 parent
28f8a30
commit bf7e08c
Showing
2 changed files
with
60 additions
and
4 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
56 changes: 56 additions & 0 deletions
56
tiny-engine/src/commonMain/kotlin/com/github/minigdx/tiny/lua/DebugLibExamples.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,56 @@ | ||
package com.github.minigdx.tiny.lua | ||
|
||
//language=Lua | ||
const val DEBUG_EXAMPLE = """ | ||
function _update() | ||
local pos = ctrl.touch() | ||
debug.table(pos) | ||
debug.log("frame "..tiny.frame) | ||
end | ||
function _draw() | ||
gfx.cls() | ||
-- draw the mouse position. | ||
local pos = ctrl.touch() | ||
shape.line(pos.x - 2, pos.y, pos.x + 2, pos.y, 3) | ||
shape.line(pos.x, pos.y - 2, pos.x, pos.y + 2, 3) | ||
end | ||
""" | ||
|
||
//language=Lua | ||
const val DEBUG_ENABLED_EXAMPLE = """ | ||
function _init() | ||
switch = true | ||
end | ||
function _update() | ||
local pos = ctrl.touch() | ||
debug.rect(pos.x, pos.y, 16, 16) | ||
if ctrl.touched(0) then | ||
switch = not switch | ||
debug.enabled(switch) | ||
end | ||
debug.log("debug ".. tostring(switch)) | ||
end | ||
function _draw() | ||
gfx.cls() | ||
-- draw the mouse position. | ||
local pos = ctrl.touch() | ||
shape.line(pos.x - 2, pos.y, pos.x + 2, pos.y, 3) | ||
shape.line(pos.x, pos.y - 2, pos.x, pos.y + 2, 3) | ||
if switch then | ||
print("debug enabled", 10, 40) | ||
else | ||
print("debug disabled", 10, 40) | ||
end | ||
end | ||
""" |