Search found 5 matches
- Sun Aug 08, 2021 4:36 pm
- Forum: General
- Topic: Passing arguments to a function used as an argument?
- Replies: 7
- Views: 8307
Re: Passing arguments to a function used as an argument?
A function when passed around is just the function. If you also want to pass around arguments, you have to pass them separately (as you've been trying), or you can wrap the function in a table. In other programming languages this is called a closure or a delegate . This code is a bit weird for educ...
- Sun Aug 08, 2021 2:16 pm
- Forum: General
- Topic: Passing arguments to a function used as an argument?
- Replies: 7
- Views: 8307
Re: Passing arguments to a function used as an argument?
I don't really understand what you mean... like using a function as an argument and that function also needing arguments? Like if onCollision needs to know which sound to play other than hurt.wav? Maybe function projectiles:update(dt) projectiles:onCollision("wall",playSound, "hurt.w...
- Sun Aug 08, 2021 10:40 am
- Forum: General
- Topic: Passing arguments to a function used as an argument?
- Replies: 7
- Views: 8307
Passing arguments to a function used as an argument?
I know this is a more lua related question but I need it inside my love project, I am at least attempting to make my code a bit flexible, so i defined a function that gets called on object collision and takes in an argument of what object class it has to collide with and what function to execute, bu...
- Tue Aug 03, 2021 1:30 am
- Forum: General
- Topic: Can someone help a beginner with some math?
- Replies: 5
- Views: 5257
Re: Can someone help a beginner with some math?
Welcome to the forums. Taking the atan2 for passing it to sine and cosine is something that is unfortunately seen very frequently. These are unnecessary calculations when all you need is a unit vector, needing just a square root. local vx, vy = targetx - x, targety - y local len = math.sqrt(vx*vx +...
- Sat Jul 31, 2021 6:25 pm
- Forum: General
- Topic: Can someone help a beginner with some math?
- Replies: 5
- Views: 5257
Can someone help a beginner with some math?
I am trying to somewhat independently learn how to use lua and love, though I have used lua a bit in the past i am confused about some stuff, namely calculating the vector for a projectile and some other stuff, i have followed skyvaultgames' first love tutorial for the shooting part, it does work bu...