Malleable terrain system

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
sabe_nada
Prole
Posts: 1
Joined: Mon Sep 14, 2015 8:38 pm

Malleable terrain system

Post by sabe_nada »

Hello, I'm new to LÖVE and coding in general. I'm trying to figure out how to make a side scroller with highly moldable terrain. Something visually similar to this: http://thisissand.com/ + Worms-like terrain.

Think of a 2d sandbox of sorts, where the player can pour in different materials, which are interactible and destructible. It does not need to be a physics simulation. Objects do not have to possess realistic behavior other than a visually appealing falling and stacking effect.

The naive solution I found was to simply add all the individual sprites and their respective positions and speed on a table of tables. As expected this brings the performance down very very quickly, and this is just to keep track of the sprites. Just looping through thousands of tables and doing nothing more already brings the FPS under 60.

Next attempt was to separate "active" sprites and "resting" sprites. Once a pixel hit the floor and stopped moving, I deleted from the active sprites table and added to a spritebatch. Performance is vastly improved, but I'm yet to figure how to pile up the sand, not to mention the "sliding sand" effect and collision detection with other entities.

Any ideas? Thanks in advance!
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Malleable terrain system

Post by bobbyjones »

Are you using canvases and spritebatches?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 199 guests