From 76f548d6c466093c6c6715873a2f7ef55912f4cb Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Thu, 7 Jan 2021 02:15:15 -0600 Subject: [PATCH] Add bananna and zoom in/out feature --- art/sprites/bananna.png | Bin 0 -> 227 bytes art/sprites/bananna.wb | Bin 0 -> 10188 bytes main.lua | 36 +++++++++++++++++++++++++-- maps/README.txt | 9 +++++++ maps/tutorial/1.lua | 53 ++++++++++++++++++++++++---------------- maps/tutorial/1.tmx | 15 ++++++------ 6 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 art/sprites/bananna.png create mode 100644 art/sprites/bananna.wb diff --git a/art/sprites/bananna.png b/art/sprites/bananna.png new file mode 100644 index 0000000000000000000000000000000000000000..804655b135c7b68a985d2cc20e94aaa2020b50f3 GIT binary patch literal 227 zcmV<90382`P)|6a>d8Nkx-}ikv7{uyQ!$#s}a;P^F=vN~FA0Mo+f+Sdp@wEzRs=0soFMM)bM* z1ulvgq#tY|IK1Hcd}Qwr3A`WxbL)s#>A(P!nvvhZ7-QA?I z51O_@?So}42z`=*;KzfqLisb& zymwzWc$mukihh&o9~^WzzPnQ4N%J);t5Q^p2Jrfk$CTPgtzj_=B7h5?V>E;4(D42q zjIfCcE_@D=ZMwBv90tDDocT zeV%B4Ma=Dgou~gr;_ImxNicV&)N+#$n9sdr+*&(Lj{~P(Z@tj^ z*Vf~sNB`};(s%0fcP_4faogqZ{`jTo(vhVzHy`cY(Y9@N>Daf&&u{Df^6L}dJn`hY z#hqJTdQjck`O~{GJC(^=xm?0dJM$T{)46ao1YMWR>YsR3_|f%FL^9 zL@CnR2Q4*scd(W87A+6V5LOYc>S}UV3udCpSxMl}JBn(4HLE@S-McYcQ7SJ}aaYEA z)zjVQtPIpYqk@%T(7aajaDnPyP;qC@yYi0Hz*xaNKMTZNJ>@N}yc483ONM_)95!HO z>nm@Z{BrdhJS#rw!w*+@ENSL)PDJ)u>HTgjo2mcdteMU^VIEIfs)a~bHa3}C)M3-8PCr7XU)AZycKQqzT<+5FPV=+G(asGY0_GSsRJDgzqZ%-C2UoyqiN_Hq zJ7HLD!OttTK+ziMQtHjFjGaj5kq41Za+J`l7D%vm#>NCz5Ll5|8*2;J!dS_Ng_*8Q zI*EbnHbWyZjHBydhs26Z2OlI>5Oj!*J_ceZF~l{9j*o%JpRMN-T(d zk{^=41;IB-2gYqF39RhHxW8c`24H*)zy5d(V2i|})Th2Silmd+2-BfIiSf3uk2AED z81E0ZNNh5IEf|-#m23fP_w?tUH}RW8Dv^#<52RExXI5&n9lPm?JIDk4<~8+se#3!c z7Ztzr+YLiLzb*OjH57;10mOUos*m%VVHk~ZeuE>c&u?v%1gi2-IM%sxenW2H-mmWw z$X$soQ1hBDSRO6Xj}Srf=qxSBdi)&(zeHT4obbz|ljIljB1GQlzxJmerx-IA{EHL=Ob%=w`qSQ`eMUO7nUU%o2 zLEh^c_nD!=_c|mRHXt*<)X}HT&`x5oQP;r^i4{G%V0+F(ltV$z zDT_vZo>RzddI!LN&$&nf>6~)ehhMGm`aP#K_@09#!Y0v9f3bv8xo@d~9JcLLBxy}sNvcHmIMo=vJVo!G XsM+OC+RQt1llGy=fvH5?$|>VN`U(kO literal 0 HcmV?d00001 diff --git a/main.lua b/main.lua index 872aeb0..6845528 100644 --- a/main.lua +++ b/main.lua @@ -180,6 +180,7 @@ function game_draw () map:draw() player:draw() + bananna:draw() camera:detach() camera:draw() @@ -208,6 +209,11 @@ function game_keypressed(key) player.following = true elseif (key == "f" and player.following == true) then player.following = false + + elseif (key == "=" and camera.scale < 10) then + camera.scale = camera.scale + 1 + elseif (key == "-" and camera.scale > 1) then + camera.scale = camera.scale - 1 end end @@ -424,6 +430,25 @@ end +-- BANNANA owo (win condition obj) +---------------------------------------- +Bananna = class('Bananna') +world:addCollisionClass('Bananna') + +function Bananna:initialize(x, y) + self.sprite = love.graphics.newImage("art/sprites/bananna.png") + self.collider = world:newRectangleCollider(x, y, 16, 16); +end + + +function Bananna:draw() + local col = self.collider + local x,y = col.body:getWorldPoints(col.shape:getPoints()) + love.graphics.draw(self.sprite, x, y, col.body:getAngle(), 1, 1) +end + + + -- MAP used to store map data (ofc) ---------------------------------------- Map = class('Map') @@ -437,6 +462,9 @@ function Map:initialize(filepath) local maptable = dofile(filepath) love.graphics.setBackgroundColor(146/255, 187/255, 203/255) + local monkCount = 3 + local monkX,monkY = 100,100 + local banannaX,banannaY = 200,200 for n,layer in pairs(maptable.layers) do if not (layer.type == "objectgroup") then break; end @@ -452,15 +480,19 @@ function Map:initialize(filepath) self.objects[o_c]:setCollisionClass('Platform') elseif (object.shape == "point" and object.type == "spawn") then - local monkCount = 3 if not (object.properties == nil and object.properties["count"] == nil) then monkCount = object.properties["count"] end - player = Monk:new(object.x, object.y, monkCount) + monkX,monkY = object.x,object.y + + elseif (object.shape == "point" and object.type == "bananna") then + banannaX,banannaY = object.x,object.y end end end + player = Monk:new(monkX, monkY, monkCount) + bananna = Bananna:new(banannaX, banannaY) end diff --git a/maps/README.txt b/maps/README.txt index 8f49e5d..c770b55 100644 --- a/maps/README.txt +++ b/maps/README.txt @@ -9,4 +9,13 @@ Text-box formatting will be ignored, but the text is used. You can set the spawn point of the monkey party with a point object of type "spawn". Otherwise, it defaults to (100,100). +You can place the bannanas in the map with a point object of type "bannana". +Otherwise... it'll just pop up in (200,200). + Export your map to Lua, put it in a custom "maps" folder, and you're good to go! + + +Useful bits +---------------------------------------- +The farthest a monkey can jump horizontally is 15 16x16 squares +The highest a monkey can jump vertically is 5 16x16 squares diff --git a/maps/tutorial/1.lua b/maps/tutorial/1.lua index aec8612..81709d4 100644 --- a/maps/tutorial/1.lua +++ b/maps/tutorial/1.lua @@ -9,7 +9,7 @@ return { tilewidth = 16, tileheight = 16, nextlayerid = 5, - nextobjectid = 34, + nextobjectid = 46, properties = {}, tilesets = {}, layers = { @@ -35,37 +35,22 @@ return { height = 17, rotation = 0, visible = true, - text = "Hello, monkeys.", + text = "move with wasd or arrow keys", wrap = true, properties = {} }, { - id = 30, + id = 38, name = "", type = "", shape = "text", - x = 132.961, - y = 50.8333, + x = 1102.96, + y = 312.833, width = 82.0781, height = 17, rotation = 0, visible = true, - text = "You're hungry, aren't you?", - wrap = true, - properties = {} - }, - { - id = 31, - name = "", - type = "", - shape = "text", - x = 230.294, - y = 70.8333, - width = 82.0781, - height = 17, - rotation = 0, - visible = true, - text = "Go on ahead, then.", + text = "hit 'space' to create a platform", wrap = true, properties = {} } @@ -328,6 +313,19 @@ return { rotation = 0, visible = true, properties = {} + }, + { + id = 43, + name = "", + type = "", + shape = "rectangle", + x = 1370, + y = 236, + width = 222.667, + height = 77.3333, + rotation = 0, + visible = true, + properties = {} } } }, @@ -356,6 +354,19 @@ return { properties = { ["count"] = 4 } + }, + { + id = 45, + name = "", + type = "bananna", + shape = "point", + x = 1484, + y = 240, + width = 0, + height = 0, + rotation = 0, + visible = true, + properties = {} } } } diff --git a/maps/tutorial/1.tmx b/maps/tutorial/1.tmx index 244016f..66c4fac 100644 --- a/maps/tutorial/1.tmx +++ b/maps/tutorial/1.tmx @@ -1,17 +1,14 @@ - + - Hello, monkeys. + move with wasd or arrow keys - - You're hungry, aren't you? - - - Go on ahead, then. + + hit 'space' to create a platform @@ -34,6 +31,7 @@ + @@ -42,5 +40,8 @@ + + +