diff --git a/justfile b/justfile index 07a4450..04d0f73 100644 --- a/justfile +++ b/justfile @@ -2,7 +2,7 @@ bin := "Rush.pdx" alias b := build build: - pdc src {{ bin }} + pdc --quiet --skip-unknown src {{ bin }} alias s := simu simu: build diff --git a/src/img/bg_atlas-table-32-32.png b/src/img/bg_atlas-table-32-32.png new file mode 100644 index 0000000..8a58543 Binary files /dev/null and b/src/img/bg_atlas-table-32-32.png differ diff --git a/src/img/bg_atlas.pxo b/src/img/bg_atlas.pxo new file mode 100644 index 0000000..351d70b Binary files /dev/null and b/src/img/bg_atlas.pxo differ diff --git a/src/img/player.png b/src/img/player.png index c4722bd..3d5b500 100644 Binary files a/src/img/player.png and b/src/img/player.png differ diff --git a/src/img/player.pxo b/src/img/player.pxo new file mode 100644 index 0000000..77d9161 Binary files /dev/null and b/src/img/player.pxo differ diff --git a/src/img/tilemap-table-16-16.png b/src/img/tilemap-table-16-16.png deleted file mode 100644 index dc72c46..0000000 Binary files a/src/img/tilemap-table-16-16.png and /dev/null differ diff --git a/src/img/tilemap.pxo b/src/img/tilemap.pxo deleted file mode 100644 index e1c3ef4..0000000 Binary files a/src/img/tilemap.pxo and /dev/null differ diff --git a/src/main.lua b/src/main.lua index 3308c1d..2717867 100644 --- a/src/main.lua +++ b/src/main.lua @@ -6,48 +6,24 @@ import "CoreLibs/timer" local gfx = playdate.graphics local playerSprite = nil +local atlas = nil -function myGameSetUp() - local playerImage = gfx.image.new("img/player.png") +function gameInit() + local playerImage = gfx.image.new("img/player") assert(playerImage) playerSprite = gfx.sprite.new(playerImage) playerSprite:moveTo(200, 120) -- (200,120) is the center of the Playdate screen playerSprite:add() - -- We want an environment displayed behind our sprite. - -- There are generally two ways to do this: - -- 1) Use setBackgroundDrawingCallback() to draw a background image. (This is what we're doing below.) - -- 2) Use a tilemap, assign it to a sprite with sprite:setTilemap(tilemap), - -- and call :setZIndex() with some low number so the background stays behind - -- your other sprites. - - -- local backgroundImage = gfx.image.new("Images/background") - -- assert(backgroundImage) - - -- gfx.sprite.setBackgroundDrawingCallback( - -- function(x, y, width, height) - -- -- x,y,width,height is the updated area in sprite-local coordinates - -- -- The clip rect is already set to this area, so we don't need to set it ourselves - -- backgroundImage:draw(0, 0) - -- end - -- ) - - local table = gfx.imagetable.new("img/tilemap-table-16-16.png") - local map = gfx.tilemap.new() - map:setImageTable(table) - map:draw(0, 0) + atlas = gfx.imagetable.new("img/bg_atlas") end -- Now we'll call the function above to configure our game. -- After this runs (it just runs once), nearly everything will be -- controlled by the OS calling `playdate.update()` 30 times a second. -myGameSetUp() - --- `playdate.update()` is the heart of every Playdate game. --- This function is called right before every frame is drawn onscreen. --- Use this function to poll input, run game logic, and move sprites. +gameInit() function playdate.update() -- Poll the d-pad and move our player accordingly. @@ -74,4 +50,5 @@ function playdate.update() gfx.sprite.update() playdate.timer.updateTimers() + atlas:drawImage(1, 32, 32) end