Compare commits
No commits in common. "c225cc6edff5ee25308f36d1732e7ef65dffb871" and "89f9bd1913a3476b062a77b0dd8048cfc4108d7b" have entirely different histories.
c225cc6edf
...
89f9bd1913
4 changed files with 1 additions and 18 deletions
2
main.lua
2
main.lua
|
|
@ -60,8 +60,6 @@ function love.load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
camera = Camera()
|
camera = Camera()
|
||||||
|
|
||||||
gotoRoom('Stage')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@
|
||||||
---@class Area:Object
|
---@class Area:Object
|
||||||
---@field room Room
|
---@field room Room
|
||||||
---@field game_objects GameObject[]
|
---@field game_objects GameObject[]
|
||||||
---@field world table|nil
|
|
||||||
local Area = Object:extend()
|
local Area = Object:extend()
|
||||||
|
|
||||||
---Instantiates area
|
---Instantiates area
|
||||||
function Area:new(room)
|
function Area:new(room)
|
||||||
self.room = room
|
self.room = room
|
||||||
self.game_objects = {}
|
self.game_objects = {}
|
||||||
self.world = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Updates area
|
---Updates area
|
||||||
|
|
@ -38,10 +36,4 @@ function Area:addGameObject(game_object_type, x, y, opts)
|
||||||
return game_object
|
return game_object
|
||||||
end
|
end
|
||||||
|
|
||||||
---Initializes HC physics as a world
|
|
||||||
---@param cell_size number|nil
|
|
||||||
function Area:addPhysicsWorld(cell_size)
|
|
||||||
self.world = HC(cell_size or 100)
|
|
||||||
end
|
|
||||||
|
|
||||||
return Area
|
return Area
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ local Player = GameObject:extend()
|
||||||
|
|
||||||
function Player:new(area, x, y, opts)
|
function Player:new(area, x, y, opts)
|
||||||
Player.super.new(self, area, x, y, opts)
|
Player.super.new(self, area, x, y, opts)
|
||||||
|
|
||||||
self.w, self.h = 12, 12
|
|
||||||
self.collider = self.area.world:circle(self.x, self.y, math.floor(self.w*0.8))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:update(dt)
|
function Player:update(dt)
|
||||||
|
|
@ -18,10 +15,6 @@ end
|
||||||
|
|
||||||
function Player:draw()
|
function Player:draw()
|
||||||
Player.super.draw(self)
|
Player.super.draw(self)
|
||||||
love.graphics.setColor(1, 0.4, 0.4)
|
|
||||||
self.collider:draw()
|
|
||||||
love.graphics.setColor(1, 1, 1)
|
|
||||||
love.graphics.circle('line', self.x, self.y, self.w)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Player
|
return Player
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ local Stage = Room:extend()
|
||||||
|
|
||||||
function Stage:new()
|
function Stage:new()
|
||||||
Stage.super.new(self)
|
Stage.super.new(self)
|
||||||
self.area:addPhysicsWorld()
|
|
||||||
self.area:addGameObject('Player', gw/2, gh/2)
|
self.area:addGameObject('Player', gw/2, gh/2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue