Coyote = class()
function Coyote:init(x, y, width, height, options)
options = options or {}
self.gc = platform.gc()
self.x = x
self.y = y
self.width = width
self.height = height
self.tiles = {}
self.controls = options.controls or {up = "up",
down = "down",
left = "left",
right = "right"}
self.player = {}
self.tileSize = options.tileSize or 16
self.scrollThreshold = options.scrollThreshold or 1
self.outOfBoundsColor = options.outOfBoundsColor or {0, 0, 0}
self.tileCount = 0
end
function Coyote:loadTile(sprites, color, walkable)
self.tileCount = self.tileCount + 1
self.tiles[self.tileCount] = {}
local tile = self.tiles[self.tileCount]
if type(sprites) == "string" then
tile.sprites = {image.new(sprites)}
elseif type(sprites) == "table" then
tile.sprites = {}
for i = 1, #sprites do
tile.sprites[i] = image.new(sprites[i])
end
end
tile.color = color
tile.walkable = walkable
return self.tileCount
end
function Coyote:handleMoveKey(key)
local direction = (key == self.controls.up and 1)
or (key == self.controls.right and 2)
or (key == self.controls.down and 3)
or (key == self.controls.left and 4)
local map = self.area.map
local player = self.player
if direction == self.player.direction then
local x = player.x + ((direction == 2 and 1) or (direction == 4 and -1) or 0)
local y = player.y + ((direction == 1 and -1) or (direction == 3 and 1) or 0)
if self.tiles[map.data[y][x]].walkable then
local object = self.area:getObjectAt(x, y)
if not object or self.tiles[object.tile].walkable then
player.x = x
player.y = y
end
end
if self:processEvents() then
return
end
map.x = map.x + ((player.x <= map.x + self.scrollThreshold and -1)
or (player.x + self.scrollThreshold > map.x + self.width and 1)
or 0)
map.y = map.y + ((player.y <= map.y + self.scrollThreshold and -1)
or (player.y + self.scrollThreshold > map.y + self.height and 1)
or 0)
end
self.player.direction = direction
end
function Coyote:handleEventKey()
self:processEvents(true)
end
function Coyote:processEvents(keyPressed)
for i = 1, #self.area.events do
local event = self.area.events[i]
if event.x == self.player.x
and event.y == self.player.y
and event.keyPress == (keyPressed or false) then
if not event.direction
or event.direction == self.player.direction then
event.callback()
return true
end
end
end
end
function Coyote:setPlayer(tile, x, y, offsetX, offsetY, direction)
local player = self.player
player.tile = tile
player.x = x
player.y = y
player.offset = {x = offsetX or 0, y = offsetY or 0}
player.direction = direction or 3
end
function Coyote:setArea(area)
self.area = area
end
function Coyote:movePlayer(x, y)
self.player.x = x
self.player.y = y
end
function Coyote:relativeToAbsolutePosition(x, y)
return ((x - self.area.map.x - 1) * self.tileSize) + self.x,
((y - self.area.map.y - 1) * self.tileSize) + self.y
end
function Coyote:drawTileMap()
local x = self.x
local y = self.y
local area = self.area
for i = area.map.y + 1, area.map.y + self.height do
for j = area.map.x + 1, area.map.x + self.width do
if j > 0 and j <= area.map.width and i > 0 and i <= area.map.height
and area.map.data[i][j] > 0 then
local tile = self.tiles[area.map.data[i][j]]
if tile.color then
self.gc:setColorRGB(tile.color[1], tile.color[2], tile.color[3])
self.gc:fillRect(x, y, self.tileSize, self.tileSize)
end
if tile.sprites then
self.gc:drawImage(tile.sprites[1], x, y)
end
elseif self.outOfBoundsColor then
self.gc:setColorRGB(self.outOfBoundsColor[1],
self.outOfBoundsColor[2],
self.outOfBoundsColor[3])
self.gc:fillRect(x, y, self.tileSize, self.tileSize)
end
x = x + self.tileSize
end
x = self.x
y = y + self.tileSize
end
end
function Coyote:drawObjects()
local map = self.area.map
for name, object in pairs(self.area.objects) do
if object.x > map.x and object.x <= map.x + self.width
and object.y > map.y and object.y <= map.y + self.height then
local x, y = self:relativeToAbsolutePosition(object.x, object.y)
self.gc:drawImage(self.tiles[object.tile].sprites[object.currentSprite], x, y)
end
end
end
function Coyote:drawPlayer()
local x, y = self:relativeToAbsolutePosition(self.player.x, self.player.y)
self.gc:drawImage(self.tiles[self.player.tile].sprites[self.player.direction],
x + self.player.offset.x, y + self.player.offset.y)
end
function Coyote:draw()
self:drawTileMap()
self:drawObjects()
self:drawPlayer()
end
Area = class()
function Area:init(super, map, x, y)
self.super = super
self.map = {data = map,
width = #map[1],
height = #map,
x = x or 0,
y = y or 0}
self.objects = {}
self.events = {}
end
function Area:newObject(name, tile, x, y)
self.objects[name] = {tile = tile, x = x, y = y, currentSprite = 1}
end
function Area:newEvent(x, y, direction, keyPress, callback)
table.insert(self.events, {x = x, y = y,
direction = direction,
keyPress = keyPress,
callback = callback})
end
function Area:getObjectAt(x, y)
for _, object in pairs(self.objects) do
if object.x == x and object.y == y then
return object
end
end
end
function Area:moveObject(name, x, y)
self.objects[name].x = x
self.objects[name].y = y
end
function Area:setObjectSprite(name, spriteNumber)
self.objects[name].currentSprite = spriteNumber
end
function Area:destroyObject(name)
self.objects[name] = nil
end
function a1Toa2()
coyote:setArea(a2)
coyote:movePlayer(4, 5)
end
function a2Toa1()
coyote:setArea(a1)
coyote:movePlayer(12, 2)
end
function signRead()
a2:destroyObject("blocking_bush")
end
function on.arrowKey(key)
coyote:handleMoveKey(key)
platform.window:invalidate()
end
function on.enterKey()
coyote:handleEventKey()
platform.window:invalidate()
end
local bushS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0I\166I\166I\166\0\0\165\148\165\148\165\148\0\0\0\0\165\148\165\148\165\148\0\0I\166I\166I\166I\166I\166\0\0\165\148I\166I\166\0\0\165\148\165\148\0\0I\166I\166\165\148\0\0I\166I\166I\166\0\0\0\0\165\148I\166\0\0\0\0\165\148\165\148\0\0\0\0I\166\165\148\0\0\0\0I\166\0\0\165\148\165\148\165\148\165\148\0\0\0\0\165\148\165\148\0\0\0\0\165\148\165\148\165\148\165\148\231\149\165\148I\166I\166\0\0\0\0\165\148\165\148\0\0\0\0\165\148\165\148\0\0\0\0I\166I\166\165\148\165\148I\166\0\0\0\0\0\0\0\0\165\148I\166I\166\165\148\0\0\0\0\0\0\0\0I\166\165\148\165\148\165\148\0\0\0\0\0\0\0\0\165\148I\166I\166\165\148\0\0\0\0\0\0\0\0\165\148\165\148\0\0\165\148\165\148\165\148\165\148\165\148\165\148\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148\231\149\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\165\148I\166\0\0\0\0\0\0\165\148\165\148\0\0\0\0\165\148\165\148\0\0\0\0\0\0I\166\165\148\165\148I\166I\166\0\0\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\0\0I\166I\166\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148\0\0\165\148\165\148\0\0\0\0\165\148I\166\0\0\0\0I\166\165\148\0\0\0\0\165\148\165\148\0\0\0\0\0\0\165\148I\166\0\0\165\148\165\148I\166I\166\165\148\165\148\0\0I\166\165\148\0\0\0\0I\166\0\0\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0I\166I\166I\166\0\0\0\0\0\0\0\0\0\0\165\148\165\148\0\0\0\0\0\0\0\0\0\0I\166I\166"
local flowersS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\150\215\150\215\150\215\0\0\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\150\215\0\0\150\215\150\215\150\215\0\0\150\215\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\0\0\150\215\150\215\014\170\014\170\014\170\150\215\150\215\0\0\198\153\198\153\0\0\198\153\198\153\198\153\0\0\0\0e\149\150\215\014\170\014\170\014\170\150\215e\149\0\0\198\153\0\0\198\153\198\153\198\153\0\0\0\0\0\0e\149e\149\150\215\150\215\150\215e\149e\149\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\150\215\150\215\150\215\0\0\0\0\0\0\0\0\0\0\0\0\0\0\198\153\198\153\0\0\0\0\150\215\0\0\150\215\150\215\150\215\0\0\150\215\0\0\198\153\198\153\198\153\0\0\198\153\198\153\0\0\0\0\150\215\150\215\014\170\014\170\014\170\150\215\150\215\0\0\0\0\198\153\198\153\198\153\0\0\198\153\0\0\0\0e\149\150\215\014\170\014\170\014\170\150\215e\149\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0e\149e\149\150\215\150\215\150\215e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0"
local fenceS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0I\166I\166\165\148\165\148\165\148\165\148I\166I\166I\166I\166\165\148\165\148\165\148\165\148I\166I\166I\166\165\148,\206,\206,\206,\206\165\148I\166I\166\165\148,\206,\206,\206,\206\165\148I\166\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148\201\197,\206,\206,\206,\206\201\197\165\148\165\148\201\197,\206,\206,\206,\206\201\197\165\148\165\148\165\148\201\197\201\197\201\197\201\197\165\148\165\148\165\148\165\148\201\197\201\197\201\197\201\197\165\148\165\148\165\148F\177\165\148\165\148\165\148\165\148F\177\165\148\165\148F\177\165\148\165\148\165\148\165\148F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177\201\197F\177\165\148\165\148F\177\201\197\201\197F\177\201\197F\177\165\148\165\148F\177F\177\201\197F\177\201\197F\177\165\148\165\148F\177F\177\201\197F\177\201\197F\177\165\148\165\148\165\148F\177\201\197F\177\201\197\165\148\165\148\165\148\165\148F\177\201\197F\177\201\197\165\148\165\148\231\149\165\148\165\148\165\148\165\148\165\148\165\148\231\149\231\149\165\148\165\148\165\148\165\148\165\148\165\148\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149"
local stonesS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190"
local signS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148,\206,\206\165\148\165\148\165\148\165\148\165\148\165\148\0\0\165\148,\206,\206,\206,\206,\206\165\148,\206,\206\165\148,\206,\206,\206,\206,\206\165\148\165\148,\206,\206,\206,\206,\206,\206\165\148\165\148,\206,\206,\206,\206,\206,\206\165\148\165\148,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206\165\148\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0\165\148,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206\165\148\0\0\0\0\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148,\206\165\148\0\0\0\0\165\148,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206\165\148\0\0\0\0\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148,\206\165\148\0\0\0\0\165\148,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206\165\148\0\0\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148,\206,\206\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148,\206,\206\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
local linkS = {"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144B\170B\170B\170B\170\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\0\0\164\144B\170B\170\196\186\196\186\196\186\196\186\196\186B\170\164\144\0\0\164\144\0\0\164\144l\246\164\144\164\144B\170\196\186\196\186\196\186B\170B\170B\170B\170\164\144\164\144l\246\164\144\164\144l\246\164\144\164\144B\170\196\186B\170B\170\164\144\164\144B\170B\170B\170\164\144l\246\164\144\164\144\164\213\164\144\224\245\164\144B\170\164\144B\170B\170B\170B\170\164\144\224\245\164\144\164\213\164\144\164\144\164\213\164\213\164\144\224\245\164\144B\170\196\186\196\186\196\186\221\247B\170\164\144\164\144\164\213\164\144\164\144\164\213\164\213\164\144\164\144\224\245\164\144B\170B\170\196\186\196\186B\170\164\144\164\213\164\213\164\144\0\0\164\144\164\144\149\237\164\144\164\144\164\144\164\144B\170\196\186\196\186B\170\164\144\149\237\164\144\0\0\0\0\0\0\164\144\149\237\149\237\149\237\164\144\164\144B\170B\170\196\186\164\144\149\237\164\144\0\0\0\0\0\0\164\144d\193\164\144\149\237\149\237\149\237\164\144B\170B\170\196\186\164\144\164\144\164\144\164\144\0\0\164\144d\193d\193d\193\164\144\164\144\149\237\149\237\164\144B\170\196\186\164\144\164\144d\193d\193\164\144\164\144\164\144\164\144\164\144L\154N\163\164\144\164\144\164\144\164\144\164\144L\154\164\144d\193d\193\164\144\164\144J\238J\238\164\144L\154L\154N\163N\163N\163N\163N\163L\154\164\144d\193\164\144\0\0\164\144J\238J\238\164\144L\154L\154N\163N\163N\163N\163L\154L\154L\154\164\144\0\0\0\0\0\0\164\144\164\144H\247L\154L\154L\154L\154N\163N\163L\154L\154L\154\164\144\0\0\0\0\0\0\0\0\164\144L\154H\247H\247L\154L\154L\154H\247L\154\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144L\154L\154H\247H\247H\247L\154\164\144d\220d\220\164\144\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144L\154L\154L\154\164\144d\220d\220d\220\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144d\220\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0",
"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\0\0\0\0\164\144\164\144\196\186B\170B\170\164\144\0\0\0\0\0\0\0\0\164\144B\170\196\186B\170\164\144\164\144B\170\196\186\196\186B\170\224\245B\170\164\144\164\144\164\144\0\0\0\0\164\144\196\186\196\186\164\144B\170\196\186\196\186B\170B\170\224\245\224\245\164\144\149\237\149\237\164\144\0\0\164\144B\170\196\186\196\186B\170B\170B\170\224\245\224\245\224\245\224\245\164\144\149\237\149\237\164\144\0\0\0\0\164\144B\170\196\186B\170\164\144\224\245\224\245\224\245\164\144\164\144\149\237\149\237\164\144\0\0\0\0\0\0\164\144B\170B\170\164\144l\246\164\144\164\144\164\144\149\237\149\237\149\237\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144l\246\164\213\164\144\149\237\149\237\164\144\164\144\164\213\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\213\164\144\149\237\149\237\164\144\221\247\164\144l\246\164\144\0\0\0\0\0\0\0\0\164\144\149\237\164\144\164\213\164\213\164\144\164\144\164\144\221\247\164\144l\246l\246\164\144\0\0\0\0\0\0\0\0\164\144\149\237\164\144\164\213\164\213l\246l\246\164\213l\246\164\213\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\213\164\213\164\213\164\213\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144d\193d\193d\193\164\144\164\144\164\144\164\144\164\144\164\144J\238\164\144\0\0\0\0\0\0\0\0\164\144\164\144d\193d\193\164\144L\154L\154L\154L\154\164\144\164\144\0\0\0\0\0\0\0\0\164\144J\238J\238\164\144\164\144L\154L\154N\163N\163L\154\164\144\0\0\0\0\0\0\0\0\0\0\164\144J\238J\238\164\144L\154L\154N\163N\163N\163\164\144H\247\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144H\247H\247L\154N\163N\163L\154H\247L\154\164\144\164\144\0\0\0\0\0\0\164\144d\220\164\144L\154L\154H\247H\247H\247H\247L\154\164\144\164\213\224\245\164\144\0\0\0\0\0\0\164\144\164\144\164\144\164\144L\154L\154L\154L\154\164\144\164\213d\220\224\245\164\144\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144d\220d\220d\220\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144B\170B\170\196\186B\170\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144B\170B\170\196\186\196\186\196\186\196\186B\170\164\144\0\0\0\0\0\0\0\0\164\144\0\0\164\144\164\144\224\245B\170B\170\196\186B\170\224\245\164\144B\170\164\144\164\144\0\0\164\144l\246\164\144\149\237\164\144\164\144\224\245\224\245\224\245\224\245\164\144\164\144B\170\164\144l\246\164\144\164\144l\246\164\144\149\237\149\237\149\237\164\144\164\144\164\144\164\144\149\237\149\237\164\144\164\144l\246\164\144\164\144\164\213l\246\164\144\149\237\149\237\149\237\149\237\149\237\149\237\149\237\149\237\164\144l\246\164\213\164\144\164\144\164\213\164\144\149\237\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\149\237\164\144\164\213\164\144\0\0\164\144\164\213\164\144\164\213\221\247\221\247\164\213\164\213\221\247\221\247\164\213\164\144\164\213\164\144\0\0\0\0\0\0\164\144\164\213\164\213\221\247\164\144l\246l\246\164\144\221\247\164\213\164\213\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\213l\246\164\144l\246l\246\164\144l\246\164\213\164\144\164\144\0\0\0\0\0\0\164\144d\193d\193\164\144\164\213l\246l\246l\246l\246\164\213\164\144\164\144d\193\164\144\0\0\0\0\164\144d\193d\193d\193\164\144\164\144\164\213\164\213\164\144\164\144\164\144d\193d\193\164\144\0\0\0\0\164\144d\193d\193\164\144\164\144L\154\164\144\164\144L\154N\163L\154\164\144d\193\164\144\0\0\0\0\164\144d\193\164\144J\238J\238\164\144L\154N\163N\163L\154L\154L\154\164\144\0\0\0\0\0\0\0\0\164\144\164\144J\238J\238\164\144L\154N\163L\154L\154H\247H\247\164\144\0\0\0\0\0\0\0\0\164\144L\154\164\144\164\144\164\144H\247H\247\164\144H\247L\154L\154\164\144\0\0\0\0\0\0\0\0\164\144\164\144L\154L\154H\247H\247H\247\164\144L\154\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144L\154L\154L\154L\154\164\144d\220d\220\224\245\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144d\220\164\144\164\144\164\144\164\144\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0",
"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144B\170B\170\196\186\164\144\164\144\0\0\0\0\164\144\164\144\164\144\0\0\0\0\164\144\164\144\164\144B\170\224\245B\170\196\186\196\186B\170\164\144\164\144B\170\196\186B\170\164\144\164\144\149\237\149\237\164\144\224\245\224\245B\170B\170\196\186\196\186B\170\164\144\196\186\196\186\164\144\0\0\164\144\149\237\149\237\164\144\224\245\224\245\224\245\224\245B\170B\170B\170\196\186\196\186B\170\164\144\0\0\0\0\164\144\149\237\149\237\164\144\164\144\224\245\224\245\224\245\164\144B\170\196\186B\170\164\144\0\0\0\0\0\0\164\144\164\144\149\237\149\237\149\237\164\144\164\144\164\144l\246\164\144B\170B\170\164\144\0\0\0\0\0\0\164\144\164\213\164\144\164\144\149\237\149\237\164\144\164\213l\246\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144l\246\164\144\221\247\164\144\149\237\149\237\164\144\164\213\164\144\164\144\0\0\0\0\0\0\0\0\164\144l\246l\246\164\144\221\247\164\144\164\144\164\144\164\213\164\213\164\144\149\237\164\144\0\0\0\0\0\0\0\0\164\144\164\213l\246\164\213l\246l\246\164\213\164\213\164\144\149\237\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\213\164\213\164\213\164\213\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144J\238\164\144\164\144\164\144\164\144\164\144\164\144d\193d\193d\193\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144L\154L\154L\154L\154\164\144d\193d\193\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\164\144L\154N\163N\163L\154L\154\164\144\164\144J\238J\238\164\144\0\0\0\0\0\0\0\0\164\144H\247\164\144N\163N\163N\163L\154L\154\164\144J\238J\238\164\144\0\0\0\0\0\0\164\144\164\144L\154H\247L\154N\163N\163L\154H\247H\247\164\144\164\144\164\144\0\0\0\0\164\144\224\245\164\213\164\144L\154H\247H\247H\247H\247L\154L\154\164\144d\220\164\144\0\0\0\0\164\144\224\245d\220\164\213\164\144L\154L\154L\154L\154\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144d\220d\220d\220\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}
local map1 = {{2,2,2,2,2,2,2,2,2,2,2,5,2,2,2},
{2,1,1,1,1,1,1,1,1,4,3,5,3,3,2},
{2,1,1,1,1,3,1,1,1,4,4,5,4,4,2},
{2,3,1,5,5,5,5,5,1,1,1,5,1,1,2},
{2,1,1,5,1,1,1,5,3,1,1,5,1,1,2},
{2,1,1,5,1,1,1,5,1,1,1,5,1,1,2},
{2,1,1,5,1,1,1,5,5,5,5,5,3,1,2},
{2,1,1,5,3,1,1,1,1,1,1,1,1,1,2},
{2,1,1,5,1,1,1,1,3,1,1,1,1,1,2},
{2,4,4,2,4,4,1,1,1,1,1,1,3,1,2},
{2,3,3,5,3,4,1,1,1,1,1,1,1,1,2},
{2,2,2,5,2,2,2,2,2,2,2,2,2,2,2}}
local map2 = {{2,2,2,2,2,2},
{2,3,1,1,1,2},
{2,1,1,3,1,2},
{2,1,4,1,4,2},
{2,3,4,1,4,2},
{2,2,2,5,2,2}}
local initialized = false
function on.paint(gc)
if not initialized then
coyote = Coyote(63, 26, 12, 10)
coyote:loadTile(nil, {72, 152, 72}, true)
local bushT = coyote:loadTile(bushS, {40, 120, 56}, false)
coyote:loadTile(flowersS, {72, 152, 72}, true)
coyote:loadTile(fenceS, nil, false)
coyote:loadTile(stonesS, {160, 224, 168}, true)
local signT = coyote:loadTile(signS, nil, false)
local linkT = coyote:loadTile(linkS, nil, false)
coyote:setPlayer(linkT, 2, 2, 0, -8)
a1 = Area(coyote, map1)
a1:newObject("sign", signT, 10, 6)
a1:newEvent(10, 7, 1, true, signRead)
a1:newEvent(12, 1, nil, false, a1Toa2)
a2 = Area(coyote, map2, -3, -2)
a2:newObject("blocking_bush", bushT, 4, 4)
a2:newEvent(4, 6, nil, false, a2Toa1)
coyote:setArea(a1)
initialized = true
end
coyote:draw()
gc:drawRect(62, 25, 193, 161)
end
Anyway joking aside, this looks nice. I will definitively have to give this a try when I have time. Will it support full screen or will it always just use a small portion of the screen due to limitations or something else?Oh no, of course not. It's that small just to show off the scrolling (didn't bother to make a bigger map, maybe I should for the sake of a nicer demo). As I said it'll be a very flexible library, no restrictions.
platform.apilevel = '1.0'
Coyote = class()
function Coyote:init(x, y, width, height, options)
options = options or {}
self.x = x
self.y = y
self.width = width
self.height = height
self.tiles = {}
self.controls = options.controls or {up = "up",
down = "down",
left = "left",
right = "right"}
self.player = {}
self.tileSize = options.tileSize or 16
self.scrollThreshold = options.scrollThreshold or 1
self.outOfBoundsColor = options.outOfBoundsColor or {0, 0, 0}
self.tileCount = 0
end
function Coyote:loadTile(sprites, color, walkable)
self.tileCount = self.tileCount + 1
self.tiles[self.tileCount] = {}
local tile = self.tiles[self.tileCount]
if type(sprites) == "string" then
tile.sprites = {image.new(sprites)}
elseif type(sprites) == "table" then
tile.sprites = {}
for i = 1, #sprites do
tile.sprites[i] = image.new(sprites[i])
end
end
tile.color = color
tile.walkable = walkable
return self.tileCount
end
function Coyote:handleMoveKey(key)
local direction = (key == self.controls.up and 1)
or (key == self.controls.right and 2)
or (key == self.controls.down and 3)
or (key == self.controls.left and 4)
local map = self.area.map
local player = self.player
if direction == self.player.direction then
local x = player.x + ((direction == 2 and 1) or (direction == 4 and -1) or 0)
local y = player.y + ((direction == 1 and -1) or (direction == 3 and 1) or 0)
if self.tiles[map.data[y][x]].walkable then
local object = self.area:getObjectAt(x, y)
if not object or self.tiles[object.tile].walkable then
player.x = x
player.y = y
end
end
if self:processEvents() then
return
end
map.x = map.x + ((player.x <= map.x + self.scrollThreshold and -1)
or (player.x + self.scrollThreshold > map.x + self.width and 1)
or 0)
map.y = map.y + ((player.y <= map.y + self.scrollThreshold and -1)
or (player.y + self.scrollThreshold > map.y + self.height and 1)
or 0)
end
self.player.direction = direction
end
function Coyote:handleEventKey()
self:processEvents(true)
end
function Coyote:processEvents(keyPressed)
for i = 1, #self.area.events do
local event = self.area.events[i]
if event.x == self.player.x
and event.y == self.player.y
and event.keyPress == (keyPressed or false) then
if not event.direction
or event.direction == self.player.direction then
event.callback()
return true
end
end
end
end
function Coyote:setPlayer(tile, x, y, offsetX, offsetY, direction)
local player = self.player
player.tile = tile
player.x = x
player.y = y
player.offset = {x = offsetX or 0, y = offsetY or 0}
player.direction = direction or 3
end
function Coyote:setArea(area)
self.area = area
end
function Coyote:movePlayer(x, y)
self.player.x = x
self.player.y = y
end
function Coyote:relativeToAbsolutePosition(x, y)
return ((x - self.area.map.x - 1) * self.tileSize) + self.x,
((y - self.area.map.y - 1) * self.tileSize) + self.y
end
function Coyote:drawTileMap(gc)
local x = self.x
local y = self.y
local area = self.area
for i = area.map.y + 1, area.map.y + self.height do
for j = area.map.x + 1, area.map.x + self.width do
if j > 0 and j <= area.map.width and i > 0 and i <= area.map.height
and area.map.data[i][j] > 0 then
local tile = self.tiles[area.map.data[i][j]]
if tile.color then
gc:setColorRGB(tile.color[1], tile.color[2], tile.color[3])
gc:fillRect(x, y, self.tileSize, self.tileSize)
end
if tile.sprites then
gc:drawImage(tile.sprites[1], x, y)
end
elseif self.outOfBoundsColor then
gc:setColorRGB(self.outOfBoundsColor[1],
self.outOfBoundsColor[2],
self.outOfBoundsColor[3])
gc:fillRect(x, y, self.tileSize, self.tileSize)
end
x = x + self.tileSize
end
x = self.x
y = y + self.tileSize
end
end
function Coyote:drawObjects(gc)
local map = self.area.map
for name, object in pairs(self.area.objects) do
if object.x > map.x and object.x <= map.x + self.width
and object.y > map.y and object.y <= map.y + self.height then
local x, y = self:relativeToAbsolutePosition(object.x, object.y)
gc:drawImage(self.tiles[object.tile].sprites[object.currentSprite], x, y)
end
end
end
function Coyote:drawPlayer(gc)
local x, y = self:relativeToAbsolutePosition(self.player.x, self.player.y)
gc:drawImage(self.tiles[self.player.tile].sprites[self.player.direction],
x + self.player.offset.x, y + self.player.offset.y)
end
function Coyote:draw(gc)
self:drawTileMap(gc)
self:drawObjects(gc)
self:drawPlayer(gc)
end
Area = class()
function Area:init(super, map, x, y)
self.super = super
self.map = {data = map,
width = #map[1],
height = #map,
x = x or 0,
y = y or 0}
self.objects = {}
self.events = {}
end
function Area:newObject(name, tile, x, y)
self.objects[name] = {tile = tile, x = x, y = y, currentSprite = 1}
end
function Area:newEvent(x, y, direction, keyPress, callback)
table.insert(self.events, {x = x, y = y,
direction = direction,
keyPress = keyPress,
callback = callback})
end
function Area:getObjectAt(x, y)
for _, object in pairs(self.objects) do
if object.x == x and object.y == y then
return object
end
end
end
function Area:moveObject(name, x, y)
self.objects[name].x = x
self.objects[name].y = y
end
function Area:setObjectSprite(name, spriteNumber)
self.objects[name].currentSprite = spriteNumber
end
function Area:destroyObject(name)
self.objects[name] = nil
end
function a1Toa2()
coyote:setArea(a2)
coyote:movePlayer(4, 5)
end
function a2Toa1()
coyote:setArea(a1)
coyote:movePlayer(12, 2)
end
function signRead()
a2:destroyObject("blocking_bush")
end
function on.arrowKey(key)
coyote:handleMoveKey(key)
platform.window:invalidate()
end
function on.enterKey()
coyote:handleEventKey()
platform.window:invalidate()
end
local bushS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0I\166I\166I\166\0\0\165\148\165\148\165\148\0\0\0\0\165\148\165\148\165\148\0\0I\166I\166I\166I\166I\166\0\0\165\148I\166I\166\0\0\165\148\165\148\0\0I\166I\166\165\148\0\0I\166I\166I\166\0\0\0\0\165\148I\166\0\0\0\0\165\148\165\148\0\0\0\0I\166\165\148\0\0\0\0I\166\0\0\165\148\165\148\165\148\165\148\0\0\0\0\165\148\165\148\0\0\0\0\165\148\165\148\165\148\165\148\231\149\165\148I\166I\166\0\0\0\0\165\148\165\148\0\0\0\0\165\148\165\148\0\0\0\0I\166I\166\165\148\165\148I\166\0\0\0\0\0\0\0\0\165\148I\166I\166\165\148\0\0\0\0\0\0\0\0I\166\165\148\165\148\165\148\0\0\0\0\0\0\0\0\165\148I\166I\166\165\148\0\0\0\0\0\0\0\0\165\148\165\148\0\0\165\148\165\148\165\148\165\148\165\148\165\148\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148\231\149\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\165\148I\166\0\0\0\0\0\0\165\148\165\148\0\0\0\0\165\148\165\148\0\0\0\0\0\0I\166\165\148\165\148I\166I\166\0\0\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\0\0I\166I\166\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148\0\0\165\148\165\148\0\0\0\0\165\148I\166\0\0\0\0I\166\165\148\0\0\0\0\165\148\165\148\0\0\0\0\0\0\165\148I\166\0\0\165\148\165\148I\166I\166\165\148\165\148\0\0I\166\165\148\0\0\0\0I\166\0\0\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0I\166I\166I\166\0\0\0\0\0\0\0\0\0\0\165\148\165\148\0\0\0\0\0\0\0\0\0\0I\166I\166"
local flowersS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\150\215\150\215\150\215\0\0\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\150\215\0\0\150\215\150\215\150\215\0\0\150\215\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\0\0\150\215\150\215\014\170\014\170\014\170\150\215\150\215\0\0\198\153\198\153\0\0\198\153\198\153\198\153\0\0\0\0e\149\150\215\014\170\014\170\014\170\150\215e\149\0\0\198\153\0\0\198\153\198\153\198\153\0\0\0\0\0\0e\149e\149\150\215\150\215\150\215e\149e\149\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0\0\0\150\215\150\215\150\215\0\0\0\0\0\0\0\0\0\0\0\0\0\0\198\153\198\153\0\0\0\0\150\215\0\0\150\215\150\215\150\215\0\0\150\215\0\0\198\153\198\153\198\153\0\0\198\153\198\153\0\0\0\0\150\215\150\215\014\170\014\170\014\170\150\215\150\215\0\0\0\0\198\153\198\153\198\153\0\0\198\153\0\0\0\0e\149\150\215\014\170\014\170\014\170\150\215e\149\0\0\0\0\0\0\198\153\198\153\0\0\0\0\0\0\0\0e\149e\149\150\215\150\215\150\215e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0e\149e\149e\149\0\0\0\0"
local fenceS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0I\166I\166\165\148\165\148\165\148\165\148I\166I\166I\166I\166\165\148\165\148\165\148\165\148I\166I\166I\166\165\148,\206,\206,\206,\206\165\148I\166I\166\165\148,\206,\206,\206,\206\165\148I\166\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206\201\197,\206,\206\201\197,\206\165\148\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148,\206,\206\201\197\201\197,\206,\206\165\148\165\148\201\197,\206,\206,\206,\206\201\197\165\148\165\148\201\197,\206,\206,\206,\206\201\197\165\148\165\148\165\148\201\197\201\197\201\197\201\197\165\148\165\148\165\148\165\148\201\197\201\197\201\197\201\197\165\148\165\148\165\148F\177\165\148\165\148\165\148\165\148F\177\165\148\165\148F\177\165\148\165\148\165\148\165\148F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177F\177F\177\165\148\165\148F\177\201\197\201\197F\177\201\197F\177\165\148\165\148F\177\201\197\201\197F\177\201\197F\177\165\148\165\148F\177F\177\201\197F\177\201\197F\177\165\148\165\148F\177F\177\201\197F\177\201\197F\177\165\148\165\148\165\148F\177\201\197F\177\201\197\165\148\165\148\165\148\165\148F\177\201\197F\177\201\197\165\148\165\148\231\149\165\148\165\148\165\148\165\148\165\148\165\148\231\149\231\149\165\148\165\148\165\148\165\148\165\148\165\148\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149\231\149"
local stonesS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\0\0\0\0\0\0\0\0\0\0\0\0\0\0\210\190\210\190\0\0\0\0\210\190\0\0\0\0\210\190\210\190\210\190\0\0\0\0\0\0\0\0\0\0\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190\210\190"
local signS = "\016\0\0\0\016\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148,\206,\206\165\148\165\148\165\148\165\148\165\148\165\148\0\0\165\148,\206,\206,\206,\206,\206\165\148,\206,\206\165\148,\206,\206,\206,\206,\206\165\148\165\148,\206,\206,\206,\206,\206,\206\165\148\165\148,\206,\206,\206,\206,\206,\206\165\148\165\148,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206\165\148\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0\165\148,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206\165\148\0\0\0\0\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148,\206\165\148\0\0\0\0\165\148,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206,\206\165\148,\206\165\148\0\0\0\0\165\148,\206\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148,\206\165\148\0\0\0\0\165\148,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206,\206\165\148\0\0\0\0\0\0\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148,\206,\206\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148,\206,\206\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\165\148\165\148\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
local linkS = {"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144B\170B\170B\170B\170\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\0\0\164\144B\170B\170\196\186\196\186\196\186\196\186\196\186B\170\164\144\0\0\164\144\0\0\164\144l\246\164\144\164\144B\170\196\186\196\186\196\186B\170B\170B\170B\170\164\144\164\144l\246\164\144\164\144l\246\164\144\164\144B\170\196\186B\170B\170\164\144\164\144B\170B\170B\170\164\144l\246\164\144\164\144\164\213\164\144\224\245\164\144B\170\164\144B\170B\170B\170B\170\164\144\224\245\164\144\164\213\164\144\164\144\164\213\164\213\164\144\224\245\164\144B\170\196\186\196\186\196\186\221\247B\170\164\144\164\144\164\213\164\144\164\144\164\213\164\213\164\144\164\144\224\245\164\144B\170B\170\196\186\196\186B\170\164\144\164\213\164\213\164\144\0\0\164\144\164\144\149\237\164\144\164\144\164\144\164\144B\170\196\186\196\186B\170\164\144\149\237\164\144\0\0\0\0\0\0\164\144\149\237\149\237\149\237\164\144\164\144B\170B\170\196\186\164\144\149\237\164\144\0\0\0\0\0\0\164\144d\193\164\144\149\237\149\237\149\237\164\144B\170B\170\196\186\164\144\164\144\164\144\164\144\0\0\164\144d\193d\193d\193\164\144\164\144\149\237\149\237\164\144B\170\196\186\164\144\164\144d\193d\193\164\144\164\144\164\144\164\144\164\144L\154N\163\164\144\164\144\164\144\164\144\164\144L\154\164\144d\193d\193\164\144\164\144J\238J\238\164\144L\154L\154N\163N\163N\163N\163N\163L\154\164\144d\193\164\144\0\0\164\144J\238J\238\164\144L\154L\154N\163N\163N\163N\163L\154L\154L\154\164\144\0\0\0\0\0\0\164\144\164\144H\247L\154L\154L\154L\154N\163N\163L\154L\154L\154\164\144\0\0\0\0\0\0\0\0\164\144L\154H\247H\247L\154L\154L\154H\247L\154\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144L\154L\154H\247H\247H\247L\154\164\144d\220d\220\164\144\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144L\154L\154L\154\164\144d\220d\220d\220\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144d\220\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0",
"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\0\0\0\0\164\144\164\144\196\186B\170B\170\164\144\0\0\0\0\0\0\0\0\164\144B\170\196\186B\170\164\144\164\144B\170\196\186\196\186B\170\224\245B\170\164\144\164\144\164\144\0\0\0\0\164\144\196\186\196\186\164\144B\170\196\186\196\186B\170B\170\224\245\224\245\164\144\149\237\149\237\164\144\0\0\164\144B\170\196\186\196\186B\170B\170B\170\224\245\224\245\224\245\224\245\164\144\149\237\149\237\164\144\0\0\0\0\164\144B\170\196\186B\170\164\144\224\245\224\245\224\245\164\144\164\144\149\237\149\237\164\144\0\0\0\0\0\0\164\144B\170B\170\164\144l\246\164\144\164\144\164\144\149\237\149\237\149\237\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144l\246\164\213\164\144\149\237\149\237\164\144\164\144\164\213\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\213\164\144\149\237\149\237\164\144\221\247\164\144l\246\164\144\0\0\0\0\0\0\0\0\164\144\149\237\164\144\164\213\164\213\164\144\164\144\164\144\221\247\164\144l\246l\246\164\144\0\0\0\0\0\0\0\0\164\144\149\237\164\144\164\213\164\213l\246l\246\164\213l\246\164\213\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\213\164\213\164\213\164\213\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144d\193d\193d\193\164\144\164\144\164\144\164\144\164\144\164\144J\238\164\144\0\0\0\0\0\0\0\0\164\144\164\144d\193d\193\164\144L\154L\154L\154L\154\164\144\164\144\0\0\0\0\0\0\0\0\164\144J\238J\238\164\144\164\144L\154L\154N\163N\163L\154\164\144\0\0\0\0\0\0\0\0\0\0\164\144J\238J\238\164\144L\154L\154N\163N\163N\163\164\144H\247\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144H\247H\247L\154N\163N\163L\154H\247L\154\164\144\164\144\0\0\0\0\0\0\164\144d\220\164\144L\154L\154H\247H\247H\247H\247L\154\164\144\164\213\224\245\164\144\0\0\0\0\0\0\164\144\164\144\164\144\164\144L\154L\154L\154L\154\164\144\164\213d\220\224\245\164\144\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144d\220d\220d\220\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144B\170B\170\196\186B\170\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144B\170B\170\196\186\196\186\196\186\196\186B\170\164\144\0\0\0\0\0\0\0\0\164\144\0\0\164\144\164\144\224\245B\170B\170\196\186B\170\224\245\164\144B\170\164\144\164\144\0\0\164\144l\246\164\144\149\237\164\144\164\144\224\245\224\245\224\245\224\245\164\144\164\144B\170\164\144l\246\164\144\164\144l\246\164\144\149\237\149\237\149\237\164\144\164\144\164\144\164\144\149\237\149\237\164\144\164\144l\246\164\144\164\144\164\213l\246\164\144\149\237\149\237\149\237\149\237\149\237\149\237\149\237\149\237\164\144l\246\164\213\164\144\164\144\164\213\164\144\149\237\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\149\237\164\144\164\213\164\144\0\0\164\144\164\213\164\144\164\213\221\247\221\247\164\213\164\213\221\247\221\247\164\213\164\144\164\213\164\144\0\0\0\0\0\0\164\144\164\213\164\213\221\247\164\144l\246l\246\164\144\221\247\164\213\164\213\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\213l\246\164\144l\246l\246\164\144l\246\164\213\164\144\164\144\0\0\0\0\0\0\164\144d\193d\193\164\144\164\213l\246l\246l\246l\246\164\213\164\144\164\144d\193\164\144\0\0\0\0\164\144d\193d\193d\193\164\144\164\144\164\213\164\213\164\144\164\144\164\144d\193d\193\164\144\0\0\0\0\164\144d\193d\193\164\144\164\144L\154\164\144\164\144L\154N\163L\154\164\144d\193\164\144\0\0\0\0\164\144d\193\164\144J\238J\238\164\144L\154N\163N\163L\154L\154L\154\164\144\0\0\0\0\0\0\0\0\164\144\164\144J\238J\238\164\144L\154N\163L\154L\154H\247H\247\164\144\0\0\0\0\0\0\0\0\164\144L\154\164\144\164\144\164\144H\247H\247\164\144H\247L\154L\154\164\144\0\0\0\0\0\0\0\0\164\144\164\144L\154L\154H\247H\247H\247\164\144L\154\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144L\154L\154L\154L\154\164\144d\220d\220\224\245\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144d\220\164\144\164\144\164\144\164\144\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0",
"\016\0\0\0\024\0\0\0\0\0\0\0 \0\0\0\016\0\001\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144B\170B\170\196\186\164\144\164\144\0\0\0\0\164\144\164\144\164\144\0\0\0\0\164\144\164\144\164\144B\170\224\245B\170\196\186\196\186B\170\164\144\164\144B\170\196\186B\170\164\144\164\144\149\237\149\237\164\144\224\245\224\245B\170B\170\196\186\196\186B\170\164\144\196\186\196\186\164\144\0\0\164\144\149\237\149\237\164\144\224\245\224\245\224\245\224\245B\170B\170B\170\196\186\196\186B\170\164\144\0\0\0\0\164\144\149\237\149\237\164\144\164\144\224\245\224\245\224\245\164\144B\170\196\186B\170\164\144\0\0\0\0\0\0\164\144\164\144\149\237\149\237\149\237\164\144\164\144\164\144l\246\164\144B\170B\170\164\144\0\0\0\0\0\0\164\144\164\213\164\144\164\144\149\237\149\237\164\144\164\213l\246\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144l\246\164\144\221\247\164\144\149\237\149\237\164\144\164\213\164\144\164\144\0\0\0\0\0\0\0\0\164\144l\246l\246\164\144\221\247\164\144\164\144\164\144\164\213\164\213\164\144\149\237\164\144\0\0\0\0\0\0\0\0\164\144\164\213l\246\164\213l\246l\246\164\213\164\213\164\144\149\237\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\213\164\213\164\213\164\213\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144J\238\164\144\164\144\164\144\164\144\164\144\164\144d\193d\193d\193\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144L\154L\154L\154L\154\164\144d\193d\193\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\164\144L\154N\163N\163L\154L\154\164\144\164\144J\238J\238\164\144\0\0\0\0\0\0\0\0\164\144H\247\164\144N\163N\163N\163L\154L\154\164\144J\238J\238\164\144\0\0\0\0\0\0\164\144\164\144L\154H\247L\154N\163N\163L\154H\247H\247\164\144\164\144\164\144\0\0\0\0\164\144\224\245\164\213\164\144L\154H\247H\247H\247H\247L\154L\154\164\144d\220\164\144\0\0\0\0\164\144\224\245d\220\164\213\164\144L\154L\154L\154L\154\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144d\220d\220d\220\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\164\144\164\144\164\144\164\144\164\144\164\144\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}
local map1 = {{2,2,2,2,2,2,2,2,2,2,2,5,2,2,2},
{2,1,1,1,1,1,1,1,1,4,3,5,3,3,2},
{2,1,1,1,1,3,1,1,1,4,4,5,4,4,2},
{2,3,1,5,5,5,5,5,1,1,1,5,1,1,2},
{2,1,1,5,1,1,1,5,3,1,1,5,1,1,2},
{2,1,1,5,1,1,1,5,1,1,1,5,1,1,2},
{2,1,1,5,1,1,1,5,5,5,5,5,3,1,2},
{2,1,1,5,3,1,1,1,1,1,1,1,1,1,2},
{2,1,1,5,1,1,1,1,3,1,1,1,1,1,2},
{2,4,4,2,4,4,1,1,1,1,1,1,3,1,2},
{2,3,3,5,3,4,1,1,1,1,1,1,1,1,2},
{2,2,2,5,2,2,2,2,2,2,2,2,2,2,2}}
local map2 = {{2,2,2,2,2,2},
{2,3,1,1,1,2},
{2,1,1,3,1,2},
{2,1,4,1,4,2},
{2,3,4,1,4,2},
{2,2,2,5,2,2}}
local initialized = false
function on.paint(gc)
if not initialized then
coyote = Coyote(63, 26, 12, 10)
coyote:loadTile(nil, {72, 152, 72}, true)
local bushT = coyote:loadTile(bushS, {40, 120, 56}, false)
coyote:loadTile(flowersS, {72, 152, 72}, true)
coyote:loadTile(fenceS, nil, false)
coyote:loadTile(stonesS, {160, 224, 168}, true)
local signT = coyote:loadTile(signS, nil, false)
local linkT = coyote:loadTile(linkS, nil, false)
coyote:setPlayer(linkT, 2, 2, 0, -8)
a1 = Area(coyote, map1)
a1:newObject("sign", signT, 10, 6)
a1:newEvent(10, 7, 1, true, signRead)
a1:newEvent(12, 1, nil, false, a1Toa2)
a2 = Area(coyote, map2, -3, -2)
a2:newObject("blocking_bush", bushT, 4, 4)
a2:newEvent(4, 6, nil, false, a2Toa1)
coyote:setArea(a1)
initialized = true
end
coyote:draw(gc)
gc:drawRect(62, 25, 193, 161)
end
It looks like his project is now named "Owl" :It indeed is, haven't had the time to edit the thread, I'm working rather silently so I can get the most important things up. It'll also have a website and I'll use LuaDoc for the documentation.
https://github.com/Hoffa/Owl (https://github.com/Hoffa/Owl)
Looks quite nice so far. By the way although smooth scrolling cannot be implemented, have you tried 8 pixel scrolling or even 4 pixel scrolling?No but I have tried some sort of smooth scrolling in the past. Way too slow for what it gives back, not worth the pain of implementing it. Well, at least not a this point, maybe if Lua gets a bit faster in the future, then why not.
Smooth scrolling for the character's sprite is easily possible... just a for loops over the coordinates from source to destination (maybe with actually a partial window:invalidate() to accelerate the specific screen part refresh)Looks quite nice so far. By the way although smooth scrolling cannot be implemented, have you tried 8 pixel scrolling or even 4 pixel scrolling?No but I have tried some sort of smooth scrolling in the past. Way too slow for what it gives back, not worth the pain of implementing it. Well, at least not a this point, maybe if Lua gets a bit faster in the future, then why not.
but it's really nice, why did you change the name to owl (i like it, just to know)?I like owls and it's shorter, and somehow feels a lot less clumsy.
My experience with partially updating the screen is that it is pointless. The thing is the TI-Nspire stupidly clears the whole screen before calling on.paint, which means I am required to "draw" (or rather, copy the stuff into some buffer) the whole screen every single time anyway. That's what takes a lot of CPU time, not the actual flipping of the screen. So, just scrolling the characters would be just as slow as scrolling the background (unless I had some blank background).Smooth scrolling for the character's sprite is easily possible... just a for loops over the coordinates from source to destination (maybe with actually a partial window:invalidate() to accelerate the specific screen part refresh)Looks quite nice so far. By the way although smooth scrolling cannot be implemented, have you tried 8 pixel scrolling or even 4 pixel scrolling?No but I have tried some sort of smooth scrolling in the past. Way too slow for what it gives back, not worth the pain of implementing it. Well, at least not a this point, maybe if Lua gets a bit faster in the future, then why not.
But yeah, smooth scrolling for the rest (background and tiles) would indeed be slow.
This is not the case if you only invalidate a certain spot (by giving arguments to invalidate() ).I'd like to see how you do that, as this simple example does clear the whole screen whenever I press the enter key:
I've made some stuff with it (smooth scrolling) and it works very good.
sprite = image.new("some 318*212 ti image")
drawn = false
function on.enterKey()
platform.window:invalidate(10, 10, 10, 10)
end
function on.paint(gc)
if not drawn then
gc:drawImage(sprite, 0, 0)
drawn = true
end
end
well, you make drawn true when painting, so when you press enter, the drawn isn't false anymore and the sprite won't get drawn, just change that drawn=true in =false (or just delete it) and it should workWell that was to show that it does clear the screen every time, which is absolutely dumb speed-wise (i.e. I am forced to recopy all the data to the screen no matter what).
the rest of the code is correct imo
Your code works with me, although I did not use a fullscreen picture (32*32).Actually I tried it on the official emulator, maybe the behavior is different on the actual hardware. Once I return home I'll try it on the calculator, so hopefully that was the reason why it didn't seem to work. Thanks for clearing that up anyway.
When pushing enter only a 10*10 square is cleared.
Edit:
Also, you can expect improvement in the next OS release.
TI did not create Lua for game programming, so its not hard to understand that its not optimized for games.
Anyway, I don't have any problem with TI.Image.
Interesting. Could you sum up how you got to improve the speed? Also does it use any undocumented tricks? Because maybe that won't work in future OSes then :(Well it basically keeps track of tiles that need to be redrawn and only refreshes that part of the screen (which doesn't work on the official emulator). That speeds things up a lot. No undocumented stuff.
EDIT Weird I don't notice much of a frame difference. Is it just due to the getkey speed limitation and lack of smooth character movement?Actually I just noticed that that TNS used the timer to refresh the screen every 0.01s (I was measuring the FPS), rather than updating after moving Link (I uploaded again and updated the link). I think why it doesn't seem to be that much faster is because of the key repeat limitation indeed. Also if I had used a map with loads of sprites you would have seen a huge improvement, but even now it should be quite a bit more responsive.
You should make a demo where the character gradually moves from a tile to another like in some RPGs. I wonder how smooth it would be on-calc.EDIT Weird I don't notice much of a frame difference. Is it just due to the getkey speed limitation and lack of smooth character movement?Actually I just noticed that that TNS used the timer to refresh the screen every 0.01s (I was measuring the FPS), rather than updating after moving Link (I uploaded again and updated the link). I think why it doesn't seem to be that much faster is because of the key repeat limitation indeed. Also if I had used a map with loads of sprites you would have seen a huge improvement, but even now it should be quite a bit more responsive.
If getkey
Set movement distance in one var
End
Else
Move by one pixel along the direction
Decrease the movement variable
hoffa, could anything done with Ndless Lua extensions to improve the engine?I think I'll keep this project as TI-Nspire's official Lua only.
An alternative to the default key press detection?
Scrolling?
A wrapper to nRGBlib's drawTile8Multicolors()?