I've been writing a simple pong game as a way of teaching myself how to use love, and I've run into something weird... I've set up a sound to play each time the ball hits either the player's bat or the enemy bat. However, despite using what is to my eye identical code, the sound does play when it hits the enemy bat, but it doesn't play when it hits the player's. I'll paste some code below - any idea what might be causing this?
Love's sound system currently sucks. Use TEsound to make up for it.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit! Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
While the LOVE sound functions themselves are well documented, they act in very odd ways. Taehl and I wrote TEsound to get around this. Sound sources act more like channels than individual sounds and therefore you can't call from a source while it's playing unless you stop it first or create a duplicate sound in a new source and play it as well.
Solution? Just use the TEsound library that Taehl linked to. Seriously, it will keep you from beating your head against a wall for hours.
@Taehl: Just because it's hard for you to use it doesn't mean it sucks, please refrain from using language like that to describe love.
Anyway, the real deal is that sound sources act like real life sound sources, you don't expect one guitar to play two guitar tracks either, do you? Now you may be wondering why this is the case. Well, part of it is that sources are in 3d space, so you could place them in a marching band, if you were to feel that way.
BlackBulletIV wrote:So I guess what's wanted here is a Sound class, which everytime you want it to play, a new source will be created.
...also, this prompts me to ask a really dumb question: I read somewhere that Lua is not an object-oriented language, although it's possible to add an object system through a module or an extension or something. Is that something I should be doing?
lesslucid wrote:I read somewhere that Lua is not an object-oriented language, although it's possible to add an object system through a module or an extension or something. Is that something I should be doing?
If you don't feel a need for a class system, then no.
Just using tables is fine in most cases.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.
BlackBulletIV wrote:So I guess what's wanted here is a Sound class, which everytime you want it to play, a new source will be created.
That's pretty much what TEsound handles for you automatically.
bartbes wrote:@Taehl: Just because it's hard for you to use it doesn't mean it sucks, please refrain from using language like that to describe love.
It must be inherently difficult to use if newbies keep posting topics about how they don't understand it. You don't see topics of this nature about draw functions or print functions or anything like that nearly as often as the sound issues that keep popping up.
bartbes wrote:@Taehl: Just because it's hard for you to use it doesn't mean it sucks
It's not just hard for /me/ to use, as is evidenced by people making help threads about it almost weekly. Most people expect a sound to play when they love.audio.play it, not to wonder if a guitar could play two sounds at the same time (Which, for the record, makes no sense. Strumming multiple strings at the same time plays multiple notes at the same time, which is known as a "chord" and comprises a major part of music. Even if you pluck the same string twice, the second pluck doesn't get ignored - it starts the sound again (which would be a much better behavior for love.audio.play, failing a more complete solution)).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit! Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.