Code: Select all
debug = true
player = { x = 10, y = 560, xSpeed = 450, ySpeed = 700, img = nil, Img2 = nil }
player2 = { x = 1270, y = 560, xSpeed = 450, ySpeed = 700, img = nil, Img2 = nil }
bullet = { x = 640, y = 360, xSpeed = 300, ySpeed = 450, img = nil, Img2 = nil }
function love.draw(dt)
love.graphics.draw(player.Img, player.x, player.y)
love.graphics.draw(player2.Img, player2.x, player2.y)
love.graphics.draw(bullet.Img, bullet.x, bullet.y)
end
function love.load(arg)
player.Img = love.graphics.newImage('assets/player 1.png')
player.Img2 = love.graphics.newImage('assets/player 1 flip.png')
player2.Img = love.graphics.newImage('assets/player 2.png')
player2.Img2 = love.graphics.newImage('assets/player 2 flip.png')
bullet.Img = love.graphics.newImage('assets/bullet.png')
bullet.Img2 = love.graphics.newImage('assets/bullet flip.png')
-- asset ready to be used
end
function love.update(dt)
-- basic menu stuff
if love.keyboard.isDown('escape') then
love.event.push('quit')
end
-- player 1
if love.keyboard.isDown('w') then
if player.y > 0 then
player.y = player.y - (player.ySpeed*dt)
end
elseif love.keyboard.isDown('s') then
if player.y < (love.graphics.getHeight() - player.Img:getHeight()) then
player.y = player.y + (player.ySpeed*dt)
end
end
---------------------------------------------------------------------------------------------------------------------------------------
-- AI
---------------------------------------------------------------------------------------------------------------------------------------
-- Bullet AI
if love.keyboard.isDown(' ') then
if player.y >= 360 then
bullet.y = player.y - (bullet.ySpeed*dt)
elseif player.y < 360 then
bullet.y = player.y + (bullet.ySpeed*dt)
end
end
end
end
---------------------------------------------------------------------------------------------------------------------------------------
end