I'm creating a pinball-like game, where a ball collides with convex polygons, as defined by a list of vertices and other parameters like bounciness, movement path, etc. You can see a screenshot of the game below.
Everything works well, including collisions, but I have two problems I would like to resolve
1) Currently, I input the location and shape of every polygon as text in a .lua file. This is obviously very tedious. Is there some external program where I could visually draw some polygons, and export it as a list of vertices (and other parameters) that I can then import as a .lua?
2) I draw every polygon with love.graphics.polygon(), but I've heard meshes are more efficient. I can draw the polygons with meshes, but the problem is that I also use a budget glow effect by drawing several copies of each polygon below it with low transparency and varying linewidth. Can I mimic this with meshes, without creating several separate meshes for each polygon? Also, I always draw < 100 polygon per frame.. is it even worth it to use meshes?
Thanks!
Creating and drawing polygons
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Creating and drawing polygons
For static polygons that aren't too big, drawing them once to a Canvas would be a good solution.
Meshes are generally more efficient than immediate mode polygons, because they don't need to be rebuild every time. They are a little more complicated to build though. If you don't have a performance problem, or if you can use Canvases, you don't need to bother with meshes.
Meshes are generally more efficient than immediate mode polygons, because they don't need to be rebuild every time. They are a little more complicated to build though. If you don't have a performance problem, or if you can use Canvases, you don't need to bother with meshes.
-
- Prole
- Posts: 4
- Joined: Sun Feb 23, 2020 4:50 pm
Re: Creating and drawing polygons
Thanks! Are you suggesting to draw each polygon to its own canvas? Or every polygon onto a single canvas? What if some of the polygons move relative to the others?
Re: Creating and drawing polygons
It depends on how big and complex the polygons are, and the number of polygons and how many you need to draw per frame. If it's hundreds of large and unique polygons that need to be moved around independently, Canvas may use too much memory.
Meshes are never the wrong choice, but the "varying line width" thing could be difficult to pull off.
It's difficult to give good advice without knowing more details.
Meshes are never the wrong choice, but the "varying line width" thing could be difficult to pull off.
It's difficult to give good advice without knowing more details.
-
- Prole
- Posts: 15
- Joined: Mon Oct 26, 2020 2:02 pm
Re: Creating and drawing polygons
1) you can use https://www.mapeditor.org/, it has a geometry editor with rectangles, circles and polygons. You can also natively export the map to a .lua file.
Who is online
Users browsing this forum: Bing [Bot] and 7 guests