Add bananna and zoom in/out feature

This commit is contained in:
Jaidyn Ann 2021-01-07 02:15:15 -06:00
parent c63e33f1bc
commit 76f548d6c4
6 changed files with 83 additions and 30 deletions

BIN
art/sprites/bananna.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

BIN
art/sprites/bananna.wb Normal file

Binary file not shown.

View File

@ -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

View File

@ -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

View File

@ -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 = {}
}
}
}

View File

@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="34">
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="100" height="100" tilewidth="16" tileheight="16" infinite="0" nextlayerid="5" nextobjectid="46">
<editorsettings>
<export target="1.lua" format="lua"/>
</editorsettings>
<objectgroup id="2" name="Object Layer 1">
<object id="2" name="hi" x="37.6276" y="34.1667" width="94.08" height="17">
<text wrap="1">Hello, monkeys.</text>
<text wrap="1">move with wasd or arrow keys</text>
</object>
<object id="30" x="132.961" y="50.8333" width="82.0781" height="17">
<text wrap="1">You're hungry, aren't you?</text>
</object>
<object id="31" x="230.294" y="70.8333" width="82.0781" height="17">
<text wrap="1">Go on ahead, then.</text>
<object id="38" x="1102.96" y="312.833" width="82.0781" height="17">
<text wrap="1">hit 'space' to create a platform</text>
</object>
</objectgroup>
<objectgroup id="3" name="Object Layer 2">
@ -34,6 +31,7 @@
<object id="24" x="959.333" y="353.333" width="30.6667" height="157.333"/>
<object id="26" x="989.333" y="367.333" width="34.6667" height="143.333"/>
<object id="29" x="1024" y="384.667" width="224" height="126.667"/>
<object id="43" x="1370" y="236" width="222.667" height="77.3333"/>
</objectgroup>
<objectgroup id="4" name="Object Layer 3">
<object id="32" type="spawn" x="93" y="80">
@ -42,5 +40,8 @@
</properties>
<point/>
</object>
<object id="45" type="bananna" x="1484" y="240">
<point/>
</object>
</objectgroup>
</map>