Search found 21 matches

by akopyl
Tue Oct 08, 2019 9:58 pm
Forum: General
Topic: Decrease velocity
Replies: 5
Views: 2449

Re: Decrease velocity

Usually we call it friction.
Here's a simple way to do it:

Code: Select all

player.xVel = player.xVel * (1 - math.min(player.friction*dt, 1))
by akopyl
Fri Jan 25, 2019 12:42 am
Forum: Support and Development
Topic: Can't get accurate trajectory predictions with Box2d
Replies: 2
Views: 1323

Re: Can't get accurate trajectory predictions with Box2d

Thanks! Turns out the bigger the meter the more accurate my prediction will be up to a certain extent.
by akopyl
Thu Jan 24, 2019 7:02 pm
Forum: Support and Development
Topic: Can't get accurate trajectory predictions with Box2d
Replies: 2
Views: 1323

Can't get accurate trajectory predictions with Box2d

As the title says the trajectories that I predict don't line up with the path that the body ends up taking. I'd also like to note that the innacuracy is proportional to the gravity. (world.lua line 8) I'm attaching the .love file but please note that it's for v0.10.2. Sorry for all the bad code, any...
by akopyl
Tue Jan 22, 2019 6:26 pm
Forum: Support and Development
Topic: Using a single return value of a fucntion
Replies: 6
Views: 1815

Re: Using a single return value of a fucntion

Thanks everyone! Very useful!
by akopyl
Tue Jan 22, 2019 5:14 pm
Forum: Support and Development
Topic: Using a single return value of a fucntion
Replies: 6
Views: 1815

Using a single return value of a fucntion

How do I get the n-th return value of a function with multiple return values?

Here's something that doesn't work:

Code: Select all

function foo()
	return 1, 2, 3
end

two = {foo()}[2]
by akopyl
Mon Aug 21, 2017 10:21 am
Forum: Support and Development
Topic: Functions in a table [SOLVED]
Replies: 3
Views: 801

Re: Functions in a table

Yes, there is! function map.setLvl(n) map['load' .. n]() end You need to use the [] notation for tables, and concatenate the first part of the key with the index, then call that value which is the function returned by that expression. Wow, crazy. Thanks for the help. I always knew there was a bette...
by akopyl
Mon Aug 21, 2017 9:58 am
Forum: Support and Development
Topic: Functions in a table [SOLVED]
Replies: 3
Views: 801

Functions in a table [SOLVED]

Is there a more elegant way of doing this?

Code: Select all

function map.setLvl(n)
  if n == 0 then
    map.load0()
  elseif n == 1 then
    map.load1()
  elseif n == 2 then
    map.load2()
  elseif n == 3 then
    map.load3()
  end
end
This doesn't work

Code: Select all

function map.setLvl(n)
 map.load[n]()
end
by akopyl
Wed Apr 27, 2016 9:10 pm
Forum: Support and Development
Topic: Audio restarts after love.load()
Replies: 6
Views: 1032

Re: Audio restarts after love.load()

zorg wrote:Neat gorilla.bas remake though.
Oh my god! I didnt even know this game existed! This is awesome! Thanks for your help anyway, I still can do something stupid like that play call in update, so it definetly helps to have someone point that out :D
by akopyl
Wed Apr 27, 2016 8:33 pm
Forum: Support and Development
Topic: Audio restarts after love.load()
Replies: 6
Views: 1032

Re: Audio restarts after love.load()

if anything, some audio functionality has changed between 0.9 and 0.10, so i'd check love.audio on the wiki. In more detail, playing/paused/stopped states have been messed with, so it can work differently. Me asking you for your love.load function still stands though. This is a pretty messy pile of...
by akopyl
Wed Apr 27, 2016 7:52 pm
Forum: Support and Development
Topic: Audio restarts after love.load()
Replies: 6
Views: 1032

Re: Audio restarts after love.load()

love.load is a function you write; if anything, some audio functionality has changed between 0.9 and 0.10, so i'd check love.audio on the wiki. Then again, post your love.load function, and maybe we can tell what changed. The thing is that if i launch my game with 0.9.2 then it goes on, but if i la...