Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 02:37:25 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 232 233 [234] 235 236 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 733431 times)
pwg
Level 0
*



View Profile
« Reply #4660 on: November 06, 2014, 07:16:28 AM »

I want to mention that '.wav' files are composed of different chunks. Some audio-editing programs like Wavelab also save a lot of metadata chunks (loop-points, sampler-chunk, playlist) in the file. If you dont need the specific data you could strip down the file to RAW PCM sample data. PCM chunks store the audio samples in different ways. The samplerate, sampleformat and bits per sample affect the size of your file. For example:

1 Second at 44100Hz, 32-bit float, Stereo = 44100samples * 4byte * 2stereo = ~344kb
1 Second at 22050Hz, 16-bit, Mono = 22050samples * 2byte * 1stereo = ~43kb

So if you use sound files with a lot of low-frequency content, you dont need a very high samplerate and stereo doesn't matter, because we don't here low frequencies under ~200Hz in stereo. Additionally you could zip files to reduce the size by ~60-70%.

So my advice is:
44kHz, short, Stereo for normal short (<= 5 seconds) sounds.
22kHz, short, Mono for low-frequency sounds.
OGG with high bitrate for rich-frequency music (very compressed in the way of RMS-level).
OGG with low bitrate (equivalent to 128kbs mp3) for longer athmosperic low-frequency music.
Logged
oahda
Level 10
*****



View Profile
« Reply #4661 on: November 12, 2014, 06:06:39 AM »

Managed to connect the Ouya controller (yes, I have one) to my PC (running OS X). Didn't work properly at first, acting like a mouse and moving the cursor to the top-left corner of the screen. Found a driver somebody had written, and it stopped doing this and my SDL 2.0 game correctly identified it as a controller. However, it gives off completely different axis values than the flawlessly working PS3 controllers and actually doesn't give off zero values when the stick is at rest and not being pushed.

Don't know if it's the driver or the controller. Do I have to assume all different joysticks work differently? That's kind of a problem. I hope it's just the crappy Ouya controller. We'll have to see in a few days. I've ordered one of those receivers to connect a wireless Xbox 360 controller to a computer, supposedly the best supported gamepad on Mac according to my research. Fingers crossed.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #4662 on: November 12, 2014, 08:46:43 AM »

Don't know if it's the driver or the controller. Do I have to assume all different joysticks work differently? That's kind of a problem.

Perfect summary right here of what it's like to work with gamepads. They're a mess.

What sort of values are the sticks reporting? Is it kinda close to what you'd expect, or way off?
Logged

Sik
Level 10
*****


View Profile WWW
« Reply #4663 on: November 12, 2014, 09:34:29 AM »

