Destroy body with Löve2D physics

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Manyrio
Prole
Posts: 29
Joined: Sat Feb 06, 2016 10:12 am

Destroy body with Löve2D physics

Post by Manyrio »

Hey, I am creating a sandbox game using love physics and other libaries (Light vs shadow engine v2 and videolib). I've create a map and when I place a "block", it create a new physic body but when I want to destroy one, it say me " main.lua:238: attempt to index a nil value".
I check all my code but I don't find the bug ...
(Sorry if my english is very poor, i'm french)
Here my game in .love
Attachments
UnviPlanet.love
(5.08 MiB) Downloaded 150 times
function love.load() end
function love.update(dt) end
function love.draw() end
Manyrio
Prole
Posts: 29
Joined: Sat Feb 06, 2016 10:12 am

Re: Destroy body with Löve2D physics

Post by Manyrio »

Here a screenshot of the game :
Image
function love.load() end
function love.update(dt) end
function love.draw() end
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Destroy body with Löve2D physics

Post by ArchAngel075 »

been modifying the map.lua and main.lua

so many changes to make it work as expected.
I was able to make adding work, removing doesn't exactly work physics wise (but does graphically)
One major issue is you are working on globals 'stone' and 'dirt'
when you make the map, stone and dirt globals are overwritten each time a tile is made, this will result in stone and dirt globals being allllways the last overwrite.
is this intended?

also you use stone.x, stone.y which neither field exists.
Manyrio
Prole
Posts: 29
Joined: Sat Feb 06, 2016 10:12 am

Re: Destroy body with Löve2D physics

Post by Manyrio »

Hey !
What should I do to no work on globals stone and dirt ?
I didn't thought that it was overwritte each time a tile is made, I am fixing this.
I am deleting all the stone.x an stone.y
And, can I have the code you made ? Just to see
Thank you ! And I'm new in Love2D So I am not very good :/
function love.load() end
function love.update(dt) end
function love.draw() end
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: Destroy body with Löve2D physics

Post by ArchAngel075 »

err, my method isnt well made at the moment but sure ill zip up the edited files sofar.
KEY : Search the word 'ADDED' for any additions and changes i made if you don't have code comparers.
UnviPlanet-ArchEditFiles.zip
(4.48 KiB) Downloaded 108 times
To answer immediately your questions too :
1. Stone and Dirt globals are overwritten - in my edits i made a new table map_items
there is map_items.stone, map_items.dirt
I store each tile(?) in its own location by x,y ()
I kept it to overwrite global, i just use the line 'map_items.stone[x][y] = stone' to store the changes. I believe that should work.
I just returned to Love2D myself randomly nd decided to help, so apologies if my fixes are actually terrible.

good luck!
Manyrio
Prole
Posts: 29
Joined: Sat Feb 06, 2016 10:12 am

Re: Destroy body with Löve2D physics

Post by Manyrio »

Hey ! Really, thank you ! I am working on your code now :D
function love.load() end
function love.update(dt) end
function love.draw() end
Post Reply

Who is online

Users browsing this forum: No registered users and 52 guests