Remove everything from the world in Bump
Posted: Thu Dec 01, 2022 4:17 pm
For the past couple of days ive been trying to get bump working, my most recent issue has been removing things from the world since ive found world:remove() is not as easy as it seems, in the game im making right now has rougelike elements which makes me make a new map basically each time the player goes to the next level, the issue with that is that I have to clear everything before I can generate or else theres still the new and old map collisions happening at the same time, im wondering if theres a way to just remove everything from the world and then re-add it since thats basically what im doing not with way more extra steps.
Function for clearing and making all the walls
Theres nothing under the --clear everything comment since it wasnt working which is why im here now
Function for clearing and making all the walls
Theres nothing under the --clear everything comment since it wasnt working which is why im here now
Code: Select all
function worldBuild(level)
--clear everything from tables and world before queing everything else
--make boarder
table.insert(walls,Wall(0,0,screenx,10))
table.insert(walls,Wall(0,screeny - 10,screenx,10))
table.insert(walls,Wall(0,0,10,screeny))
table.insert(walls,Wall(screenx - 10,0,10,screeny))
table.insert(walls,Wall(0,400,screenx,10))
--put all level designs through here by doing if level
--when player finish's a level call this function with func(math.random())
if level == 1 then
--left
table.insert(walls,Wall(50,100,10,200))
table.insert(walls,Wall(50,100,40,10))
table.insert(walls,Wall(50,300,40,10))
--right
table.insert(walls,Wall(340,100,10,200))
table.insert(walls,Wall(310,100,30,10))
table.insert(walls,Wall(310,300,40,10))
--center
table.insert(walls,Wall(150,150,100,100))
--enemies
table.insert(listOfEnemies,Enemy(270,305))
table.insert(listOfEnemies,Enemy(57,355))
table.insert(listOfEnemies,Enemy(284,150))
table.insert(listOfEnemies,Enemy(98,170))
end