[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0, 9.8)
–usuni?cie paska statusu
display.setStatusBar(display.HiddenStatusBar)
–poziom
local kLevelRows = 7
local kLevelCols = 9
schodek = {}
schodek[1] = {}
schodek[2] = {}
schodek[3] = {}
schodek[4] = {}
schodek[5] = {}
schodek[6] = {}
schodek[7] = {}
schodek[8] = {}
schodek[9] = {}
tab = {}
tab[1] = {0,1,0,0,1,0,0}
tab[2] = {0,0,0,0,0,0,0}
tab[3] = {0,0,0,0,0,0,0}
tab[4] = {0,0,0,1,0,0,0}
tab[5] = {1,0,0,0,0,0,0}
tab[6] = {0,0,0,0,1,0,0}
tab[7] = {0,0,0,0,0,0,0}
tab[8] = {0,0,0,0,0,0,0}
tab[9] = {0,0,0,0,0,0,0}
–poziomy trudno?ci
poziom1 = 1
poziom2 = 5
poziom3 = 10
– obramowanie ekranu
–local leftWall = display.newRect(0, 0, 1, display.contentHeight)
–local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight)
local ceiling = display.newRect(0, 0, display.contentWidth, 1)
–dodanie boy dla obramowania
–physics.addBody(leftWall, “static”, {bounce = 0.1})
–physics.addBody(rightWall, “static”, {bounce = 0.1})
physics.addBody(ceiling, “static”, {bounce = 0.1})
–tlo
local tlo = display.newImage(“tlo.png”)
local tlo2 = display.newImage(“tlo.png”)
tlo:setReferencePoint( display.CenterLeftReferencePoint )
tlo2:setReferencePoint( display.CenterLeftReferencePoint )
–pilka
local pilka = display.newImage(“pilka.png”)
pilka.x = 100
pilka.y = 150
physics.addBody(pilka, {bounce = 0.5, radius = 17})
–rysowanie poziomu
local function poziom()
for i = 1, kLevelCols do
for j = 1, kLevelRows do
if tab[i][j] == 1 then
schodek[i][j] = display.newImage(“schodek.png”)
physics.addBody(schodek[i][j], “static”, {bounce = 0.3, friction = 10})
schodek[i][j].y = (_W/12) * i
schodek[i][j].x = 75 * j
end
end
end
end
Runtime:addEventListener( “enterFrame”, poziom )
function movePilka(event)
local pilka = event.target
pilka:applyLinearImpulse(0, -0.2, pilka.x, pilka.y)
end
pilka:addEventListener(“touch”, movePilka)
local tPrevious = system.getTimer()
–ruch elementów
tlo.x = 0
tlo2.x = 959
local tPrevious = system.getTimer()
local function przesuwaj(event)
–animacja tla
for i = 1, kLevelCols, 1 do
for j = 1, kLevelRows, 1 do
if tab[i][j] == 1 then
schodek[i][j].x = schodek[i][j].x - 10
end
end
end
local tDelta = event.time - tPrevious
tPrevious = event.time
local xOffset = ( 0.2 * tDelta )
tlo.x = tlo.x - xOffset
tlo2.x = tlo2.x - xOffset
if (tlo.x + tlo.contentWidth) < 0 then
tlo:translate( 959 * 2, 0)
end
if (tlo2.x + tlo2.contentWidth) < 0 then
tlo2:translate( 959 * 2, 0)
end
end
Runtime:addEventListener(“enterFrame”,przesuwaj)[/lua]
function poziom responsible for drawing platforms function przesuwaj is my animation [import]uid: 117910 topic_id: 21266 reply_id: 84618[/import]