how would i go about making a platformer with destructible terrain in love2d?
example: http://jastanton.com/experiments/Destructible-Terrain/
best regards Felix
making a platform game with destructible terrain?
Re: making a platform game with destructible terrain?
Well...
I think you should start with the easiest thing and build out the system from there. Maybe start with a player represented by a table with an x and y position. Every frame update the position based on input. Then add gravity and floor collision detection. Then add a data representation to represent your level. Then add the ability to modify the data representation based on mouse position when you click.
I think you should start with the easiest thing and build out the system from there. Maybe start with a player represented by a table with an x and y position. Every frame update the position based on input. Then add gravity and floor collision detection. Then add a data representation to represent your level. Then add the ability to modify the data representation based on mouse position when you click.
Re: making a platform game with destructible terrain?
Thanks! I will try to do it.
Re: making a platform game with destructible terrain?
If you haven't found a solution already, I actually use destructible terrain in my current project (albeit more tile destruction, not worms style). I did it by having my tile loader spawn objects with a health attribute and during a bullet collision event, the health of the object is subtracted by the damage of the bullet. Here is a sample of my collision event using HC where my bullets and static objects are stored in tables:
Then in the static object I have the following check function:
And my garbage collector removes it. In addition, if you want levels of destruction, you can have the aforementioned function check for levels of health and change the sprite accordingly. I don't know if its the best way but it worked well for me. I hope this helps in some way.
Code: Select all
function checkCollision()
for i=1,#bullets do
for k=1,#statics do
if statics[k].mask then
local collides, dx, dy = bullets[i].mask:collidesWith(statics[k].mask)
if collides then
statics[k].health = statics[k].health - bullets[i].damage
bullets[i].remove = true
end
end
end
end
end
Code: Select all
if self.health <= 0 then self.remove = true end
Re: making a platform game with destructible terrain?
Thanks very much! That sounds very interesting. I will try to implement it into a future game.
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests