Posted 22 July 2013 - 10:08 AM
First off, let me say..
Yes, I know there is a Love2d forum, but it aint working for me, so I'd figured I post it here.
Im sorry if this gives you rage :3
So, me being a noob to Love2d I tried to create Pong, and I'm getting attempt to index global 'block1' (a nil value) when Im trying to make a function called block1:up().
If anyone could help me I would greatly appreciate it.
If anyone wants to have the full program (That is the pictures, config, etc.) just say so and I will upload it.
Yes, I know there is a Love2d forum, but it aint working for me, so I'd figured I post it here.
Im sorry if this gives you rage :3
So, me being a noob to Love2d I tried to create Pong, and I'm getting attempt to index global 'block1' (a nil value) when Im trying to make a function called block1:up().
function love.load()
love.graphics.setBackgroundColor( 200, 200, 255)
block = love.graphics.newImage("Block.png")
ball = love.graphics.newImage("Pong_Ball.png")
gameStage = "playing"
block1 = {
pos = 200,
vel = 0,
speed = 10,
}
end
function love.draw()
if gameStage == "playing" then
love.graphics.draw(block, 1, block1.pos)
end
end
function block1:up(dt) --This is line 21
self.pos = self.pos + (self.speed * dt)
end
function block1:down(dt)
self.pos = self.pos - (self.speed * dt)
end
function love.update(dt)
if dt > 0.05 then
dt = 0.05
end
if love.keyboard.isDown("w") then
block1:up()
end
if love.keyBoard.isDown("s") then
block1:down()
end
end
If anyone could help me I would greatly appreciate it.
If anyone wants to have the full program (That is the pictures, config, etc.) just say so and I will upload it.