Search found 1736 matches

by ivan
Wed Mar 31, 2021 5:08 pm
Forum: Support and Development
Topic: Enforce just one instance?
Replies: 21
Views: 9090

Re: Enforce just one instance?

Yea, I hear you grump. I'm not in a rush, but file locking seems like a super basic operation that should be available in love.filesystem by default
by ivan
Wed Mar 31, 2021 12:42 pm
Forum: Support and Development
Topic: Enforce just one instance?
Replies: 21
Views: 9090

Re: Enforce just one instance?

The socket solution is clever but it's hacky.
We need to open an issue request to include love.filesystem.lock in the next version of love2d.
lfs.lock seems to available in similar libraries
by ivan
Mon Mar 22, 2021 8:50 am
Forum: General
Topic: Example code of Platformer AI
Replies: 15
Views: 8683

Re: Example code of Platformer AI

I want to see any type of enemy AI that can jump gaps and walls. You answered your own question there, you are looking for path finding and possibly obstacle avoidance. When working with tile-based maps you can just check how large the gap is easily and determine if the player can jump over it. Hav...
by ivan
Sun Mar 21, 2021 1:20 pm
Forum: Support and Development
Topic: Enforce just one instance?
Replies: 21
Views: 9090

Re: Enforce just one instance?

A simple way would be to have your project create a file when opened, and delete it before it quits (there's a callback for the latter) Yes, I use this method too, although you have to check if that file is locked or not. If the file is there but it's not locked then the previous instance has eithe...
by ivan
Thu Mar 18, 2021 5:46 am
Forum: Games and Creations
Topic: Point In Polygon algorithm
Replies: 11
Views: 5409

Re: Point In Polygon algorithm

If you want to use tables for each point then write: function in_convex_polygon(point, polygon) You don't want to be converting these for no reason. I don't like the ring_index function either. A simpler and faster way is: local last = polygon[#polygon] for i = 1, #polygon do local current = polygon...
by ivan
Wed Mar 17, 2021 5:05 pm
Forum: Games and Creations
Topic: Point In Polygon algorithm
Replies: 11
Views: 5409

Re: Point In Polygon algorithm

side({x=x, y=y} means a new table instance for every step of your loop which is not good.

Check out my version stolen from vrld: https://2dengine.com/?p=polygons#Point_in_polygon
by ivan
Tue Mar 16, 2021 11:45 am
Forum: Support and Development
Topic: Problems with slow movement speeds
Replies: 24
Views: 6755

Re: Problems with slow movement speeds

If you overwrite rect.x and rect.y the movement will be choppy and it won work when rect.speed*dt < 0.5
If you want to use rounding, then just do it when drawing:

Code: Select all

love.graphics.rectangle("fill", math.floor(rect.draw_x + 0.5), math.floor(rect.draw_y + 0.5), rect.width, rect.height)
by ivan
Tue Mar 16, 2021 7:14 am
Forum: Ports
Topic: Love.js - A Direct Emscripten Port
Replies: 207
Views: 319040

Re: Love.js - A Direct Emscripten Port

Have you tried defining the allocated memory?
If you are using the love.js player you can change the memory using the &m= argument ?g=game.love&m=MEMORY
by ivan
Wed Mar 10, 2021 12:01 pm
Forum: General
Topic: How to get the size of a table/object in love2d
Replies: 7
Views: 2640

Re: How to get the size of a table/object in love2d

That looks like collectgarbage("count") which measures the total amount of Lua memory for the current thread. Does not include love2d images, sounds or other assets.
by ivan
Wed Mar 10, 2021 10:40 am
Forum: General
Topic: How to get the size of a table/object in love2d
Replies: 7
Views: 2640

Re: How to get the size of a table/object in love2d

No, there is no way to know how much memory the table consumes, Lua is a scripted language with managed memory (NOT pre-allocated). You can't measure the size of a reference to another table. There could be cycles and so forth. It's not like you can garbage collect any table and expect a specific am...