You Confused Me....
Code: Select all
function love.load()
movingobject = "O" --love.graphics.newImageData("Explosion fire texture.png")
x = 50
y = 50
speed = 100
end
score = 0
highscore = score
obj = "()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()"
posx = -100
posy = 600
negativedistx = posx-(string.len(obj)/5)
positivedistx = posx+(string.len(obj)*5)
negativedisty = posy+10
positivedisty = posy-10
inactive = 5
d = false
t = {}
pause = false
help = false
function love.update(dt)
if love.keyboard.isDown("p") then
if pause == false then
pause = true
end
elseif
pause == true then
pause = false
end
if love.keyboard.isDown("c") and love.keyboard.isDown("lctrl" or "rctrl") then
score = score + 1000
highscore = score
end
--Highscore saving? Dont Know How...
--[[
if love.keyboard.isDown("s") and love.keyboard.isDown("lctrl") then
love.filesystem.setIdentity("4762games")
success = love.filesystem.write( "4762games/platformer", highscore , 100 )
contents, size = love.filesystem.read( "4762games/platformer" , 100 )
end
]]--
if love.keyboard.isDown("h") then
if help == false then
help = true
end
elseif
help == true then
help = false
end
if love.keyboard.isDown("right") or love.keyboard.isDown("d") then
if pause == true then return end
inactive = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
speed = 100
for i,v in pairs(t) do
collideplatforms = tonumber(string.len(string.sub(v,string.find(v,"|")+1,string.len(v))))
xpoint = tonumber(string.sub(v,4,string.find(v,"/")-1))
ypoint = tonumber(string.sub(v,string.find(v,"/")+1,string.find(v,"|")-1))
positivexpoint = xpoint+(collideplatforms*5)
negativexpoint = xpoint-(collideplatforms*5)
positiveypoint = ypoint-10
negativeypoint = ypoint+10
if y <= 800 and y >= 0 and x >= 800 then
x = 10
end
if x >= negativedistx and x <= positivedistx and y >= positivedisty and y <= negativedisty or x >= negativexpoint and x <= positivexpoint and y >= positiveypoint and y <= negativeypoint then
speed = 0
if d == false then
d = true
end
end
end
x = x + (speed * dt)
movingobject = ">"
elseif love.keyboard.isDown("left") or love.keyboard.isDown("a")then
if pause == true then return end
speed = 100
inactive = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
for i,v in pairs(t) do
collideplatforms = tonumber(string.len(string.sub(v,string.find(v,"|")+1,string.len(v))))
xpoint = tonumber(string.sub(v,4,string.find(v,"/")-1))
ypoint = tonumber(string.sub(v,string.find(v,"/")+1,string.find(v,"|")-1))
positivexpoint = xpoint+(collideplatforms*5)
negativexpoint = xpoint-(collideplatforms*5)
positiveypoint = ypoint-10
negativeypoint = ypoint+10
if y <= 800 and y >= 0 and x <= 0 then
x = 790
end
if x <= positivedistx and x >= negativedistx and y >= positivedisty and y <= negativedisty or x >= negativexpoint and x <= positivexpoint and y >= positiveypoint and y <= negativeypoint then
speed = 0
if d == false then
d = true
end
end
end
x = x - (speed * dt)
movingobject = "<"
end
if love.keyboard.isDown("down") or love.keyboard.isDown("s")then
if pause == true then return end
inactive = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
speed = 100
for i,v in pairs(t) do
collideplatforms = tonumber(string.len(string.sub(v,string.find(v,"|")+1,string.len(v))))
xpoint = tonumber(string.sub(v,4,string.find(v,"/")-1))
ypoint = tonumber(string.sub(v,string.find(v,"/")+1,string.find(v,"|")-1))
positivexpoint = xpoint+(collideplatforms*5)
negativexpoint = xpoint-(collideplatforms*5)
positiveypoint = ypoint-10
negativeypoint = ypoint+10
if x >= negativedistx and x <= positivedistx and y >= positivedisty and y <= negativedisty or x >= negativexpoint and x <= positivexpoint and y >= positiveypoint and y <= negativeypoint then
speed = 0
if d == false then
d = true
end
end
end
y = y + (speed * dt)
movingobject = "v"
elseif love.keyboard.isDown("up") or love.keyboard.isDown("w") then
if pause == true then return end
inactive = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
speed = 100
for i,v in pairs(t) do
collideplatforms = tonumber(string.len(string.sub(v,string.find(v,"|")+1,string.len(v))))
xpoint = tonumber(string.sub(v,4,string.find(v,"/")-1))
ypoint = tonumber(string.sub(v,string.find(v,"/")+1,string.find(v,"|")-1))
positivexpoint = xpoint+(collideplatforms*5)
negativexpoint = xpoint-(collideplatforms*5)
positiveypoint = ypoint-10
negativeypoint = ypoint+10
if y <= 10 and x >= 0 and x <= 800 then
y = 10
end
if x >= negativedistx and x <= positivedistx and y <= negativedisty and y >= positivedisty or x >= negativexpoint and x <= positivexpoint and y >= negativeypoint and y <= positiveypoint then
speed = 0
if d == false then
d = true
end
end
end
y = y - (speed * dt)
movingobject = "^"
end
if love.keyboard.isDown("r") then
x = 50
y = 50
d = false
score = 0
movingobject = "O"
inactive = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
end
end
function love.draw()
love.graphics.print(movingobject, x, y)
love.graphics.print(obj, posx, posy)
love.graphics.print("Score: "..math.ceil(score), 600, 550)
love.graphics.print("Highscore: "..math.ceil(highscore), 600, 500)
love.graphics.print("Jordan4762's Platformer Game ... =D",500,580)
if pause == true then return end
if d == true then
love.graphics.print([[You Died, press "R" to respawn.]], 200, 300)
end
inactive = string.sub(inactive,1,string.len(inactive)-1)
love.graphics.print("Inactive-time: "..inactive, 100, 50)
if inactive == "" then
inactive = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
d = true
end
love.timer.sleep(1)
if d ~= true then
score = score + 0.5
if score >= highscore then
highscore = highscore + 0.5
end
end
love.timer.sleep(1)
if d ~= true then
a = "><"
rand = math.random(0,800)
b = string.rep(a,math.random(1,8))
table.insert(t,"num"..tostring(rand).."/".."800".."|"..b) -- Ex; "num352/800|()()()()()
love.graphics.print(b, posx, posy)
for i,v in pairs(t) do
posxnumcut = string.sub(v,4,string.find(v,"/")-1)
posynumcut = string.sub(v,string.find(v,"/")+1,string.find(v,"|")-1)
platforms = string.sub(v,string.find(v,"|")+1,string.len(v))
love.graphics.print(platforms, tonumber(posxnumcut), tonumber(math.ceil(posynumcut)))
newy = tonumber(posynumcut)
newy = newy - 2
table.remove(t,i)
table.insert(t,"num"..tostring(posxnumcut).."/"..tostring(newy).."|"..platforms)
if newy <= 0 then
table.remove(t,i)
end
end
end
helpmsgtab = {}
if help == true then
helpmessage = "The goal of this game is not hitting the moving platforms, "
helpmessage2 = "and stay as long alive as you can. But keep moving, "
helpmessage3 = "else your 'inactive-time' gets too low and you die. "
helpmessage4 = "The controls are the arrow keys to move, or AWSD. "
helpmessage5 = "Press 'P' to pause the game. Anyway, enjoy this game! :D -- Jordan4762"
table.insert(helpmsgtab,helpmessage)
table.insert(helpmsgtab,helpmessage2)
table.insert(helpmsgtab,helpmessage3)
table.insert(helpmsgtab,helpmessage4)
table.insert(helpmsgtab,helpmessage5)
love.graphics.print(tostring(helpmsgtab[1]), 200,400)
love.graphics.print(tostring(helpmsgtab[2]), 200,410)
love.graphics.print(tostring(helpmsgtab[3]), 200,420)
love.graphics.print(tostring(helpmsgtab[4]), 200,430)
love.graphics.print(tostring(helpmsgtab[5]), 200,440)
--table.remove(helpmsgtab,1)
end
end