local ENEMY_COLOR = { 1, 0, 0 }
local BULLET_COLOR = { 0.6, 0.6, 1.0 }
-local PLAYER_VISION_SEGMENTS = 32
+local PLAYER_VISION_SEGMENTS = 16
local PLAYER_VISION_DISTANCE = 20
local ENEMY_SIZE = 20
local input
function love.load()
world, player = World:new()
- for i = 1, 10 do
+ for i = 1, 100 do
local enemy = Enemy:new(math.random(800), math.random(600))
world:add_entity(enemy)
end
function love.draw()
world:draw()
+
+ love.graphics.setColor(0, 0, 0)
+ love.graphics.printf(tostring(love.timer.getFPS()) .. " FPS", 0, 0, 800, "center")
end
local dy = math.sin(a) * CONF.ENEMY_SIZE
local hit_entity = false
- for j = 0, CONF.PLAYER_VISION_DISTANCE - 1 do
+ for j = 1, CONF.PLAYER_VISION_DISTANCE do
local tx = self.x + dx * j
local ty = self.y + dy * j
if e.ENTITY_TYPE == "Enemy" and math.rectcontains(e:get_rect(), tx, ty) then
local ent_rect = e:get_rect()
- for k = 0, 4 do
+ local toggle = false
+ for k = 0, 20 do
dx = dx / 2
dy = dy / 2
tx = tx - dx
ty = ty - dy
- if not math.rectcontains(ent_rect, tx, ty) then
+ if math.rectcontains(ent_rect, tx, ty) == toggle then
dx = dx * -1
dy = dy * -1
+ toggle = not toggle
end
end