mirror of
https://github.com/bvanroll/3dsStuff.git
synced 2025-08-29 03:42:40 +00:00
added difficulty settings by making the game faster
This commit is contained in:
41
main.lua
41
main.lua
@@ -1,5 +1,11 @@
|
|||||||
beep = love.audio.newSource("beep.wav", "static")
|
beep = love.audio.newSource("beep.wav", "static")
|
||||||
|
|
||||||
|
--dif determines fps, this can make the game faster and therefore harder
|
||||||
|
diff = 10
|
||||||
|
frames = 0
|
||||||
|
fps = 1/diff
|
||||||
|
|
||||||
|
|
||||||
bgCol = {
|
bgCol = {
|
||||||
r = 0,
|
r = 0,
|
||||||
g = 0,
|
g = 0,
|
||||||
@@ -50,6 +56,18 @@ player = {
|
|||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
function player:reset()
|
||||||
|
self.xvel = 0
|
||||||
|
self.yvel = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function player:hardreset()
|
||||||
|
self.xvel = 0
|
||||||
|
self.yvel = 0
|
||||||
|
self.x = 1
|
||||||
|
self.y = 1
|
||||||
|
self.blocks = {}
|
||||||
|
end
|
||||||
|
|
||||||
function player:move(xvel, yvel)
|
function player:move(xvel, yvel)
|
||||||
self.xvel = xvel
|
self.xvel = xvel
|
||||||
@@ -84,15 +102,18 @@ function love.load()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
player:update()
|
if frames >= fps then
|
||||||
|
player:update()
|
||||||
|
frames = 0
|
||||||
|
end
|
||||||
|
frames = frames+dt
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
love.graphics.setBackgroundColor(bgCol.r, bgCol.g, bgCol.b)
|
love.graphics.setBackgroundColor(bgCol.r, bgCol.g, bgCol.b)
|
||||||
--topscreen only works on 3ds, so look out
|
--topscreen only works on 3ds, so look out
|
||||||
love.graphics.setScreen('top')
|
--love.graphics.setScreen('top')
|
||||||
--love.graphics.rectangle("fill", 1, 1, 30, 30)
|
--love.graphics.rectangle("fill", 1, 1, 30, 30)
|
||||||
player:draw()
|
player:draw()
|
||||||
--bottom screen
|
--bottom screen
|
||||||
@@ -161,9 +182,19 @@ function love.keypressed(key)
|
|||||||
end
|
end
|
||||||
if (key == "a") then
|
if (key == "a") then
|
||||||
player:move(1, 0)
|
player:move(1, 0)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
if (key == "select") then
|
||||||
|
player:reset()
|
||||||
|
end
|
||||||
|
if (key == "lbutton") then
|
||||||
|
diff = diff - 10
|
||||||
|
if diff < 9 then
|
||||||
|
diff = 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (key == "rbutton") then
|
||||||
|
diff = diff + 10
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keyreleased(key)
|
function love.keyreleased(key)
|
||||||
|
Reference in New Issue
Block a user