Code: Select all
local g1 = { k = { anim1 = 'idle', attackTime = 0, animdone = true }, i = {}, a1 = {}, m = { i = 1 }, }
g1.l = require 'Modules/LocationF1'
function g1.load()
--Idle
g1.i.F1i_1 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-1.png')
g1.i.F1i_2 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-2.png')
g1.i.F1i_3 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-3.png')
g1.i.F1i_4 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-4.png')
g1.i.F1i_5 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-5.png')
g1.i.F1i_6 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-6.png')
g1.i.F1i_7 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-7.png')
g1.i.F1i_8 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1i-8.png')
--Attack #1
g1.a1.F1A_1 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-1.png')
g1.a1.F1A_2 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-2.png')
g1.a1.F1A_3 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-3.png')
g1.a1.F1A_4 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-4.png')
g1.a1.F1A_5 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-5.png')
g1.a1.F1A_6 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-6.png')
g1.a1.F1A_7 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-7.png')
g1.a1.F1A_8 = love.graphics.newImage('Assets/Sprites/FightersBlowup/F1/F1A-8.png')
g1.F1 = g1.i.F1i_1
end
function g1.attack(key)
g1.m.i = 1
while g1.m.i <= 8.8 do
g1.m.i = g1.m.i + (dt/10)
g1.m.i_floored = math.floor(g1.m.i)
if g1.m.i_floored == 1 then
g1.frame = g1.i.F1A_1
elseif g1.m.i_floored == 2 then
g1.frame = g1.i.F1A_2
elseif g1.m.i_floored == 3 then
g1.frame = g1.i.F1A_3
elseif g1.m.i_floored == 4 then
g1.frame = g1.i.F1A_4
elseif g1.m.i_floored == 5 then
g1.frame = g1.i.F1A_5
elseif g1.m.i_floored == 6 then
g1.frame = g1.i.F1A_6
elseif g1.m.i_floored == 7 then
g1.frame = g1.i.F1A_7
elseif g1.m.i_floored == 8 then
g1.frame = g1.i.F1A_8
end
g1.F1 = g1.frame
if g1.m.i == 8.8 then break end
end
end
function g1.idle(key)
g1.m.i = 1
while g1.m.i <= 8.8 do
g1.m.i = g1.m.i + 0.2
g1.m.i_floored = math.floor(g1.m.i)
if g1.m.i_floored == 1 then
g1.frame = g1.i.F1i_1
elseif g1.m.i_floored == 2 then
g1.frame = g1.i.F1i_2
elseif g1.m.i_floored == 3 then
g1.frame = g1.i.F1i_3
elseif g1.m.i_floored == 4 then
g1.frame = g1.i.F1i_4
elseif g1.m.i_floored == 5 then
g1.frame = g1.i.F1i_5
elseif g1.m.i_floored == 6 then
g1.frame = g1.i.F1i_6
elseif g1.m.i_floored == 7 then
g1.frame = g1.i.F1i_7
elseif g1.m.i_floored == 8 then
g1.frame = g1.i.F1i_8
end
g1.F1 = g1.frame
if g1.m.i == 8.8 then break end
end
end
function g1.update(dt)
g1.l.update(dt) --line 92----------------------------------------------------------
end
function g1.draw()
--love.graphics.print(g1.m.i, 400, 400)
love.graphics.draw( g1.F1, g1.l.x, g1.l.y )
end
return g1
And here's the code for LocationF1:
Code: Select all
--this file is for movement and positioning of Fighter 1
local l = { x, y, xv, yv, px, py }
function l.load()
l.x = 300
l.y = 500
l.xv = 0
l.yv = 0
end
function l.update(dt)
l.px = l.x
l.py = l.y
if love.keyboard.isDown('d') then
if l.xv < 5 then
l.xv = l.xv + 0.5
if l.xv > 5 then
l.xv = 5
end
end
end
if love.keyboard.isDown('a') then
if l.xv > -5 then
l.xv = l.xv + -0.5
if l.xv < -5 then
l.xv = -5
end
end
end
if l.px <= 800 and l.px >= 0 then
l.x = l.x +l.xv * dt
end
--if l.py <= 800 and l.py >= 0 then
-- l.y = l.y +l.yv * dt
--end
end
And here's the code for the drawing file:
Code: Select all
--file for adding effects and the camera...
local d = { g1 = require 'Modules/GraphicsF1', c = require 'Libs/Stalker-X'}
function d.load()
d.g1.load
d.camera = d.c()
end
function d.update(dt)
d.g1.update(dt)
d.camera:update(dt)
end
function d.draw()
d.camera:attach()
d.g1.draw()
d.camera:detach()
d.camera:draw()
end
return d