-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
table index is nill #18
Comments
I need more information in order to be able to help you. Can you provide of the code showing the issue? |
sure thing: local bump = require 'lib/bump' local world = bump.newWorld(50) function love.update(dt) function love.draw() world:add(player, px, py, 50, 50) print(world:getRect(enemy)) sorry for being a bit late |
Hi there, The problem is, fortunatelly, quite simple: you are not using In LÖVE, the drawing-related functions (like For this reason, A way to get around this is using a Lua table to represent Here is a version that should work (I have not tested it for typos and such). local bump = require 'lib/bump'
local world = bump.newWorld(50)
local player = {x = 10, y = 10, w = 50, h = 50, speed = 100}
local enemy = {x = 100, y = 100, w = 50, h = 50}
world:add(player, player.x, player.y, player.w, player.h)
world:add(enemy, enemy.x, enemy.y, enemy.w, enemy.h)
function love.update(dt)
if love.keyboard.isDown('d') then player.x = player.x + player.speed * dt end
if love.keyboard.isDown('a') then player.x = player.x - player.speed * dt end
if love.keyboard.isDown('s') then player.y = player.y + player.speed * dt end
if love.keyboard.isDown('w') then player.y = player.y - player.speed * dt end
world:move(player, player.x, player.y)
if love.keyboard.isDown('escape') then love.quit() end
print(world:getRect(enemy))
end
function love.draw()
love.graphics.setColor(255,255,255)
love.graphics.rectangle("fill", player.x, player.y, player.w, player.h)
love.graphics.rectangle("fill", enemy.x, enemy.y, enemy.w, enemy.h)
end
Since this is not an issue with bump, I am closing this issue. Feel free to ask more questions (if you have questions about LÖVE, however, I would recommend you to ask them in the LÖVE forums, there's lots of people which can help you there besides me, and my schedule has been a bit packed lately). Regards! |
tried to add some rectangles to the world and this error appeared
The text was updated successfully, but these errors were encountered: