Zombies-Kong/main.lua

138 lines
4.8 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 = 515
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 = {}
local level = {
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
}
function Personnage(LaPostition)
local x, y = PosPersonnage.X, PosPersonnage.Y
--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, 80 do
PosPersonnage.Y = PosPersonnage.Y + 1
end
PosPersonnage.Saute = false
end
if love.keyboard.isDown("up") then
for i = 0, 80 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
PosPersonnage.tir = PosPersonnage.tir + 1
Pistol = Pistol + 1
end
if love.keyboard.isDown("left") and PosPersonnage.X - 10 > 0 then
PosPersonnage.X = PosPersonnage.X - 1
PosPersonnage.tir = PosPersonnage.tir - 1
Pistol = Pistol - 1
end
if love.keyboard.isDown("space") then
tir = true
PosPersonnage.tirY = PosPersonnage.Y
end
if tir == true then
Pistol = Pistol + 3
end
if Pistol > love.graphics.getWidth() then
tir = false
Pistol = PosPersonnage.tir
end
end
function love.draw()
local size = 20
for line = 1, #level do
for row = 1, #level[line] do
local cell = level[line][row]
if cell ~= 0 then
love.graphics.rectangle("fill",row*size,line*size,size,size)
else
--love.graphics.rectangle("line",row*size,line*size,size,size)
end
end
end
Personnage(LaPostition)
--tir
love.graphics.rectangle("fill", Pistol, PosPersonnage.tirY + 10, 2, 2)
end