examples: add cameras
This commit is contained in:
parent
00fe87f61d
commit
dacff225a2
3 changed files with 14 additions and 5 deletions
|
@ -2,8 +2,9 @@ local cwd = (...):gsub('%.player$', '') .. "."
|
||||||
local Parent = require(cwd .. "parent")
|
local Parent = require(cwd .. "parent")
|
||||||
local Player = Parent:extend()
|
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)
|
Player.super.new(self, world, "player", x, y, 16, 16, true)
|
||||||
|
self.playerid = id
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:update(dt)
|
function Player:update(dt)
|
||||||
|
@ -25,4 +26,9 @@ function Player:update(dt)
|
||||||
Player.super.update(self, dt)
|
Player.super.update(self, dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:draw()
|
||||||
|
Player.super.draw(self)
|
||||||
|
love.graphics.print(self.playerid, self.x, self.y)
|
||||||
|
end
|
||||||
|
|
||||||
return Player
|
return Player
|
||||||
|
|
|
@ -29,10 +29,10 @@ local World = require "gamecore.modules.world.world2D"
|
||||||
function MovePlayer:new()
|
function MovePlayer:new()
|
||||||
MovePlayer.super.new(self)
|
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, 16, 16, 1), 1, true)
|
||||||
self.world:addPlayer(self.world.obj.Player(self.world, 424 - 16, 16), 2)
|
self.world:addPlayer(self.world.obj.Player(self.world, 424 - 16, 16, 2), 2, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MovePlayer:update(dt)
|
function MovePlayer:update(dt)
|
||||||
|
|
|
@ -32,6 +32,9 @@ function Plateformer:new()
|
||||||
local folder = "examples.gameplay.plateform"
|
local folder = "examples.gameplay.plateform"
|
||||||
|
|
||||||
self.world = World(self, folder .. ".actors", "examples/gameplay/plateform/assets/platformer.lua")
|
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
|
end
|
||||||
|
|
||||||
function Plateformer:update(dt)
|
function Plateformer:update(dt)
|
||||||
|
|
Loading…
Reference in a new issue