added draw functions for setScale, rehandled scale, animations now have multiple frame times (this breaks some minor stuff)
This commit is contained in:
@@ -5,7 +5,6 @@ function Animation:New(anim_data)
|
||||
|
||||
o.path = anim_data.path
|
||||
o.frames = anim_data.frames
|
||||
o.speed = anim_data.speed
|
||||
o.imgs = anim_data.imgs
|
||||
o.subframe = 0
|
||||
o.frame = 1
|
||||
@@ -26,8 +25,8 @@ end
|
||||
|
||||
-- to manually handle what frame
|
||||
function Animation:DrawFrame(frame, x, y, rotate, sx, sy)
|
||||
if frame > self.frames then
|
||||
frame = self.frames
|
||||
if frame > #self.frames then
|
||||
frame = #self.frames
|
||||
end
|
||||
local x = x or 0
|
||||
local y = y or 0
|
||||
@@ -45,18 +44,18 @@ end
|
||||
|
||||
-- to linearly animate
|
||||
function Animation:Animate()
|
||||
if self.speed ~= 0 then
|
||||
if self.frames[self.frame] ~= 0 then
|
||||
-- try to animate
|
||||
self.subframe = self.subframe + current_dt
|
||||
|
||||
if self.subframe > self.speed then
|
||||
self.frame = self.frame + 1
|
||||
self.subframe = self.subframe - self.speed
|
||||
if self.subframe > self.frames[self.frame] then
|
||||
self.subframe = self.subframe - self.frames[self.frame]
|
||||
self.frame = self.frame + 1
|
||||
end
|
||||
|
||||
-- cycle
|
||||
if self.frame >= self.frames+1 then
|
||||
self.frame = self.frame - self.frames
|
||||
if self.frame >= #self.frames+1 then
|
||||
self.frame = self.frame - #self.frames
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ end
|
||||
|
||||
function Canvas:Recreate()
|
||||
self.canvas:release()
|
||||
self = Canvas:New()
|
||||
self = Canvas:New(self.name)
|
||||
end
|
||||
|
||||
function Canvas:Reset()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
function DebugUI()
|
||||
love.graphics.setScale()
|
||||
|
||||
local mouse_x, mouse_y = love.mouse.getPosition()
|
||||
for _, light in pairs(LoadedObjects.Lights) do
|
||||
love.graphics.print(light.pos.x,light.pos.x,light.pos.y)
|
||||
@@ -24,11 +26,13 @@ function DebugUI()
|
||||
end
|
||||
|
||||
function DebugColisions()
|
||||
love.graphics.setScale(game.scale)
|
||||
-- DrawColisionTable()
|
||||
LoadedObjects.DrawCollisions()
|
||||
end
|
||||
|
||||
function DebugEntities()
|
||||
love.graphics.setScale(game.scale)
|
||||
for _, particle in pairs(LoadedParticles) do
|
||||
particle:Debug()
|
||||
end
|
||||
|
||||
6
code/draw.lua
Normal file
6
code/draw.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
function love.graphics.setScale(scale_x, scale_y)
|
||||
local scale_x = scale_x or 1
|
||||
local scale_y = scale_y or scale_x
|
||||
love.graphics.origin()
|
||||
love.graphics.scale(scale_x,scale_y)
|
||||
end
|
||||
@@ -87,7 +87,7 @@ function GameDraw()
|
||||
GameworldDrawEnd()
|
||||
|
||||
-- hud
|
||||
textScale = 0.5
|
||||
textScale = 1
|
||||
|
||||
-- debug
|
||||
if debug then DebugUI() end
|
||||
|
||||
@@ -5,7 +5,7 @@ function GameworldDrawPrepare()
|
||||
Canvas.Darkness.Recreate()
|
||||
end
|
||||
pcr, pcg, pcb, pca = love.graphics.getColor()
|
||||
love.graphics.scale(game.scale,game.scale)
|
||||
love.graphics.setScale(game.scale,game.scale)
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
function MenuDraw(menu)
|
||||
local font = love.graphics.getFont()
|
||||
love.graphics.setFont(LocaleFont)
|
||||
-- Set scale to 1
|
||||
love.graphics.scale(0.5,0.5)
|
||||
|
||||
-- reset scale
|
||||
love.graphics.setScale()
|
||||
|
||||
if menu == "pause" then
|
||||
MenuDrawPauseScreen()
|
||||
@@ -13,8 +14,7 @@ function MenuDraw(menu)
|
||||
for _, element in pairs(UIElement) do
|
||||
element:Draw()
|
||||
end
|
||||
-- Reset scale
|
||||
love.graphics.scale(2,2)
|
||||
|
||||
love.graphics.setFont(font)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ require "code/locale"
|
||||
|
||||
-- support functions
|
||||
require "code/math"
|
||||
require "code/draw"
|
||||
require "code/hex"
|
||||
require "code/in_out"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user