From f92e88b5548bad697122f493a6c57389227ef7e5 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Fri, 28 Feb 2025 14:05:37 +0100 Subject: [PATCH] add tilemap --- src/img/tilemap-table-16-16.png | Bin 0 -> 133 bytes src/img/tilemap.pxo | Bin 0 -> 621 bytes src/main.lua | 29 ++++++++--------------------- 3 files changed, 8 insertions(+), 21 deletions(-) create mode 100644 src/img/tilemap-table-16-16.png create mode 100644 src/img/tilemap.pxo diff --git a/src/img/tilemap-table-16-16.png b/src/img/tilemap-table-16-16.png new file mode 100644 index 0000000000000000000000000000000000000000..dc72c465c90c887a69385fcaac1575d0a06c6564 GIT binary patch literal 133 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}_MR?|ArY-_ zFKY8KDDbdcZ2Wy+QiRbnLP+3qh_C%ku>}(~J&Sp#AD<_0@W{H>S;YPf%QZ*quT!5+ eQt_O$M8Blr0u!I9{~>pvQ4F50elF{r5}E)KX()jJ literal 0 HcmV?d00001 diff --git a/src/img/tilemap.pxo b/src/img/tilemap.pxo new file mode 100644 index 0000000000000000000000000000000000000000..e1c3ef474c34d601bf32bde5f8b289628a6da3d6 GIT binary patch literal 621 zcmWIWW@Zs#VBp|jxSAIe#q{R2o-ZQ^hVvgARjVuYh!DK>9$nqF5#!|V}(6BqWCs^GT3bVm|G_Hx&M=eKde$5noadO zqO^pz7V5HTn4Lc^72U+dbY3^=#DZ-;_dZ`YoK&J0FliUBF6$Zt1(E65Y{!x`om-U7 zKhRmSE+gTm_WQL~?T%8mPToOGv;D$0JGM@|bTl)2q zcNx2Df$UP2^WAG?JS6kDUC$>TyK&+9>$AUdpE9ed{WqDxe(I&n)g!CDgf<;bTX*=h zF{fVP_PNh2&Tf1zt)vK6}M|6TJ(yd(MC z@yZ&3f41{;O6SelA<8&sqr2{3&DfiFpFRA=9e@(%JLQi~(*lMyg8&1AG?2>7O-xUX z2Zg+TT2W$dYO%hdeokU#YEiu5+jE9|3<^9<4*&jV#@>}#F}a-6Q$1tSRK2zLzt5Ie zn>%-VbrsNvhT~=d-i*K~#2v99`+)Hb1@LG_*M{ykm<9%h5}TC$ IeI0BW0L+`_CIA2c literal 0 HcmV?d00001 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.