When I start create my Speaker and feed it data it seems to only play the first buffer. The method that feeds in buffers first checks needbuffers flag and just returns and does nothing if it's false. My setneedbuffers event handler is never called (I set a break point in it) and needbuffers flag never gets set back to true.
If I pause execution and check the state of DynSoundInst it's still set to "playing". DynamicSoundEffectInstance is suposed to stop playback if its starved of data, but that's not the case here.
public class Speaker_XNA : Speaker
bool needbuffers = true;
public Speaker_XNA(short BitsPerSample, short Channels, int SamplesPerSecond)
DynSoundInst = new DynamicSoundEffectInstance(SamplesPerSecond, (AudioChannels)Channels);
bitspersample = BitsPerSample;
DynSoundInst.BufferNeeded += setneedbuffers;
private void setneedbuffers(object sender, EventArgs e)
needbuffers = true;
I'm kind of OCD and irrational numbers really bother me. So how many digits of Pi would you need to calculate a circle the size of the known universe with the accuracy of the Planck length? That way, at least in a physical sense Pi does have a practical end and I can stop worrying about it.
Every thing in my game world is an Entity, Entity is not derived from anything and has no derived classes. What makes a projectile different from a player, different from an enemy, different from an inanimate object, is what that entity has. Each Entity has a list of components that it owns. Some components are graphical, some are physical, some are AI components, some are control components(takes player input), ect.
I'm trying to use inheritance as little as possible and use a data driven approach. Component is the only class currently that has any derived classes, the 4 I mentioned above. Entity types are defined in a txt file, which is as simple as listing a type name, which components that type has, and any raw values those components may need.
I have a EntityBuilder class that I want to work like this. It first reads that txt file and stores 1 of each type. Then when the worldManager needs a new anything, (projectile, enemy, box, ect.) it asks the Entitybuilder for a new Entity of "type x" Then the builder looks through it's list of types and and if it finds one that matches that type name it copies it and passes it to the worldManager. Entity and and each Component implement a copy function, so the EntityBuilder simply calls that copy function on the matching entity(which in turn calls it on each of its components). In this way I hope to be able to design new stuff for my game world without changing any code and just editing a txt file.
I'm not sure if there and actual question in there, maybe just looking for feedback. Also I'm a bit rusty with my design patterns, is this the a factory or prototype pattern?