Search found 1078 matches

by micha
Wed May 27, 2015 11:46 am
Forum: Support and Development
Topic: Movement Relative to Mouse
Replies: 13
Views: 4678

Re: Movement Relative to Mouse

Robin wrote:When strafing, you'll need to swap math.cos and math.sin, because movement will be rotated by 90 degrees. I think. I didn't test it. But it was something like that.
Almost. To rotate a vector (x,y) by 90 degrees, swap the two components and multiply one by -1. You get (y,-x) and (-y,x).
by micha
Sat May 09, 2015 11:08 am
Forum: Support and Development
Topic: Sounds that repeat and overlap
Replies: 5
Views: 3215

Re: Sounds that repeat and overlap

Yes, I think this is the right approach. I don't know, though, how lua manages the source, if they are local variables. When the sound is over, you should delete the source from memory. I don't know whether lua deletes a source by itself, if it is stored in a local variable or not. Maybe it is bette...
by micha
Fri May 08, 2015 12:21 pm
Forum: Support and Development
Topic: Sounds that repeat and overlap
Replies: 5
Views: 3215

Re: Sounds that repeat and overlap

UPDATE From https://love2d.org/forums/viewtopic.php?f=4&t=2220 "Basically, you need to create your sound as a SoundData, and when you want to play it, create a Source from the SoundData and play that." ^ Is this the best solution? Where/how do I save the Source data? Do I have to have...
by micha
Wed May 06, 2015 7:29 pm
Forum: General
Topic: Questions about require, calling tables from files.
Replies: 13
Views: 6871

Re: Questions about require, calling tables from files.

No you don't have to assign require-calls to local variables, but you should do so. When you call require, then the code in the required file is executed. If this code defines a global variable, then it will also exist in your normal program. However, in most cases, it is bad practice to define glob...
by micha
Fri Apr 24, 2015 6:12 am
Forum: General
Topic: The Hello World Challenge
Replies: 2
Views: 1772

Re: The Hello World Challenge

"Just making a thread" worked very well in the "Code doodle"-thread. If you go ahead and post a first hello-world example, this might encourage people to follow and submit their idea.
by micha
Fri Apr 24, 2015 5:29 am
Forum: Support and Development
Topic: [Solved]Paths
Replies: 7
Views: 2356

Re: [Solved]Paths

The idea is this: If you want to move in a non 45-degree angle then the x-velocity and the y-velocity need to have the correct ratio, so that you move exactly towards the target point. If, for example, the target is 200 pixel away in x-direction and 100 away pixel in y-direction then also the x-velo...
by micha
Thu Apr 23, 2015 7:42 pm
Forum: Support and Development
Topic: [Solved]Paths
Replies: 7
Views: 2356

Re: Paths

To make the object move in a non-45-degree angle, you have two options: 1) Take the distance vector to the target, normalize it (by dividing by its length) and multiply by speed and dt local dx = target.x - object.x local dy = target.y - object.y local distance = math.sqrt(dx^2+dy^2) local vx = dx/d...
by micha
Wed Apr 22, 2015 2:59 pm
Forum: Support and Development
Topic: [Solved] Friction and FPS troubles!
Replies: 9
Views: 4649

Re: Friction and FPS troubles!

You are right. I did not think of that.
by micha
Wed Apr 22, 2015 1:05 pm
Forum: Support and Development
Topic: [Solved] Friction and FPS troubles!
Replies: 9
Views: 4649

Re: Friction and FPS troubles!

Robin wrote:I don't think that's what you want: it's not frame-rate independent, higher frame-rates result in stronger damping.
That is very true.

However, if dt varies only a little bit, then this approximation will work well (everything is approximately linear for small changes).
by micha
Tue Apr 21, 2015 11:15 am
Forum: Support and Development
Topic: [Solved] Friction and FPS troubles!
Replies: 9
Views: 4649

Re: Friction and FPS troubles!

Hi and welcome to the forum. You code is almost fine. You will not need a framerate delimiter. Instead should make the code work with arbitrary framerates. You only need to make a few changes: Replace this line: Player.vel = Player.vel - Player.friction by this line: Player.vel = Player.vel - Player...