This commit is contained in:
Patrick Schwarzer 2025-04-16 00:20:32 +02:00
parent 1e299dfa84
commit 204021b9ae
11 changed files with 143 additions and 26 deletions

View file

@ -11,28 +11,41 @@ end
function Update(dt, curTime)
end
local sprite = Spritesheet("testSprites.json", 16, 16, Color(48, 104, 80, 255))
local sprite = Spritesheet("testSprites.png", 16, 16, Color(48, 104, 80, 255))
local tileset = Spritesheet("tileset.json", 16, 16, Color(48, 104, 80, 255))
local testSound = Sound("testSound.mp3", "static")
local test = 1
local test2 = 1
function KeyPressed(key)
if (key == "f3") then
test = test - 1
test2 = test2 - 1
if (test == 0) then
test = sprite.Count
end
if (test2 == 0) then
test2 = tileset.Count
end
elseif (key == "f4") then
test = test + 1
test2 = test2 + 1
if (test == sprite.Count + 1) then
test = 1
end
if (test2 == tileset.Count + 1) then
test2 = 1
end
elseif (key == "f2") then
testSound:Play()
end
end
function Draw()
DrawText(test .. "/" .. sprite.Count, 25, 25)
sprite:Draw(test, 50, 0)
DrawText(test .. "/" .. sprite.Count, 50, 25)
sprite:Draw(test, 5, 25)
tileset:Draw(test2, 25, 0)
end

59
games/test/main.lua Normal file
View file

@ -0,0 +1,59 @@
NAME = "Test"
AUTHOR = "Tarion"
VERSION = 0
local backgroundColor = Color(48, 104, 80, 255)
local colo3r = Color(48, 104, 80, 255)
function Load()
SetBackgroundColor(backgroundColor)
color = Color(48, 104, 80, 255)
end
function Update(dt, curTime)
end
local sprite = Spritesheet("testSprites.png", 16, 16, Color(48, 104, 80, 255))
local tileset = Spritesheet("tileset.json", 16, 16, Color(48, 104, 80, 255))
local testSound = Sound("testSound.mp3", "static")
local test = 1
local test2 = 1
function KeyPressed(key)
if (key == "f3") then
test = test - 1
test2 = test2 - 1
if (test == 0) then
test = sprite.Count
end
if (test2 == 0) then
test2 = tileset.Count
end
elseif (key == "f4") then
test = test + 1
test2 = test2 + 1
if (test == sprite.Count + 1) then
test = 1
end
if (test2 == tileset.Count + 1) then
test2 = 1
end
elseif (key == "f2") then
testSound:Play()
testSound = nil
collectgarbage()
end
end
function Draw()
DrawText(test .. "/" .. sprite.Count, 50, 25)
sprite:Draw(test, 5, 25)
tileset:Draw(test2, 30, 0)
end
-- TODO:
-- 1. Implement memory limits for code, track how many variables are loaded, based on the size, like int64 and stuff

2
games/test/test.lua Normal file
View file

@ -0,0 +1,2 @@
return "test"

BIN
games/test/testSound.mp3 Normal file

Binary file not shown.

BIN
games/test/testSprites.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

22
games/test/tileset.json Normal file
View file

@ -0,0 +1,22 @@
{
"image": "tileset.png",
"tiles": [
{"x":0,"y":0,"width":64,"height":24},
{"x":64,"y":0,"width":16,"height":24},
{"x":64,"y":0,"width":16,"height":24},
{"x":0,"y":24,"width":64,"height":24},
{"x":80,"y":52,"width":8,"height":12},
{"x":80,"y":68,"width":8,"height":12},
{"x":0,"y":72,"width":80,"height":24},
{"x":90,"y":48,"width":14,"height":48},
{"x":72,"y":96,"width":32,"height":15},
{"x":32,"y":96,"width":40,"height":15},
{"x":24,"y":96,"width":8,"height":8},
{"x":16,"y":96,"width":8,"height":8},
{"x":16,"y":104,"width":8,"height":8},
{"x":0,"y":96,"width":16,"height":16},
{"x":0,"y":112,"width":32,"height":24},
{"x":32,"y":111,"width":32,"height":24},
{"x":72,"y":136,"width":32,"height":24}
]
}

BIN
games/test/tileset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -1,18 +0,0 @@
[
{
"image": "testSprites.png"
},
{"x":0,"y":0,"width":64,"height":24},
{"x":64,"y":0,"width":16,"height":24},
{"x":64,"y":0,"width":16,"height":24},
{"x":0,"y":24,"width":64,"height":24},
{"x":80,"y":52,"width":8,"height":12},
{"x":80,"y":68,"width":8,"height":12},
{"x":0,"y":72,"width":80,"height":24},
{"x":90,"y":48,"width":14,"height":48},
{"x":72,"y":96,"width":32,"height":15},
{"x":32,"y":96,"width":40,"height":15},
{"x":24,"y":96,"width":8,"height":8},
{"x":16,"y":96,"width":8,"height":8},
{"x":16,"y":104,"width":8,"height":8},
{"x":0,"y":96,"width":16,"height":16},{"x":0,"y":112,"width":32,"height":24},{"x":32,"y":111,"width":32,"height":24},{"x":72,"y":136,"width":32,"height":24}]

22
games/tileset.json Normal file
View file

@ -0,0 +1,22 @@
{
"image": "tileset.png",
"tiles": [
{"x":0,"y":0,"width":64,"height":24},
{"x":64,"y":0,"width":16,"height":24},
{"x":64,"y":0,"width":16,"height":24},
{"x":0,"y":24,"width":64,"height":24},
{"x":80,"y":52,"width":8,"height":12},
{"x":80,"y":68,"width":8,"height":12},
{"x":0,"y":72,"width":80,"height":24},
{"x":90,"y":48,"width":14,"height":48},
{"x":72,"y":96,"width":32,"height":15},
{"x":32,"y":96,"width":40,"height":15},
{"x":24,"y":96,"width":8,"height":8},
{"x":16,"y":96,"width":8,"height":8},
{"x":16,"y":104,"width":8,"height":8},
{"x":0,"y":96,"width":16,"height":16},
{"x":0,"y":112,"width":32,"height":24},
{"x":32,"y":111,"width":32,"height":24},
{"x":72,"y":136,"width":32,"height":24}
]
}