function love.load()
require ("Rock")
require ("anal")
RockMoveS = 180
RockMoveX = 355
RockMoveY = 255
rockbarf = love.graphics.newImage("Rock.png")
Rockmonster = love.graphics.newImage("Rockmonster.png")
backround = love.graphics.newImage("backround.png")
RockWalkR = love.graphics.newImage("RockMonsterR.png")
RockWalkR:setFilter("nearest", "nearest")
MonsterR = newAnimation(RockWalkR, 45, 45, 0.1, 2)
BoulderSpawn = true
music = love.audio.newSource("doop.ogg", "steam")
music:setLooping(true)
love.audio.play(music)
end
function love.update(dt)
for i = #all_rocks,1,-1 do
local rock = all_rocks[i]
if rock.y > love.graphics.getHeight() then
table.remove(all_rocks,i)
end
end
rock.y = rock.y + dt*rock.fallSpeed
if love.keyboard.isDown("w") then
RockMoveY = RockMoveY - RockMoveS*dt
MonsterR:update(dt)
end
if love.keyboard.isDown("s") then
RockMoveY = RockMoveY + RockMoveS*dt
MonsterR:update(dt)
end
if love.keyboard.isDown("d") then
RockMoveX = RockMoveX + RockMoveS*dt
MonsterR:update(dt)
end
if love.keyboard.isDown("a") then
RockMoveX = RockMoveX - RockMoveS*dt
MonsterR:update(dt)
end
if love.keyboard.isDown(" ") and BoulderSpawn == true then
Rocks_spawn(RockMoveX, rock.y, rockbarf)
BoulderSpawn = false
end
if love.keyboard.isDown("d") and love.keyboard.isDown("s") then
RockMoveS = 210
end
if love.keyboard.isDown("a") and love.keyboard.isDown("s") then
RockMoveS = 210
end
if love.keyboard.isDown("a") and love.keyboard.isDown("w") then
RockMoveS = 205
end
if love.keyboard.isDown("d") and love.keyboard.isDown("w") then
RockMoveS = 205
end
if RockMoveY > 555 then
RockMoveY = 555
end
if RockMoveX > 755 then
RockMoveX = 755
end
if RockMoveY < 0 then
RockMoveY = 0
end
if RockMoveX < 0 then
RockMoveX = 0
end
end
all_rocks is a local variable inside rock.lua, if you want it to be accessible in main.lua you have to write all_rocks = {} instead of "local all_rocks = {}"
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
You still haven't made a .love. If Nixola's answer doesn't solve your problem completely, please make a .love and upload it as an attachment before you expect more help.
Okay, here's your problem: your game is very, very incomplete. You don't seem to have a Rock_draw(), for example.
But the issue that's directly causing your error is that line 38 is placed wrong. rock.y = rock.y + dt*rock.fallSpeed should be inside the for-loop you close just two lines above that line, because you want to do that for every rock.
for variable = start number, end number, step do
--zero or more statements
end
By default, the step is 1, "variable" is usually i, or j (if in a nested loop), but you can name it to any variable. Just note that "variable" is a local variable, that is, it cannot be accessed from outside that statement, only in the inside.