diff --git a/.main.lua.swp b/.main.lua.swp new file mode 100644 index 0000000..3e4fdd9 Binary files /dev/null and b/.main.lua.swp differ diff --git a/main.lua b/main.lua index 26e4989..3a731cd 100644 --- a/main.lua +++ b/main.lua @@ -8,7 +8,7 @@ PosPersonnage = {} PosPersonnage.X = 50 -PosPersonnage.Y = 400 +PosPersonnage.Y = 515 PosPersonnage.Saute = false PosPersonnage.tir = PosPersonnage.X + 50 PosPersonnage.tirY = PosPersonnage.Y @@ -21,30 +21,41 @@ 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 +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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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) - local x, y = PosPersonnage.X, PosPersonnage.Y - 45 + local x, y = PosPersonnage.X, PosPersonnage.Y --print( Position.Horiz[3] ) -- personnage @@ -65,15 +76,16 @@ end function love.update(dt) + if PosPersonnage.Saute == true then - for j = 0, 30 do - PosPersonnage.Y = PosPersonnage.Y + 1 + for j = 0, 80 do + PosPersonnage.Y = PosPersonnage.Y + 1 end PosPersonnage.Saute = false end if love.keyboard.isDown("up") then - for i = 0, 30 do + for i = 0, 80 do PosPersonnage.Y = PosPersonnage.Y - 1 end PosPersonnage.Saute = true @@ -81,33 +93,45 @@ function love.update(dt) 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 - PosPersonnage.tirY = PosPersonnage.Y Pistol = Pistol + 3 end if Pistol > love.graphics.getWidth() then - PosPersonnage.tirY = PosPersonnage.Y - Pistol = PosPersonnage.tirY tir = false + Pistol = PosPersonnage.tir end end 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) - --tir love.graphics.rectangle("fill", Pistol, PosPersonnage.tirY + 10, 2, 2) end