diff --git a/src/img/tilemap-table-16-16.png b/src/img/tilemap-table-16-16.png new file mode 100644 index 0000000..dc72c46 Binary files /dev/null and b/src/img/tilemap-table-16-16.png differ diff --git a/src/img/tilemap.pxo b/src/img/tilemap.pxo new file mode 100644 index 0000000..e1c3ef4 Binary files /dev/null and b/src/img/tilemap.pxo differ diff --git a/src/main.lua b/src/main.lua index fd08daa..3308c1d 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,37 +1,19 @@ --- Name this file `main.lua`. Your game can use multiple source files if you wish --- (use the `import "myFilename"` command), but the simplest games can be written --- with just `main.lua`. - --- You'll want to import these in just about every project you'll work on. - import "CoreLibs/object" import "CoreLibs/graphics" import "CoreLibs/sprites" import "CoreLibs/timer" --- Declaring this "gfx" shorthand will make your life easier. Instead of having --- to preface all graphics calls with "playdate.graphics", just use "gfx." --- Performance will be slightly enhanced, too. --- NOTE: Because it's local, you'll have to do it in every .lua source file. - local gfx = playdate.graphics --- Here's our player sprite declaration. We'll scope it to this file because --- several functions need to access it. - local playerSprite = nil --- A function to set up our game environment. - function myGameSetUp() - -- Set up the player sprite. - local playerImage = gfx.image.new("img/player.png") - assert(playerImage) -- make sure the image was where we thought + assert(playerImage) playerSprite = gfx.sprite.new(playerImage) - playerSprite:moveTo(200, 120) -- this is where the center of the sprite is placed; (200,120) is the center of the Playdate screen - playerSprite:add() -- This is critical! + 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: @@ -50,6 +32,11 @@ function myGameSetUp() -- 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) end -- Now we'll call the function above to configure our game.