If it's off zero but still close to zero it's normal, nearly all controllers do that actually (except those that explicitly filter out those values), that's the reason why games have dead zones. The worse the quality of the sticks, the more off the center it'll be, and I recall Ouya controllers being... kind of special (although I guess you have one of the later models if you're getting only slightly off-zero values)
Logged
oahda
Level 10
*****



View Profile
« Reply #4664 on: November 17, 2014, 04:41:10 AM »

Don't know if it's the driver or the controller. Do I have to assume all different joysticks work differently? That's kind of a problem.

Perfect summary right here of what it's like to work with gamepads. They're a mess.

What sort of values are the sticks reporting? Is it kinda close to what you'd expect, or way off?
They're within the correct range that SDL reports for the PS3 controller as well, but while the PS3 controller reports x and y for the primary stick as axes 1 and 2 respectively and 3 and 4 for the secondary stick, not even these axes seem to correspond to the same sticks or directions as on the PS3 controller. They're also not all at 0 when the sticks are at rest. I believe it detected 9 or so axes for the controller, so I suppose it's another pair for each stick that I need to read, but how to know which ones if it's not universal? Find the information online and hard-code depending on the name reported by the device?

Still haven't gotten that receiver, so I don't know what values the 360 controller reports yet.
Logged

Sik
Level 10
*****


View Profile WWW
« Reply #4665 on: November 17, 2014, 05:31:28 AM »

SDL2 comes with a database of mappings for controllers (and if running a game from Steam that database will get updated beyond what was available when the game was built), but honestly I doubt the controller you have is in that database... (you can try figuring out the mappings and then adding the controller to the database, though) Every PS controller knock-off I've seen does map the left stick to axes 0 and 1 though, so it definitely isn't the clone "standard" either (which is more or less the same for all clone controllers).

Also have fun with the 360 controller. You have to use the mappings SDL2 gives you with those, because they aren't intuitive (hint: buttons 0 to 3 are not ABXY, but the D-pad, just to give you an example).
Logged
oahda
Level 10
*****



View Profile
« Reply #4666 on: November 17, 2014, 05:53:34 AM »

SDL2 comes with a database of mappings for controllers (and if running a game from Steam that database will get updated beyond what was available when the game was built), but honestly I doubt the controller you have is in that database... (you can try figuring out the mappings and then adding the controller to the database, though) Every PS controller knock-off I've seen does map the left stick to axes 0 and 1 though, so it definitely isn't the clone "standard" either (which is more or less the same for all clone controllers).
Oh, that's neat. But yeah, maybe I can set a hint for the controller like in the example I initially followed to make the Ouya controller play nice.

Also have fun with the 360 controller. You have to use the mappings SDL2 gives you with those, because they aren't intuitive (hint: buttons 0 to 3 are not ABXY, but the D-pad, just to give you an example).
Well, I was going to try out every button manually and make a custom system anyway, creating an enum with stuff like B_CONFIRM (X on PS3, A on Xbox) and B_CANCEL (O on PS3, B on Xbox), B_LEFT and so on, hard-coded to the specific button ID's on each controller type, in order to have a portable system with the mappings that people are used too. Plus I'm going to allow for custom remapping in the game's settings in worst case scenarios anyway.
Logged

Sik
Level 10
*****


View Profile WWW
« Reply #4667 on: November 17, 2014, 12:47:46 PM »

Probably using the database is the easiest way since it already implements all of that for you, and you can add joysticks to that database if needed as long as you know its GUID (which can also be easily retrieved with SDL2).

Allowing remapping is still a good idea anyway since some people would prefer (or even need) different mappings.
Logged
oahda
Level 10
*****



View Profile
« Reply #4668 on: November 18, 2014, 02:47:54 AM »

Oh. So how do I access the database, then? I got my wireless receiver for my non-wired Xbox 360 controller yesterday and plugged it in and it does not seem to correspond exactly to the PS3 controller, like ThemsAllTook said. So do I need to apply it manually by calling some function, or do I need to use different functions to access the values this way?

The 360 controller does report 6 axes just like the PS3 controller, and the first two do correspond to the primary stick in the same way, so that my normal movement in my game works fine with this controller too. However, the latter two axes do not correspond to the secondary stick and do not both seem to be zeroed either, making my submarine strife to the left (which is done with the secondary stick using the PS3 controller) when the sticks are at rest, and it seems the left shoulder button controls the vertical strifing (downwards), meaning that the axis indices above 1 (starting from 0) are not mapped like on the PS3 controller at the moment.

Also, wanting to test rumble using the 360 controller, I used SDL_HapticRumbleSupported() and got a positive response, but SDL_HapticRumbleInit() failed. Giving up on this, I decided just to implement rumble myself using the more complex haptic effect interface.

While researching this, I found out that this is actually how SDL itself does the simpler rumble interface underlyingly. It queries the controller for sine wave or left-right effect support and uses either of those to set up a basic rumble effect. Which is exactly what I had done, getting the sine effect to work nicely – however only if I ignored the support check, because the number I get from SDL_HapticQuery() seems to be incorrect, indicating a lack of sine wave effect support in the 360 controller, but it does work if I just try it anyway.

So that's why SDL's rumble interface won't work, as it performs this query, getting the response that sine is not supported, and aborting the rest of its implementation. My solution works, and nothing happens if I try to use an unsupported effect, or try to call the same code on the PS3 controller, which does not support it, so it's all fine. I can stick to this implementation. But it's weird.

Also I get weird crashes if I try to destroy certain SDL things or if I try to quit the haptics subsystem at the end of the program even tho I've obviously been able to initialise it properly (I've even queried it with a positive response just to be sure even tho the controller is obviously vibrating), so I've just commented out all of that ATM. That feels bad. I need to figure that out. Geeeeeez.
Logged

Sik
Level 10
*****


View Profile WWW
« Reply #4669 on: November 18, 2014, 03:54:50 AM »

Oh. So how do I access the database, then? I got my wireless receiver for my non-wired Xbox 360 controller yesterday and plugged it in and it does not seem to correspond exactly to the PS3 controller, like ThemsAllTook said. So do I need to apply it manually by calling some function, or do I need to use different functions to access the values this way?

Look up the GameController API (not the same thing as the Joystick API, beware). That's the one that handles the controller mapping database, you can even make it send events of the mapped buttons to you if you want. You'll still want to handle gracefully joysticks that don't have mappings though (in those cases it's better to let the player remap controls as needed).

As for everything else, maybe you'll want to take a look at the SDL mailing list, even if just to get Sam or Ryan look into the issue. Honestly I sorta skimmed the post since it's too long but it does seem like you're having some rather complex issues there (and maybe you can get the rumble implementation fixed as a bonus =P).
Logged
oahda
Level 10
*****



View Profile
« Reply #4670 on: November 18, 2014, 04:09:28 AM »

Aaah, right. I remember thinking it weird that there should be a separate game controller struct at all, when I was apparently doing everything using the joystick structure anyway. That makes sense. I'll look into it during my next session. Thanks!

And yeah, perhaps I should describe this to one of the authors.

EDIT:
Back home, and changed my function to use SDL_GameControllerGetAxis() instead of SDL_JoystickGetAxis() in case of a gamepad rather than just a joystick, using the proper enum values. It's now working nicely for the 360 controller too.

