Page 1 of 2

Very slow character

Posted: Mon Jun 19, 2017 7:37 pm
by Pospos
Since my lua programs doesn't work on windows, i'm temprorarely tring on linux!
i made a little game where you have to escape an enemy, i'm trying to add bullets but sadly,
my game started to glitched out when i started to split the files in differents .lua files to organize a little bit
the game.
the glitch is that the player character is very slow and i don't know why beacause the enemy is as fast at it was
before i splited the file
(EDIT) the scancode don't work either.
there is the game file.

(EDIT) changed the game file.

Re: Very slow character

Posted: Tue Jun 20, 2017 8:47 am
by xNick1
Would you be so kind to attach a .love file?

Re: Very slow character

Posted: Tue Jun 20, 2017 10:56 am
by Pospos
Done. The file is now a .love file runnable on windows.

Re: Very slow character

Posted: Tue Jun 20, 2017 12:37 pm
by zorg
Not according to the link in your first post it isn't. (You just renamed the folder to contents.love)

You'd need to put the contents in the folder into a new archive file (a zip file, to be precise), save that, and share that... though google drive auto-zips folders when you download them, so :3

Also, to attach the .love to your post, just drag it into the text area when you're writing a new one, and it'll be attached; Nick meant that, and it's better that way since it won't rely on 3rd party hosts (not that google drive will disappear soon, but still)

Edit: I looked at the project; i have no idea why you have an extra main.lua in your lib folder, but the issue is most probably that you forgot to multiply each something = something + speed with dt.

Code: Select all

x = x + v * dt
That would make movement speeds and everything consistent everywhere.

Re: Very slow character

Posted: Tue Jun 20, 2017 1:05 pm
by Pospos
i have changed these

Code: Select all

       player.x = player.x -player.speed
into these

Code: Select all

    player.x = player.x - player.speed * dt
but now my character doesn't even move.

Re: Very slow character

Posted: Tue Jun 20, 2017 1:16 pm
by zorg
That's because, as you said, your character moved very slow to begin with.

if the player.speed is 100, then 100*dt means move 100 pixels per second; you have the speed variable set to 2, and 2 pixels/second is slow.

Re: Very slow character

Posted: Tue Jun 20, 2017 1:29 pm
by Pospos
i set the player.speed to 100 but that's still very laggy though.
The character looks disgustingly laggy, it looks like it 3 fps.
Do you have another solution? :roll:
is it possible to set a smaller delta time to, like, 0.01 sec, this way, the character will still look decent.?

Re: Very slow character

Posted: Tue Jun 20, 2017 4:39 pm
by zorg
dt should be around 1/60 if vsync is on, and 1/1000 if it's off... i haven't looked too much into your code though.

Re: Very slow character

Posted: Tue Jun 20, 2017 6:59 pm
by Pospos
Are you sure this is the only way to lower dt?
Beacause this bool set to true or false it's the same thing.

Re: Very slow character

Posted: Tue Jun 20, 2017 7:05 pm
by zorg
Yes, that one.
Also it's -not- the same thing.
If it is, then either your drivers are messing something up, or your code is wrong... sadly i dont have more time looking into it, maybe someone else will.