Zombies-Kong/main.lua
2022-03-15 19:41:03 +01:00

114 lines
2.7 KiB
Lua

--Version 2.1 dated 2013-06-21
--CeCILL Copyright (C) 2022-2035 by Jean-Christophe Énée
--Initiated by Jean-Chrisotphe Énée
--followed by jean-christoph@atlantic-game.com technical team
--Web Site = <https://atlantic-game.com>
PosPersonnage = {}
PosPersonnage.X = 50
PosPersonnage.Y = 400
PosPersonnage.Saute = false
PosPersonnage.tir = PosPersonnage.X + 50
PosPersonnage.tirY = PosPersonnage.Y
tir = false
Pistol = PosPersonnage.tir
Position = {}
Position.Vert_1 = {}
Position.Vert_2 = {}
Position.Horiz = {}
function Niveau()
local i = 0
PositionVert_1 = 0
PositionVert_2 = 800
PositionHoriz = 565
for PositionHoriz = 565, 240, -65 do
love.graphics.line(PositionVert_1, PositionHoriz, PositionVert_2 , PositionHoriz)
PositionVert_1 = PositionVert_1 + 100
PositionVert_2 = PositionVert_1 + 300
Position.Vert_1[i] = PositionVert_1
Position.Vert_2[i] = PositionVert_2
Position.Horiz[i] = PositionHoriz
i = i + 1
end
love.graphics.rectangle("fill", 700, 220, 20, 20)
end
function Personnage(LaPostition)
local x, y = PosPersonnage.X, PosPersonnage.Y - 45
--print( Position.Horiz[3] )
-- personnage
love.graphics.rectangle("fill", x, y, 10, 10)
love.graphics.line(x + 5, y + 30, x + 5, y )
love.graphics.line(x - 10, y + 15, x + 20, y + 15)
love.graphics.line(x + 5, y + 30, x - 5, y + 40)
love.graphics.line(x + 5, y + 30, x + 15, y + 40)
-- pistolet
love.graphics.rectangle("fill", x + 20, y + 10, 5, 10)
love.graphics.rectangle("fill", x + 20, y + 10, 15, 5)
end
function love.load()
end
function love.update(dt)
if PosPersonnage.Saute == true then
for j = 0, 30 do
PosPersonnage.Y = PosPersonnage.Y + 1
end
PosPersonnage.Saute = false
end
if love.keyboard.isDown("up") then
for i = 0, 30 do
PosPersonnage.Y = PosPersonnage.Y - 1
end
PosPersonnage.Saute = true
end
if love.keyboard.isDown("right") and PosPersonnage.X + 35 < love.graphics.getWidth() then
PosPersonnage.X = PosPersonnage.X + 1
end
if love.keyboard.isDown("left") and PosPersonnage.X - 10 > 0 then
PosPersonnage.X = PosPersonnage.X - 1
end
if love.keyboard.isDown("space") then
tir = true
end
if tir == true then
PosPersonnage.tirY = PosPersonnage.Y
Pistol = Pistol + 3
end
if Pistol > love.graphics.getWidth() then
PosPersonnage.tirY = PosPersonnage.Y
Pistol = PosPersonnage.tirY
tir = false
end
end
function love.draw()
Niveau()
Personnage(LaPostition)
--tir
love.graphics.rectangle("fill", Pistol, PosPersonnage.tirY + 10, 2, 2)
end