Search found 1719 matches

by ivan
Fri Apr 09, 2021 10:43 am
Forum: Games and Creations
Topic: Point in triangle
Replies: 3
Views: 285

Re: Point in triangle

If I remember correctly from Ericson's book, it may be possible to do even further performance optimizations - but you have to know the triangle's winding/orientation in advance.
by ivan
Thu Apr 08, 2021 5:12 pm
Forum: Games and Creations
Topic: Point in triangle
Replies: 3
Views: 285

Re: Point in triangle

Hello, I haven't tested your code, but I think there are a lot simpler and more efficient ways to test if a point is inside a triangle: https://2dengine.com/?p=intersections#Point_inside_triangle The issues with your code are: 1. The intermediate a,b,c tables. That's very inefficient 2. No "ear...
by ivan
Sat Apr 03, 2021 2:30 pm
Forum: Ports
Topic: Love.js - A Direct Emscripten Port
Replies: 207
Views: 253789

Re: Love.js - A Direct Emscripten Port

I have a followup update on the LoveJS Web player. It can now load files from arbitrary locations: example.com/lovejsplayer/?g=path/to/my/game.love The supplied path is relative to the lovejsplayer's install directory (cross-domain requests will not work) Some additional arguments: &f=1 disables...
by ivan
Wed Mar 31, 2021 5:08 pm
Forum: Support and Development
Topic: Enforce just one instance?
Replies: 21
Views: 4950

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: 4950

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: 5483

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: 4950

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: 2252

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: 2252

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: 3255

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)