From 1d824dcc1098df518ad95e5070fc1acf6ddf5814 Mon Sep 17 00:00:00 2001 From: annabunches Date: Thu, 28 Sep 2023 15:02:46 -0400 Subject: [PATCH] Initial commit. --- .gitignore | 1 + Makefile | 4 + license.md | 3 + readme.md | 7 + src/Makefile | 10 + src/ball.lua | 81 ++++++ src/brick.lua | 12 + src/constants.lua | 14 + src/fonts/Mini Mono 2X-table-16-20.png | Bin 0 -> 1825 bytes src/fonts/Mini Mono 2X.fnt | 103 ++++++++ src/fonts/Mini Mono-table-8-10.png | Bin 0 -> 2277 bytes src/fonts/Mini Mono.fnt | 103 ++++++++ src/fonts/font-Bitmore-table-7-11.png | Bin 0 -> 1966 bytes src/fonts/font-Bitmore.fnt | 121 +++++++++ src/fonts/font-Cuberick-Bold-table-12-15.png | Bin 0 -> 3428 bytes src/fonts/font-Cuberick-Bold.fnt | 258 +++++++++++++++++++ src/images/brick.png | Bin 0 -> 485 bytes src/main.lua | 165 ++++++++++++ src/pdxinfo | 5 + src/pixie.lua | 32 +++ src/textbox.lua | 43 ++++ 21 files changed, 962 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 license.md create mode 100644 readme.md create mode 100644 src/Makefile create mode 100644 src/ball.lua create mode 100644 src/brick.lua create mode 100644 src/constants.lua create mode 100644 src/fonts/Mini Mono 2X-table-16-20.png create mode 100644 src/fonts/Mini Mono 2X.fnt create mode 100644 src/fonts/Mini Mono-table-8-10.png create mode 100644 src/fonts/Mini Mono.fnt create mode 100644 src/fonts/font-Bitmore-table-7-11.png create mode 100644 src/fonts/font-Bitmore.fnt create mode 100644 src/fonts/font-Cuberick-Bold-table-12-15.png create mode 100644 src/fonts/font-Cuberick-Bold.fnt create mode 100644 src/images/brick.png create mode 100644 src/main.lua create mode 100644 src/pdxinfo create mode 100644 src/pixie.lua create mode 100644 src/textbox.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e00b594 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pdx diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cf18b5c --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +all: build + +build: + make -C src/ diff --git a/license.md b/license.md new file mode 100644 index 0000000..cea10d7 --- /dev/null +++ b/license.md @@ -0,0 +1,3 @@ +Copyright 2023 Anna Rose Wiggins. + +All rights reserved. diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..d55d65e --- /dev/null +++ b/readme.md @@ -0,0 +1,7 @@ +## March of the Sinister Bricks + +This is a simple game for the (Playdate)[https://play.date] handheld console. In it, you use the crank to control a paddle, and try to break the bricks marching toward you from the right. + +This is, of course, a completely novel idea and is dissimilar from any other game ever made. + +It was written as part of a series of games to learn the Playdate SDK. diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..e20ce2a --- /dev/null +++ b/src/Makefile @@ -0,0 +1,10 @@ +PLAYDATE_SDK_PATH := ~/playdate +GAME := SinisterBricks + +all: build + +build: clean + PLAYDATE_SDK_PATH=$(PLAYDATE_SDK_PATH) $(PLAYDATE_SDK_PATH)/bin/pdc -k main.lua ../$(GAME).pdx + +clean: + rm -rf ../$(GAME).pdx diff --git a/src/ball.lua b/src/ball.lua new file mode 100644 index 0000000..2f9bb74 --- /dev/null +++ b/src/ball.lua @@ -0,0 +1,81 @@ +import "CoreLibs/graphics" +import "CoreLibs/timer" +import "pixie" + +local gfx = playdate.graphics + +class("Ball", { + direction = {x=5, y=5}, +}).extends(Pixie) + +function Ball:init(width, height, color, x, y) + local img = gfx.image.new(width, height, color) + Ball.super.init(self, img, x, y) + self.collisionResponse = gfx.sprite.kCollisionTypeBounce + + self:levelUpTimer() + + return self +end + +function Ball:levelUpTimer() + playdate.timer.performAfterDelay(5000, + function(ball) + if ball.direction.x > 0 then + ball.direction.x += 1 + else + ball.direction.x -= 1 + end + if ball.direction.y > 0 then + ball.direction.y += 1 + else + ball.direction.y -= 1 + end + + ball:levelUpTimer() + end, + self) +end + +function Ball:move() + local collisions + collisions = select(3, self:moveWithCollisions(self.x + self.direction.x, self.y + self.direction.y)) + + for i=1, #collisions, 1 do + self:changeDirection(collisions[i].normal) + end + + return collisions +end + +function Ball:changeDirection(normal) + local dx,dy = normal:unpack() + if dx ~= 0 then + self.direction.x *= -1 + end + + if dy ~= 0 then + self.direction.y *= -1 + end +end + +function Ball:setDirection(x, y) + x = x or self.direction.x + y = y or self.direction.y + self.direction.x = x + self.direction.y = y +end + +function Ball:deflect() + self:setDirection(1) +end + +function Ball:_normalizePosition() + local changeVector = Ball.super._normalizePosition(self) + if changeVector[1] ~= 0 then + self.direction.x = changeVector[1] + end + if changeVector[2] ~= 0 then + self.direction.y = changeVector[2] + end +end diff --git a/src/brick.lua b/src/brick.lua new file mode 100644 index 0000000..f366597 --- /dev/null +++ b/src/brick.lua @@ -0,0 +1,12 @@ +import "CoreLibs/graphics" + +import "pixie" + +class("Brick").extends(Pixie) + +function Brick:init(x, y) + local img = playdate.graphics.image.new("images/brick.png") + Brick.super.init(self, img, x, y) + return self +end + diff --git a/src/constants.lua b/src/constants.lua new file mode 100644 index 0000000..bbcd826 --- /dev/null +++ b/src/constants.lua @@ -0,0 +1,14 @@ +-- Important constants used by multiple files. + +-- The playable screen limits; this allows us to set aside regions of the screen for +-- UI elements. Pixies will not venture beyond these bounds. +-- This must be coordinated with background images / drawing functions. +constants = { + screenTop = 20, + screenBottom = 240, + screenLeft = 0, + screenRight = 400, +} + +constants.screenHeight = constants.screenBottom - constants.screenTop +constants.screenWidth = constants.screenRight - constants.screenLeft diff --git a/src/fonts/Mini Mono 2X-table-16-20.png b/src/fonts/Mini Mono 2X-table-16-20.png new file mode 100644 index 0000000000000000000000000000000000000000..8b9444a56cb7ec3b9f050d808cf9c01287aa82d8 GIT binary patch literal 1825 zcmYLIdsGrw8o%Hh?UdEJnUkp1XliM-t&@o|9+0%jSLTSM>0mxHdME~{IMcdmp);*I z+LXF!x-KD9iZ%kuIx|{o68RuepfXkk%}rjjpt4|{v-gkt-SeIA-uwN2zwcKb9f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q3@ zC&#-Vo2|@uaPQ&9H3oRz>*oGNQUdZ0r9+7I=rYB=>y>XmukN07Ir6>hMDcjOMALi7 z9w6s_#g-)P-oje6ZQXlpRX6Ds^VpdQkkX z6==VtU*`d!)sfme^!9w0|63(&L?{rSoUdnHSg7C3?CRg-lHvrsd=GoRW*iyqAQpxD zz`uUB85Hg|n{gkUzsR29X*$WoEMwp;&}z<7hHU(mw?ld`=jDmRm2U5s9{NFtO 16 +? 16 +@ 16 \ No newline at end of file diff --git a/src/fonts/Mini Mono-table-8-10.png b/src/fonts/Mini Mono-table-8-10.png new file mode 100644 index 0000000000000000000000000000000000000000..2598ebaf8f82aa0e9a5bddcfa466f46baa094701 GIT binary patch literal 2277 zcmX|DdpHvc8y_qBI@Z1@U1)lav`?$3*>Rh33L|A9R$(q*$F(w3pV?fGOsFk&Tw7am z7={qa6;##whXXzSjs0002w>f-3R z;gdJ$yhUrnZlckHH=IU{C;9}SN?<78NUVN2?;3LE4B*g4yak|<9uC;_ZDfOcHwXY| zKGgiXlKc?(ckKMF3DUFuX=BaT)$!+ZM2)G!41xh#$MFhwZ9Q)|;uNiSGO+5CiK%Ig zx32jZaQ7X3V{S_l-)>$1#SpW0tKO!nW@$1uf5O*_z8y8djH6dyd^4o3@(>J@WW)XK z?_f50jeW>!yb6GA<|}B}y>YCR@kCQ$S_-olp1b0u_|P7@(v&A#@TCE5-deE2Vxa0X&UQQ=2> zV-gdy^I!{0xr9wbtvAi(?0Xqfi7b1j{lMQotAl)V%{Te9S~r8@XkO^WeVW!0DG~Lg zE3h;k<`V7!3pzpX_bTxK;nIrJIvS)X(JE*bfK)&HdCy{JC1sJ<)_qfyuH|f1jJRK7 zK|XG|P*t$LH(&Esqn6f7<^1;d?R=@cJfv(o2W|s>_WsVGu=dE+_iSzjM~bbTjI&)a z2)uaCCgJeQ+8av!>V;s7NlaeB?J!@Y+dNv+-&F-n-!R#tD`oq%l+ROXQl~L&Wb#AG;CW>C+k&IV*dpkH+B` zx0#P$&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055Fd|SF7AI;lj4U@Z!G$L fm)I#YEh#OLWIu{)@@VI`cf-}m-LdLK;IDrHYKE3T literal 0 HcmV?d00001 diff --git a/src/fonts/Mini Mono.fnt b/src/fonts/Mini Mono.fnt new file mode 100644 index 0000000..9e0a620 --- /dev/null +++ b/src/fonts/Mini Mono.fnt @@ -0,0 +1,103 @@ + +space 8 +A 8 +B 8 +C 8 +D 8 +E 8 +F 8 +G 8 +H 8 +I 8 +J 8 +K 8 +L 8 +M 8 +N 8 +O 8 +P 8 +Q 8 +R 8 +S 8 +T 8 +U 8 +V 8 +W 8 +X 8 +Y 8 +Z 8 +[ 8 +\ 8 +] 8 +^ 8 +_ 8 +` 8 +a 8 +b 8 +c 8 +d 8 +e 8 +f 8 +g 8 +h 8 +i 8 +j 8 +k 8 +l 8 +m 8 +n 8 +o 8 +p 8 +q 8 +r 8 +s 8 +t 8 +u 8 +v 8 +w 8 +x 8 +y 8 +z 8 +{ 8 +| 8 +} 8 +~ 8 +¥ 8 +… 8 +™ 8 +‼ 8 +© 8 +® 8 +� 8 +! 8 +" 8 +# 8 +$ 8 +% 8 +& 8 +' 8 +( 8 +) 8 +* 8 ++ 8 +, 8 +- 8 +. 8 +/ 8 +0 8 +1 8 +2 8 +3 8 +4 8 +5 8 +6 8 +7 8 +8 8 +9 8 +: 8 +; 8 +< 8 += 8 +> 8 +? 8 +@ 8 \ No newline at end of file diff --git a/src/fonts/font-Bitmore-table-7-11.png b/src/fonts/font-Bitmore-table-7-11.png new file mode 100644 index 0000000000000000000000000000000000000000..2f5779967a56f9c6dc9516d27f6a74f4c4fc77ae GIT binary patch literal 1966 zcmV;f2T}NmP)Px+Xh}ptRCodHn2B;5Ne)E46Z8MSyrY!$6v-4&2fImK-4Qg7Jb)^SlkZ-uE0{)f1+EV$>CeMzMR)C*JkN10$yPv+AvVMr1Hz9?1Kii>I2G>zqfP5q+og ze#PCvnVlNy84mBvcr){#Go8(gA&Q=hqWXVIULHm8*GBx|+<+clGJCY&!=f<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W5RbFFJeeR!i;a57e!&8F1`2YX_07*qoM6N<$f;v1W A&Hw-a literal 0 HcmV?d00001 diff --git a/src/fonts/font-Bitmore.fnt b/src/fonts/font-Bitmore.fnt new file mode 100644 index 0000000..c0fefb7 --- /dev/null +++ b/src/fonts/font-Bitmore.fnt @@ -0,0 +1,121 @@ +space 2 +! 2 +" 4 +# 6 +$ 5 +% 7 +& 6 +' 2 +( 2 +) 2 +* 3 ++ 5 +, 2 +- 4 +. 2 +/ 4 +0 5 +1 2 +2 5 +3 5 +4 5 +5 5 +6 5 +7 5 +8 5 +9 5 +: 2 +; 3 +< 4 += 5 +> 4 +? 6 +@ 7 +A 5 +B 5 +C 5 +D 5 +E 5 +F 5 +G 5 +H 5 +I 3 +J 5 +K 5 +L 4 +M 7 +N 7 +O 5 +P 5 +Q 6 +R 5 +S 5 +T 5 +U 5 +V 7 +W 7 +X 7 +Y 5 +Z 5 +[ 2 +\ 4 +] 2 +^ 6 +_ 5 +` 2 +a 6 +b 5 +c 5 +d 5 +e 5 +f 5 +g 5 +h 5 +i 2 +j 4 +k 5 +l 2 +m 7 +n 5 +o 5 +p 5 +q 5 +r 5 +s 5 +t 4 +u 5 +v 5 +w 5 +x 5 +y 5 +z 5 +{ 4 +| 2 +} 4 +~ 4 +ag -1 +at -1 +av -1 +ay -1 +ff -2 +fi -1 +fr -1 +ft -1 +fu -2 +le -1 +is -1 +it -1 +iv -1 +li -1 +ll -1 +iz -1 +ly -1 +rc -1 +re -1 +ri -1 +ro -1 +tf -1 +rt -1 +ry -1 +vi -1 +tt -1 \ No newline at end of file diff --git a/src/fonts/font-Cuberick-Bold-table-12-15.png b/src/fonts/font-Cuberick-Bold-table-12-15.png new file mode 100644 index 0000000000000000000000000000000000000000..69cc81ba9dade282c9faaefd210dbfdda6d548f4 GIT binary patch literal 3428 zcmYk9dpHve`^P7Rmz?qlvrV2=N=g#uu;@{y13jgYLvuC^Va;K4$fF{MEk(((S|!Ft za>|CDnMomK=FFBu4#Uixn!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src/images/brick.png b/src/images/brick.png new file mode 100644 index 0000000000000000000000000000000000000000..53f4513e3afb25864f4e04a99073b3a4971e4f2d GIT binary patch literal 485 zcmVEX>4Tx04R~2kUdMoP!xurRPhU)lnyGG!L^%qa`1}=heB;D7@g9a7K=#?NlNh_ z_)ql5bPxppg1dsV?~M))X7R$|eK?%+zV}|Jxsi$U`9p}4BJ;XO{-uBAF21qM7IpU6 z2~3{0d#yf|=kpcE>Py3VRnPr-7Q$g}q%&1w(yRdIK-`=bsbv)#xBc#k_(AN3aT1E3 z#Jgb}TDH60IGUIrPkWoyVRF&4ebqJ|XSC_yGGM}(h=PVRQRkE<`%;gLfO~R`G-9aU zR5JxPqFhcM$D+PSx2ee6Eb}@_8OUQSFPm^jEKi$<{on7kkMnZVsn60N3(D4K4y*A-byzu#6d(=2EH`Nl7S?NG7WleO6Z000SaNLh0L04^f{04^f|c%?sf z00007bV*G`2j>YJ7B>nd_CX>@2HM@dak zSAh-}0000mNklB44PZjY*P?X9~S;< bP0q~;_arR!? = playdate.graphics + +local brickFreq = 0.7 + +local paddle = nil +local deadWall = nil +local ball = nil + +local startTime = nil +local endTime = nil +local timeWidget = nil +local speedWidget = nil + +function setup() + playdate.resetElapsedTime() + math.randomseed(playdate.getSecondsSinceEpoch()) + + paddle = Pixie.new(6, 50, gfx.kColorWhite, 6, 120) + paddle:add() + ball = Ball(6, 6, gfx.kColorWhite, 12, 120) + ball:add() + + addWallColliders() + setupBricks() + + timeWidget = TextBox(100, 20, 350, 10, 5, kTextAlignment.center) + updateTimeWidget() + timeWidget:add() + + speedWidget = TextBox(100, 20, 50, 10, 5, kTextAlignment.center) + updateSpeedWidget() + speedWidget:add() + + local backgroundImage = gfx.image.new(400, 220, gfx.kColorBlack) + gfx.sprite.setBackgroundDrawingCallback( + function(x, y, width, height) + backgroundImage:draw(0, 20) + end + ) + + startTime = playdate.getElapsedTime() +end + +function addWallColliders() + -- set up border boundaries + -- top + gfx.sprite.addEmptyCollisionSprite(constants.screenLeft, constants.screenTop, + constants.screenWidth, 1) + -- right + gfx.sprite.addEmptyCollisionSprite(constants.screenRight, constants.screenTop, + 1, constants.screenHeight) + -- bottom + gfx.sprite.addEmptyCollisionSprite(constants.screenLeft, constants.screenBottom, + constants.screenWidth, 1) + + -- left + deadWall = Pixie.new(1, constants.screenHeight, gfx.kColorClear, + 0, constants.screenHeight / 2 + constants.screenTop) + deadWall:add() +end + +function setupBricks() + for i=1,12 do + addBrickRow() + advanceBricks() + end +end + +function addBrickRow() + for i=1,10 do + if math.random() < brickFreq then + local brick = Brick(constants.screenRight - 5, + constants.screenTop + (22 * (i-1)) + 11) + brick:add() + end + end +end + +function advanceBricks() + -- move all the bricks over + local sprites = gfx.sprite.getAllSprites() + for i=1, #sprites, 1 do + local brick = sprites[i] + if brick:isa(Brick) then + brick:moveBy(-10, 0) + end + end +end + +function playdate.update() + gfx.clear() + + if endTime then + if playdate.buttonJustPressed(playdate.kButtonA) then + gfx.sprite.removeAll() + playdate.file.run("main.pdz") + end + else + -- Handle player movement + movePaddle(playdate.getCrankTicks(80)) + + -- Handle ball movement + collision + moveBall() + + -- UI Updates + updateTimeWidget() + updateSpeedWidget() + + playdate.timer.updateTimers() + end + + gfx.sprite.update() +end + +function updateTimeWidget() + timeWidget:setText(string.format("time: %.2f", playdate.getElapsedTime())) +end + +function updateSpeedWidget() + speedWidget:setText(string.format("speed: " .. math.abs(ball.direction.x) - 4)) +end + +function movePaddle(ticks) + if ticks == 0 then return end + paddle:moveWithCollisions(paddle.x, paddle.y + ticks*-5) +end + +function moveBall() + local collisions = ball:move() + for i = 1, #collisions, 1 do + local obj = collisions[i].other + if obj:isa(Brick) then + obj:remove() + end + if obj == deadWall then + endGame() + end + end +end + +function endGame() + endTime = playdate.getElapsedTime() + + local textBox = TextBox(275, 40, 200, 120, 5, kTextAlignment.center) + textBox:setText( + "Game Over!\nYou survived for " .. + string.format("%.2f", endTime) .. + " seconds.\n Press 'A' to play again." + ) + textBox:add() +end + +setup() diff --git a/src/pdxinfo b/src/pdxinfo new file mode 100644 index 0000000..5a8f321 --- /dev/null +++ b/src/pdxinfo @@ -0,0 +1,5 @@ +name=March of the Sinister Bricks +author=Anna Rose Wiggins +description=You think they're essential masonry supplies but I think they're sinister. +bundleID=net.annabunches.sinister-bricks +version=0.1 diff --git a/src/pixie.lua b/src/pixie.lua new file mode 100644 index 0000000..c7d9b7a --- /dev/null +++ b/src/pixie.lua @@ -0,0 +1,32 @@ +-- A pixie is like a sprite, but better +-- built-in collider, support for setting position at creation +-- ideal for subclassing sprites that don't need a custom +-- draw function + +import "CoreLibs/object" +import "CoreLibs/graphics" +import "CoreLibs/sprites" + +import "constants" + +local gfx = playdate.graphics + +class("Pixie").extends(gfx.sprite) + +-- automatically initialize pixie with a simple rectangle. +-- great for simple games or for debugging +function Pixie.new(width, height, color, x, y) + local img = gfx.image.new(width, height, color) + local pixie = Pixie(img, x, y) + return pixie +end + +function Pixie:init(img, x, y) + x = x or 0 + y = y or 0 + + Pixie.super.init(self, img) + self:setCollideRect(0, 0, self:getSize()) + self:moveTo(x, y) + return self +end diff --git a/src/textbox.lua b/src/textbox.lua new file mode 100644 index 0000000..caed2e3 --- /dev/null +++ b/src/textbox.lua @@ -0,0 +1,43 @@ +import "CoreLibs/graphics" +import "CoreLibs/object" +import "pixie" + +local gfx = playdate.graphics + +local defaultFont = gfx.font.new("fonts/Mini Mono") + +class("TextBox").extends(gfx.sprite) + +function TextBox:init(w, h, x, y, vert, align, font) + TextBox.super.init(self) + + self:setSize(w, h) + self:moveTo(x, y) + self:setZIndex(999) + self.align = align or kTextAlignment.left + self.font = font or defaultFont + self.vert = vert + self.text = "" +end + +function TextBox:setText(text) + self.text = text +end + +function TextBox:draw(x, y, w, h) + gfx.pushContext() + + gfx.setColor(gfx.kColorWhite) + gfx.fillRect(x, y, w, h) + gfx.setColor(gfx.kColorBlack) + gfx.drawRoundRect(x, y, w, h, 2) + + gfx.setFont(self.font) + gfx.drawTextInRect( + self.text, + x, y+self.vert, w, h, nil, nil, self.align + ) + + gfx.popContext() +end +