Remove everything from the world in Bump

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
User avatar
fridays18
Citizen
Posts: 90
Joined: Tue Nov 01, 2022 3:24 pm

Remove everything from the world in Bump

Post by fridays18 »

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

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
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Remove everything from the world in Bump

Post by darkfrei »

Code: Select all

function worldBuild(level)
--clear everything from tables and world before queing everything else
walls = {} -- no walls
listOfEnemies = {} -- no enemies

--make boarder
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
fridays18
Citizen
Posts: 90
Joined: Tue Nov 01, 2022 3:24 pm

Re: Remove everything from the world in Bump

Post by fridays18 »

darkfrei wrote: Thu Dec 01, 2022 4:45 pm

Code: Select all

function worldBuild(level)
--clear everything from tables and world before queing everything else
walls = {} -- no walls
listOfEnemies = {} -- no enemies

--make boarder
That will clear the tables but not the Bump world
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Remove everything from the world in Bump

Post by darkfrei »

fridays18 wrote: Fri Dec 02, 2022 4:35 pm
darkfrei wrote: Thu Dec 01, 2022 4:45 pm

Code: Select all

function worldBuild(level)
--clear everything from tables and world before queing everything else
walls = {} -- no walls
listOfEnemies = {} -- no enemies

--make boarder
That will clear the tables but not the Bump world
Get old cellSize and create new world:

Code: Select all

local cellsize = world.cellSize
world = bump.newWorld (cellSize)
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
fridays18
Citizen
Posts: 90
Joined: Tue Nov 01, 2022 3:24 pm

Re: Remove everything from the world in Bump

Post by fridays18 »

darkfrei wrote: Fri Dec 02, 2022 9:26 pm
fridays18 wrote: Fri Dec 02, 2022 4:35 pm
darkfrei wrote: Thu Dec 01, 2022 4:45 pm

Code: Select all

function worldBuild(level)
--clear everything from tables and world before queing everything else
walls = {} -- no walls
listOfEnemies = {} -- no enemies

--make boarder
That will clear the tables but not the Bump world
Get old cellSize and create new world:

Code: Select all

local cellsize = world.cellSize
world = bump.newWorld (cellSize)
Works perfect tysm!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 16 guests