From dacff225a22ddb4752da4e134303ffae0d5efce7 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 29 Apr 2019 15:27:40 +0200 Subject: [PATCH] examples: add cameras --- examples/gameplay/moveplayer/actors/player.lua | 10 ++++++++-- examples/gameplay/moveplayer/init.lua | 6 +++--- examples/gameplay/plateform/init.lua | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/gameplay/moveplayer/actors/player.lua b/examples/gameplay/moveplayer/actors/player.lua index cffb741..32cac36 100644 --- a/examples/gameplay/moveplayer/actors/player.lua +++ b/examples/gameplay/moveplayer/actors/player.lua @@ -2,13 +2,14 @@ local cwd = (...):gsub('%.player$', '') .. "." local Parent = require(cwd .. "parent") local Player = Parent:extend() -function Player:new(world, x, y) +function Player:new(world, x, y, id) Player.super.new(self, world, "player", x, y, 16, 16, true) + self.playerid = id end function Player:update(dt) self.xfrc, self.yfrc = 480*3, 480*3 - + if self.keys["up"].isDown then self.ysp = -120 end @@ -25,4 +26,9 @@ function Player:update(dt) Player.super.update(self, dt) end +function Player:draw() + Player.super.draw(self) + love.graphics.print(self.playerid, self.x, self.y) +end + return Player diff --git a/examples/gameplay/moveplayer/init.lua b/examples/gameplay/moveplayer/init.lua index bd40d32..5444d5b 100644 --- a/examples/gameplay/moveplayer/init.lua +++ b/examples/gameplay/moveplayer/init.lua @@ -29,10 +29,10 @@ local World = require "gamecore.modules.world.world2D" function MovePlayer:new() MovePlayer.super.new(self) - self.world = World(self, "examples.gameplay.moveplayer.actors") + self.world = World(self, "examples.gameplay.moveplayer.actors", "examples/gameplay/plateform/assets/platformer.lua") - self.world:addPlayer(self.world.obj.Player(self.world, 16, 16)) - self.world:addPlayer(self.world.obj.Player(self.world, 424 - 16, 16), 2) + self.world:addPlayer(self.world.obj.Player(self.world, 16, 16, 1), 1, true) + self.world:addPlayer(self.world.obj.Player(self.world, 424 - 16, 16, 2), 2, true) end function MovePlayer:update(dt) diff --git a/examples/gameplay/plateform/init.lua b/examples/gameplay/plateform/init.lua index 2d5bfa0..6e6a5e5 100644 --- a/examples/gameplay/plateform/init.lua +++ b/examples/gameplay/plateform/init.lua @@ -32,6 +32,9 @@ function Plateformer:new() local folder = "examples.gameplay.plateform" self.world = World(self, folder .. ".actors", "examples/gameplay/plateform/assets/platformer.lua") + + self.world.cameras:addView(24, 150*16) + self.world.cameras:addView(24, 240) end function Plateformer:update(dt)