Drawing an 'undrawing' images
Posted: Thu Jan 07, 2016 1:41 pm
Hey Guys! I have recently been having troubles in my script (as in it has been taking too much space). So my problem is when i want to play an animation i use a method of teleporting the animation or sprite to the previous x and y. for example...
So my question is, is there a quicker and more efficient way of doing this, like "undrawing" the image or animation and then recalling it? instead of just teleporting it off screen? this would make my scripts much more efficient and easier to navigate
--note i am fairy new to love
Code: Select all
require("AnAL")
love.graphics.setBackgroundColor(255,255,255)
health = 5
y5 = -600
y4 = -600
y3 = -600
y2 = -600
y1 = -600
y0 = -600
function love.load()
health5 = love.graphics.newImage("assets/heartline5.png")
health4 = love.graphics.newImage("assets/heartline4.png")
health3 = love.graphics.newImage("assets/heartline3.png")
health2 = love.graphics.newImage("assets/heartline2.png")
health1 = love.graphics.newImage("assets/heartline1.png")
health0 = love.graphics.newImage("assets/heartline0.png")
end
function love.update(dt)
--health
if health == 5 then
y5 = 20
y4 = -600
y3 = -600
y2 = -600
y1 = -600
y0 = -600
elseif health == 4 then
y5 = -600
y4 = 20
y3 = -600
y2 = -600
y1 = -600
y0 = -600
elseif health == 3 then
y5 = -600
y4 = -600
y3 = 20
y2 = -600
y1 = -600
y0 = -600
elseif health == 2 then
y5 = -600
y4 = -600
y3 = -600
y2 = 20
y1 = -600
y0 = -600
elseif health == 1 then
y5 = -600
y4 = -600
y3 = -600
y2 = -600
y1 = 20
y0 = -600
elseif health == 0 then
y5 = -600
y4 = -600
y3 = -600
y2 = -600
y1 = -600
y0 = 20
end
--health
end
function love.draw()
love.graphics.draw(health5, 800, y5)
love.graphics.draw(health4, 800, y4)
love.graphics.draw(health3, 800, y3)
love.graphics.draw(health2, 800, y2)
love.graphics.draw(health1, 800, y1)
love.graphics.draw(health0, 800, y0)
end
--note i am fairy new to love