Search found 55 matches

by TheHUG
Thu Sep 26, 2019 3:25 pm
Forum: Support and Development
Topic: [Solved] Hump.camera + love.physics
Replies: 3
Views: 574

Re: Hump.camera + love.physics

Another possible solution: If your camera is always centered on the player, then you can just setLinearVelocity() on the camera-stationary objects to be equal to that of the player (not sure what order love physics resolves force, acceleration, velocity, depending on that and how you move your playe...
by TheHUG
Mon Sep 16, 2019 6:52 am
Forum: Support and Development
Topic: Writing unit tests within love code
Replies: 9
Views: 2603

Re: Writing unit tests within love code

for tests where I need access to love functions I use: https://love2d.org/forums/viewtopic.php?t=75192

Another option would be to mock the functions you need
by TheHUG
Sat Aug 24, 2019 2:48 pm
Forum: Support and Development
Topic: Code review please
Replies: 8
Views: 1249

Re: Code review please

Ok, I wasn't sure if global or local took longer to load or something. What I'm creating is rather simple so having global variables shouldn't be an issue. Thanks! In this case, count, for example, is a global variable. In lua, unlike python, variable scope is global unless explicitly declared to b...
by TheHUG
Fri Aug 23, 2019 6:50 pm
Forum: Support and Development
Topic: Code review please
Replies: 8
Views: 1249

Re: Code review please

You have some one-letter variable names where it isn't immediately obvious what they are.
(Q, I ,f w, c), I think they'd be better off as full words.

Most coding standards agree that it is best to limit the number of characters per line to around 80 characters.
by TheHUG
Sat Jul 20, 2019 9:11 am
Forum: Support and Development
Topic: Trace a curve which pass through all of the points.
Replies: 8
Views: 1342

Re: Trace a curve which pass through all of the points.

Whatever my girlfriend's svg editing software used for it's curves ( which it did call bezier) does pass through all the points, so I was also surprised by this. I spent some time looking for this, and I didn't find anything. I think you'll need to come up with it yourself. I was thinking of doing i...
by TheHUG
Sat Jul 13, 2019 6:22 pm
Forum: Support and Development
Topic: Object inheritance
Replies: 26
Views: 3365

Re: Object inheritance

That's a pretty good idea
by TheHUG
Sat Jul 13, 2019 5:47 pm
Forum: Support and Development
Topic: What is setUserData and why do I need it?
Replies: 24
Views: 2351

Re: What is setUserData and why do I need it?

But then you have to modify the table every time a body is created or destroyed. As for creation, in the other method you have to setUserData anyway, so there's no significant advantage - both methods require an action at creation time. As for destruction, weak tables take care of that automaticall...
by TheHUG
Sat Jul 13, 2019 5:29 pm
Forum: Support and Development
Topic: Object inheritance
Replies: 26
Views: 3365

Re: Object inheritance

Yes that's true about self.__index, you could set A.__index = A, and then do the same whenever you define a new class, or if you prefer to keep the metatable and the superclass separate you could define local metaA = {__index=A} and set that to be the metatable of subclasses. It's an additional thin...
by TheHUG
Sat Jul 13, 2019 2:44 pm
Forum: Support and Development
Topic: Object inheritance
Replies: 26
Views: 3365

Re: Object inheritance

An example of more levels of inheritance would be: Object = {} function Object:new(x, y) local o = {x=x, y=y} setmetatable(o, self) self.__index = self return o end Collider = Object:new() -- Collider inherits Object's :new method function Collider:collide(...) ... end a_collider = Collider:new() --...
by TheHUG
Sat Jul 13, 2019 6:06 am
Forum: Support and Development
Topic: [SOLVED] Math + Spread bullets
Replies: 10
Views: 1227

Re: Math + Spread bullets

First thanks again all of you. Both aproach gave interesting result. After post my last reply I found what I was searching with just adding two var that I may have to random: table.insert(b, {x = startX, y = startY, dx = bulletDx, dy = bulletDy,r=size,vx=15,vy=15}) -- and v.x = v.x + ((v.dx+v.vx) *...