The Ouya controller, however, I see now, apparently does get detected as just a joystick rather than a gamepad. Maybe there's some other driver. But at least it isn't SDL's fault, then. And kind of expected.
« Last Edit: November 18, 2014, 11:05:19 AM by Prinsessa » Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #4671 on: November 20, 2014, 01:19:30 PM »

This is more of a social grump than a technical one, but I need a place to vent...

I spend a lot of time in an IRC channel with game developer friends from a community I used to be a part of. It's great for getting feedback on stuff I'm doing and brainstorming about things, but a growing frustration I've had is when people will get too invested in what I'm doing and how I'm doing it. I frequently talk through problems I face during game development and how I go about solving them, and often my friends will have some great suggestions for how to do things better.

However, sometimes they start acting like it's their place to micromanage my time and how I approach things. If I've picked a solution to a problem that they see as inefficient, they'll start hounding me about it and acting like I'm a moron for not doing my work exactly as they think I should be doing it. If something similar comes up later, they'll have a selective lapse in memory and act like I'm nuts for doing things a certain way, even though we've already discussed it before and I have solid reasons for what I'm doing. It's insulting, patronizing, and infuriating, and I don't know how to put a stop to it other than to avoid talking about what I'm doing. If I did that, I'd lose all of the positive interactions that come from sharing with the channel.

Some of this is certainly my problem. I can work on not getting so angry when it happens or ignoring people trying to push my buttons, but that does nothing to solve the underlying issue. I want to stay friends with these people, but some of them are making it monumentally difficult.
Logged

oahda
Level 10
*****



View Profile
« Reply #4672 on: November 20, 2014, 11:12:57 PM »

Do it my way and turn off IRC and Skype, log out of Facebook and uninstall the Facebook apps from your phone. Life quality has improved greatly.
Logged

Boreal
Level 6
*


Reinventing the wheel


View Profile
« Reply #4673 on: November 23, 2014, 08:31:17 AM »

OpenGL thinks it's funny right now to make my uniform block (containing two 4x4 matrices) 3MB long, and to mess with the sacred std140 layout beyond comprehension.
Logged

"In software, the only numbers of significance are 0, 1, and N." - Josh Barczak

magma - Reconstructed Mantle API
Dacke
Level 10
*****



View Profile
« Reply #4674 on: November 26, 2014, 07:19:32 AM »

This is more of a social grump than a technical one, but I need a place to vent...

Maybe tell them that you feel this way? Just not in an angry way in the middle of an argument.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Garthy
Level 9
****


Quack, verily


View Profile WWW
« Reply #4675 on: November 28, 2014, 07:23:41 PM »

However, sometimes they start acting like it's their place to micromanage my time and how I approach things.

I've found that the best way to handle that sort of thing is to be grateful to those that try to help you, consider the advice that you are given, and make it clear that you do this. On the other hand, also make it clear that ultimately the path you take is the one of your choosing. Be very firm about this. Be grateful, but assertive on this point.

I hope this helps.
Logged
indie11
Level 2
**


View Profile
« Reply #4676 on: December 04, 2014, 10:58:21 AM »

I've been trying different Path Finding Plugins from the Unity Asset Store (free) to prototype a puzzle game but they just don't fit perfect for my design.

I want some suggestion from people who have worked on path finding. Here are some details:

A Node can be connected to at max 4 other nodes.
A Boolean (isWalkable) to check if this Node can be added in the path list.

Pretty simple eh!? So which Algorithm should I go with? A* or Dijkstra, keeping in mind that the Node isWalkable state is changeable at Runtime.
Logged

d
Level 0
***


View Profile
« Reply #4677 on: December 06, 2014, 07:36:36 PM »

This is an actual line of code I just wrote.

Code:
r.attributify(attributes.attributes);

Please forgive me.
Logged
Sik
Level 10
*****


View Profile WWW
« Reply #4678 on: December 07, 2014, 02:11:27 PM »

I'm more amused at attributify than at the repetition.
Logged
Dacke
Level 10
*****



View Profile
« Reply #4679 on: December 08, 2014, 12:56:43 AM »

Pretty simple eh!? So which Algorithm should I go with? A* or Dijkstra, keeping in mind that the Node isWalkable state is changeable at Runtime.

It doesn't really matter. They will both give you exactly the same result (i.e. the optimal path). The only difference is:
  • Dijkstra's is easier to understand and implement
  • A* runs much faster (requires less computing power)

If you don't need the optimal path, you can make A* run faster by modifying a constant in the heuristic.

     
Dijkstra's
     
A*
   
A* (suboptimal path)

For grids you can also use jps, which is even faster:
http://forums.tigsource.com/index.php?topic=34071.msg901817#msg901817
« Last Edit: December 08, 2014, 04:29:57 AM by Dacke » Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Pages: 1 ... 232 233 [234] 235 236 ... 295
Print
Jump to:  

Theme orange-lt created by panic