modifié : main.lua

This commit is contained in:
Heitai-C11 2022-03-26 18:49:26 +01:00
parent 8cd8aa1e77
commit 61f0ba6a09
2 changed files with 54 additions and 30 deletions

BIN
.main.lua.swp Normal file

Binary file not shown.

View File

@ -8,7 +8,7 @@
PosPersonnage = {} PosPersonnage = {}
PosPersonnage.X = 50 PosPersonnage.X = 50
PosPersonnage.Y = 400 PosPersonnage.Y = 515
PosPersonnage.Saute = false PosPersonnage.Saute = false
PosPersonnage.tir = PosPersonnage.X + 50 PosPersonnage.tir = PosPersonnage.X + 50
PosPersonnage.tirY = PosPersonnage.Y PosPersonnage.tirY = PosPersonnage.Y
@ -21,30 +21,41 @@ Position.Vert_1 = {}
Position.Vert_2 = {} Position.Vert_2 = {}
Position.Horiz = {} Position.Horiz = {}
local level = {
function Niveau() {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},
local i = 0 {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},
PositionVert_1 = 0 {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},
PositionVert_2 = 800 {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},
PositionHoriz = 565 {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},
for PositionHoriz = 565, 240, -65 do {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},
love.graphics.line(PositionVert_1, PositionHoriz, PositionVert_2 , PositionHoriz) {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},
PositionVert_1 = PositionVert_1 + 100 {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},
PositionVert_2 = PositionVert_1 + 300 {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,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},
Position.Vert_1[i] = PositionVert_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},
Position.Vert_2[i] = PositionVert_2 {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},
Position.Horiz[i] = PositionHoriz {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},
i = i + 1 {1,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,0,0,0,0,0,0,0,0,0,1},
end {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},
love.graphics.rectangle("fill", 700, 220, 20, 20) {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},
end {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,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,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) function Personnage(LaPostition)
local x, y = PosPersonnage.X, PosPersonnage.Y - 45 local x, y = PosPersonnage.X, PosPersonnage.Y
--print( Position.Horiz[3] ) --print( Position.Horiz[3] )
-- personnage -- personnage
@ -65,15 +76,16 @@ end
function love.update(dt) function love.update(dt)
if PosPersonnage.Saute == true then if PosPersonnage.Saute == true then
for j = 0, 30 do for j = 0, 80 do
PosPersonnage.Y = PosPersonnage.Y + 1 PosPersonnage.Y = PosPersonnage.Y + 1
end end
PosPersonnage.Saute = false PosPersonnage.Saute = false
end end
if love.keyboard.isDown("up") then if love.keyboard.isDown("up") then
for i = 0, 30 do for i = 0, 80 do
PosPersonnage.Y = PosPersonnage.Y - 1 PosPersonnage.Y = PosPersonnage.Y - 1
end end
PosPersonnage.Saute = true PosPersonnage.Saute = true
@ -81,33 +93,45 @@ function love.update(dt)
if love.keyboard.isDown("right") and PosPersonnage.X + 35 < love.graphics.getWidth() then if love.keyboard.isDown("right") and PosPersonnage.X + 35 < love.graphics.getWidth() then
PosPersonnage.X = PosPersonnage.X + 1 PosPersonnage.X = PosPersonnage.X + 1
PosPersonnage.tir = PosPersonnage.tir + 1
Pistol = Pistol + 1
end end
if love.keyboard.isDown("left") and PosPersonnage.X - 10 > 0 then if love.keyboard.isDown("left") and PosPersonnage.X - 10 > 0 then
PosPersonnage.X = PosPersonnage.X - 1 PosPersonnage.X = PosPersonnage.X - 1
PosPersonnage.tir = PosPersonnage.tir - 1
Pistol = Pistol - 1
end end
if love.keyboard.isDown("space") then if love.keyboard.isDown("space") then
tir = true tir = true
PosPersonnage.tirY = PosPersonnage.Y
end end
if tir == true then if tir == true then
PosPersonnage.tirY = PosPersonnage.Y
Pistol = Pistol + 3 Pistol = Pistol + 3
end end
if Pistol > love.graphics.getWidth() then if Pistol > love.graphics.getWidth() then
PosPersonnage.tirY = PosPersonnage.Y
Pistol = PosPersonnage.tirY
tir = false tir = false
Pistol = PosPersonnage.tir
end end
end end
function love.draw() function love.draw()
Niveau() 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) Personnage(LaPostition)
--tir --tir
love.graphics.rectangle("fill", Pistol, PosPersonnage.tirY + 10, 2, 2) love.graphics.rectangle("fill", Pistol, PosPersonnage.tirY + 10, 2, 2)
end end