Search found 18 matches

by damv
Thu Aug 15, 2019 1:43 am
Forum: Libraries and Tools
Topic: Lovepad - A simple gamepad library for android games
Replies: 0
Views: 5738

Lovepad - A simple gamepad library for android games

Hi there, A few days ago I downloaded the love2d apk with the intention of programming from the cell phone, and I discovered that it is a bit complicated to program games using touch, I mean that my intention is to create games quickly and easily from the cell phone. That is why I prepared to write ...
by damv
Wed Aug 07, 2019 3:59 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

Also, you seem to have mixed tabs and spaces. If you look at https://github.com/DeybisMelendez/lua-vector/blob/v0.7.0/vector.lua you'll see the difference between lines 67 and before, and 68 and after, because GitHub uses a tab size of 8. Personally I'm more of the "no tabs ever" school b...
by damv
Wed Aug 07, 2019 3:50 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

If you really care about performance (maybe just in special areas of some innerloops where you need the best possible performance) you could easily localize the methods in question, shortcutting all the overhead described above and directly call them with your tables. I just want to add that the ab...
by damv
Tue Jul 30, 2019 10:55 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

by damv
Tue Jul 30, 2019 6:57 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

ivan wrote: Tue Jul 30, 2019 6:24 pm What Nelvin said.
My point was that closures have their own benefits just not in this case.
Your vectors are short lived and you create intermediate ones all the time when using the Lua operators.
Thank you very much, I will make the change.
by damv
Tue Jul 30, 2019 6:24 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

I'd like to repeat what ivan said as it's not only not very efficient, it also wastes a lot of memory. The problem with the code, as it is, is not primarily the closure but whenever you create a vector instance (which, at the moment, you do in almost all core operations) you create a new table and ...
by damv
Tue Jul 30, 2019 6:09 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

Just to clarify - its not all bad. Using closures is actually faster than metatables and doesn't require the colon : operator. This does come at a price, in particular with the initialization overhead and memory usage. Closures are very good for longer lived objects that you call a lot. This is ver...
by damv
Mon Jul 29, 2019 6:27 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Re: Another Lua Vector library

Looks fine, I am not 100% convinced by your object-orientation code. Some functionality is based on closures: local vec = {x = x or 0, y = y or 0} function vec:string() return "vector(" .. self.x .. ", " .. self.y ..")" end ... and some functionality is implemented usi...
by damv
Mon Jul 29, 2019 5:08 pm
Forum: Libraries and Tools
Topic: Another Lua Vector library
Replies: 14
Views: 15140

Another Lua Vector library

Hello, I share my library on 2d vectors, it has nothing very innovative but I hope you like it, I made it for my personal use but I share it, any advice, doubt, or criticism is accepted. Doc: https://github.com/DeybisMelendez/lua-vector/blob/master/README.md Source: https://github.com/DeybisMelendez...
by damv
Thu May 02, 2019 8:14 pm
Forum: Libraries and Tools
Topic: Lua Vector
Replies: 12
Views: 14151

Re: Lua Vector

the vector table does not inherit the checkError () method, it is a proprietary method that instantiates in the "require" once nothing else, like the constants vector.RIGHT, vector.LEFT, etc. function vector.checkError(case, func, a) print ( 'checkerror', case, func, a ) ... local vec = r...