Skip to content

Instantly share code, notes, and snippets.

@andimiller
Last active March 9, 2022 00:08
Show Gist options
  • Save andimiller/a2620e6d9d18d18255f915211dd49b53 to your computer and use it in GitHub Desktop.
Save andimiller/a2620e6d9d18d18255f915211dd49b53 to your computer and use it in GitHub Desktop.
import "CoreLibs/object"
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/timer"
local gfx <const> = playdate.graphics
-- playdate.display.setScale(2)
tiles = gfx.imagetable.new('tiles/farm')
playerTiles = gfx.imagetable.new('tiles/actor')
map = gfx.tilemap.new()
playerMap = gfx.tilemap.new()
map:setImageTable(tiles)
map:setSize(100,100)
playerMap:setImageTable(playerTiles)
playerMap:setSize(25, 15)
local map1 = {577,577,577,577,577,577,577,609,609,609,577,577,577,609,609,577,577,577,609,609,577,577,577,577,577,577,577,577,577,609,609,609,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,593,577,609,609,609,609,609,577,577,609,609,577,577,609,609,609,609,593,577,577,577,577,577,577,577,609,609,577,577,577,577,577,593,593,593,593,577,577,593,593,577,577,577,577,593,593,593,593,593,593,593,593,593,609,577,577,609,609,609,577,609,593,593,593,609,609,609,609,609,609,593,593,593,593,577,609,609,577,577,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,344,344,-1,-1,-1,-1,-1,-1,-1,593,593,593,593,593,593,593,593,577,577,577,609,609,609,609,609,609,577,577,577,577,577,593,609,593,593,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,593,593,593,593,609,593,609,609,577,593,593,593,593,593,593,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,593,593,593,593,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,305,306,307,308,309,310,-1,-1,-1,344,344,-1,359,360,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,402,403,404,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,321,322,323,324,325,326,-1,-1,-1,344,344,-1,375,376,-1,-1,-1,366,367,367,367,367,367,367,368,-1,-1,417,418,419,420,421,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,295,-1,-1,-1,-1,-1,-1,295,337,338,339,340,341,342,295,-1,-1,344,344,-1,391,392,-1,-1,-1,382,233,233,233,233,233,233,384,-1,-1,433,434,435,436,437,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,311,-1,-1,-1,-1,-1,-1,311,353,354,355,356,357,358,311,-1,-1,344,344,-1,-1,-1,-1,-1,-1,382,233,233,233,233,233,233,384,-1,-1,449,450,451,452,453,-1,-1,-1,-1,-1,295,-1,-1,-1,-1,327,-1,-1,-1,-1,-1,-1,327,369,370,371,372,373,374,327,-1,-1,344,344,-1,-1,-1,-1,-1,-1,382,233,233,233,233,233,233,384,-1,-1,465,466,467,468,469,-1,-1,-1,-1,-1,311,-1,-1,-1,-1,343,-1,-1,-1,-1,-1,-1,343,385,386,387,388,389,390,343,-1,-1,344,344,359,360,-1,-1,-1,-1,382,233,233,233,233,233,233,384,-1,-1,481,482,483,484,485,329,330,-1,-1,-1,327,-1,-1,-1,-1,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,344,375,376,-1,-1,-1,-1,398,399,399,233,233,399,399,400,-1,-1,497,498,499,500,501,345,346,-1,-1,-1,343,-1,-1,-1,-1,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,344,391,392,-1,359,360,-1,-1,-1,-1,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,749,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,375,376,-1,-1,-1,-1,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,-1,-1,391,392,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,749,749,539,540,541,542,543,544,-1,-1,82,-1,-1,82,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,749,749,555,556,557,558,559,560,-1,-1,-1,-1,-1,-1,-1,-1,-1,344,344,-1,359,360,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,90,-1,-1,-1,-1,-1,-1,-1,90,-1,-1,-1,-1,-1,-1,749,749,571,572,573,574,575,576,-1,331,332,333,-1,-1,82,-1,-1,344,344,-1,375,376,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,90,-1,-1,-1,-1,-1,-1,-1,-1,-1,749,749,587,588,589,590,591,592,-1,347,348,349,-1,-1,-1,-1,-1,344,344,-1,391,392,-1,-1,-1,82,-1,90,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,749,749,603,604,605,606,607,608,-1,363,364,365,-1,-1,82,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,-1,-1,-1,-1,-1,300,301,-1,-1,-1,-1,82,-1,749,749,619,620,621,622,623,624,-1,379,380,381,-1,-1,-1,-1,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,-1,316,317,-1,-1,-1,-1,-1,-1,749,749,749,749,749,749,639,640,-1,395,396,397,-1,331,332,333,-1,344,344,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,300,301,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,90,765,765,765,765,765,765,-1,-1,-1,-1,-1,-1,-1,347,348,349,-1,344,344,-1,-1,359,360,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,316,317,-1,-1,-1,-1,-1,-1,-1,-1,-1,65,66,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,-1,-1,363,364,365,-1,344,344,-1,-1,375,376,-1,-1,-1,82,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,90,-1,-1,-1,81,82,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,379,380,381,-1,344,344,-1,-1,391,392,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,82,-1,-1,82,-1,-1,-1,-1,82,-1,-1,-1,-1,395,396,397,-1,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344,344}
local emptyPlayer = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
map:setTiles(map1, 50)
playerMap:setTiles(emptyPlayer, 25)
x = 15
y = 8
lookDown = 1
lookUp = 2
lookRight = 3
lookLeft = 4
playerSprite = lookDown
function playdate.update()
gfx.setColor(gfx.kColorWhite)
gfx.fillRect(0,0,400,240)
print("x", x, "and y", y)
map:draw(0,0)
-- clear player layer
playerMap:setTiles(emptyPlayer, 25)
-- add player
playerMap:setTileAtPosition(x, y, playerSprite)
-- render
playerMap:draw(0,0)
end
function playdate.leftButtonDown()
x = x - 1
playerSprite = lookLeft
end
function playdate.rightButtonDown()
x = x + 1
playerSprite = lookRight
end
function playdate.upButtonDown()
y = y - 1
playerSprite = lookUp
end
function playdate.downButtonDown()
y = y + 1
playerSprite = lookDown
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment