Search found 1777 matches

by pgimeno
Wed Sep 18, 2019 11:26 pm
Forum: General
Topic: Concatenation and garbage
Replies: 5
Views: 129

Re: Concatenation and garbage

LuaJIT is the one we're interested in here. I've shown that it generates bytecode consistent with right associativity and that it has an opcode that joins several strings at once, like Lua does. I don't need to check the LuaJIT source code in order to infer that Mike Pall realized that this optimiza...
by pgimeno
Wed Sep 18, 2019 11:09 pm
Forum: Support and Development
Topic: a super fast AABB collision detection ( Minkowski Sums )
Replies: 9
Views: 201

Re: a super fast AABB collision detection ( Minkowski Sums )

The Minkowski difference reduces rectangle-rectangle interaction to point-rectangle interaction, which IMO is easier to process and reason through. It helps, for example, with swept collision checking, as you only have to check a line segment against each box, rather than a moving box.
by pgimeno
Wed Sep 18, 2019 1:07 pm
Forum: Support and Development
Topic: a super fast AABB collision detection ( Minkowski Sums )
Replies: 9
Views: 201

Re: a super fast AABB collision detection ( Minkowski Sums )

Bump uses the closely related Minkowski difference method, both to detect and to resolve collisions.
by pgimeno
Wed Sep 18, 2019 1:03 pm
Forum: General
Topic: Concatenation and garbage
Replies: 5
Views: 129

Re: Concatenation and garbage

Fair enough. I've edited the statement to be more precise. The source code clearly gathers as many as possible without generating intermediate concatenated strings. https://www.lua.org/source/5.1/lvm.c.html#luaV_concat From the source of luaV_tostring (https://www.lua.org/source/5.1/lvm.c.html#luaV_...
by pgimeno
Wed Sep 18, 2019 11:32 am
Forum: General
Topic: Concatenation and garbage
Replies: 5
Views: 129

Concatenation and garbage

I wanted to share something that I've discovered about how Lua handles concatenation, which may be useful if you worry about writing optimized code. I noticed in the Lua manual that the concatenation operator is right associative. The operation itself is associative: you get the same result from ("a...
by pgimeno
Tue Sep 17, 2019 11:24 pm
Forum: Support and Development
Topic: is it necessary to "free" texture data / love.graphics.Image ?
Replies: 8
Views: 189

Re: is it necessary to "free" texture data / love.graphics.Image ?

I've found that in a similar situation, if I didn't force garbage collection, the memory grew and grew out of control until the memory was completely filled. My hypothesis is that, since Lua does not know the size of the underlying object, it doesn't care that there are many big ones waiting to be g...
by pgimeno
Tue Sep 17, 2019 9:37 am
Forum: Support and Development
Topic: Detecting Input Without Window Focus (Listen For Input In The Background)
Replies: 5
Views: 175

Re: Detecting Input Without Window Focus (Listen For Input In The Background)

The whole concept of focus is about where to send input events, isn't it? Imagine you are typing in an editor, then change window to a web form, and what you type in the web form is typed in the editor. [EDIT: Or that you press F1 for help in one application, and every other open application opens t...
by pgimeno
Mon Sep 16, 2019 11:37 am
Forum: Games and Creations
Topic: Chessboard
Replies: 17
Views: 2339

Re: Chessboard

Well done. Like I mentioned, the "standard" Lua way is to move your code in a module. Example of a stateless module: local lib = {} function lib.movePiece(board, from,to) .. end function lib.getPiece(board, position) .. end return lib Just a nitpick, this is not stateless in itself. The library is ...
by pgimeno
Sun Sep 15, 2019 7:49 pm
Forum: General
Topic: help with collisions
Replies: 19
Views: 993

Re: help with collisions

world:move gives you information about what object was collided. It returns several things, including the table that you passed to world:add; check the docs. If you include any information you want in that table, for example the terrain type, you can get it back when world:move detects a collision.