• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Grain

Members
  • Content count

    721
  • Joined

  • Last visited

Community Reputation

500 Good

About Grain

  • Rank
    Advanced Member
  1. 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 { DynamicSoundEffectInstance DynSoundInst; bool needbuffers = true; short bitspersample; public Speaker_XNA(short BitsPerSample, short Channels, int SamplesPerSecond) { FrameworkDispatcher.Update(); DynSoundInst = new DynamicSoundEffectInstance(SamplesPerSecond, (AudioChannels)Channels); bitspersample = BitsPerSample; DynSoundInst.BufferNeeded += setneedbuffers; } private void setneedbuffers(object sender, EventArgs e) { needbuffers = true; } ... }
  2. I like thing that are evenly spaced, or symmetrical or balanced. Irrational and prime numbers bother me just because you can't make them line up evenly with things.
  3. 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.
  4. I am having trouble with this prime number sieve running out of memory.   It fails at Values.Capacity = n; Previously Values was just an array defined like this : bool[] Values = new bool[n]; but had the same result. I am passing primesieve an int.MaxValue. static int[] Primesieve(int n) { List<bool> Values = new List<bool>(); Values.Capacity = n; int[] primes = new int[(int)Math.Sqrt(n)]; int primecount = 0; Values[0] = true; Values[1] = true; for (int i = 0; i < Math.Sqrt(n); i++) { if (Values[i] == false) { for (int j = i * i; j < Values.Count; j += i) Values[j] = true; primes[primecount] = i; primecount++; } } return primes; } I believed my problem to be that since they are bools, a value type they are being created on the stack so I did this to force heap allocation. but it still fails at the same place.     public class Reference<T> {     public T Ref; } static int[] Primesieve(int n) { List<Reference<bool>> Values = new List<Reference<bool>>(); Values.Capacity = n; int[] primes = new int[(int)Math.Sqrt(n)]; int primecount = 0; Values[0].Ref = true; Values[1].Ref = true; for (int i = 0; i < Math.Sqrt(n); i++) { if (Values[i].Ref == false) { for (int j = i * i; j < Values.Count; j += i) Values[j].Ref = true; primes[primecount] = i; primecount++; } } return primes; } My machine has 16gb of ram running win7 64-bit and i even targeted the build specifically to x64. So I know it cat actually be running out of memory as int.MaxValue Booleans should only take around 2gb assuming .Net is not packing 8 of them into 1 byte,  and if it is then it should only really take up 265mb.   Or am I some how still failing to use the heap?
  5.  Same idea as a linked list. Only this can potentially branch.    Is there some method of keeping track of it automatically?   Move to the first child first, then to any of it's children/neighbors next ect, return to the parent when you reach the end, repeat for the next child until there are no more children, move to the neighbor. public class FileParseElement { string token; FileParseElement Neighbor; List<FileParseElement> Children; List<FileParseElement>.Enumerator CurrentChild; public static FileParseElement BuildFullObjectStructure(ref List<string>.Enumerator ittr){...} public static FileParseElement BuildObjectSet(ref List<string>.Enumerator ittr){...} public string Token { get { return token; } } public FPE_Iterator GetIterator() { return new FPE_Iterator(this) { }; } public class FPE_Iterator //this IS a nested class { FileParseElement Head; Stack<FileParseElement> ParrentStack; public FPE_Iterator(FileParseElement FPE) { ParrentStack = new Stack<FileParseElement>(); Head = FPE; } public FileParseElement Current { get { return Head; } } public bool Movenext() { if (Head.Children != null)                 {                     if (Head.CurrentChild != new List<FileParseElement>.Enumerator()) //compiler doesn't allow this                     {                         ParrentStack.Push(Head);                         Head = Head.Children.GetEnumerator().Current;                         return true;                     }                 }                   if (Head.Neighbor != null  /*&& I have no children or finished tracversing them*/)                 {                     Head = Head.Neighbor;                     return true;                 }                 else { //pop a parent off the stack and assign it to Head return false; } } } } Movenext() is what I'm working on now. It's far from compleet
  6. I have a custom container class that is arranged like a tree. Each element can have up-to 1 neighbor element and any number of children elements, these children are stored in a standard library List<T>.   Each element also has a  List<T>.Enumerator so that when I iterate through this container and come to the end of a branch and then back up it will remember which branch it was last down and go to the next branch next, if it exists.  Now not all all elements have children, in fact most don't, so for those I don't even bother creating a List<T> instance and there for don't have anything to attach the Enumerator to. 
  7. In C# how can I check if a List enumerator is valid before using it? Valid meaning it has been attached to a List already. Since enumerator is a struct it's not comparable to null so that option is out. The .Current property can be null even if the enumerator is valid, for example if MoveNext() has not yet been called for the first time or if the end of the list has been reached, so checking that isn't helpful in all cases either.     I can call MoveNext() in a try/catch block, which would tell me if it's valid or not, but if the the enumerator IS valid I don't wan't to move to the next item just yet. I would wan't to check if the .Current property if not null and then work with that item before calling MoveNext(). And I don't really like catching exceptions as part of preforming basic logic anyway, they should be only for error handling. 
  8. How about this then?          public static Vector2 Project(this Vector2 A, Vector2 B)         {             float DotOverDot = Vector2.Dot(A, B) / Vector2.Dot(A, A);             if (float.IsNaN(DotOverDot) || float.IsInfinity(DotOverDot))                 return Vector2.Zero;             else                 return Vector2.Multiply(A, DotOverDot);                         }
  9.   What you are trying to do here is figure out how much of B is pointing in the A direction. This assumes that A is a direction vector. A direction vector is usually required to have a length of 1. Any vector that can be normalized can be a direction vector. However, a zero-length vector cannot be normalized and thus has no direction. If A was correctly normalized your project function simply return Vector2.Dot(A,B). If you should not be projecting zero-length vectors, it seems that there is a problem upstream of this function. Personally, I would get rid of this function and make sure that my direction vector was normalized and use the dot product directly.   -Josh   Normalizing requires a square root call which I'd like to avoid as much as possible, and seeing as I can project just fine while avoiding that I see no benefit in doing so. Also zero vectors are perfectly valid in some cases(a velocity vector for example).  
  10. Also I'm projecting B onto A, as where this example projects A onto B.
  11. I'm not sure what you mean considering the result should be the same for all lengths of A with the sole exception 0.  
  12. Currently I'm doing this  public static Vector2 Project(this Vector2 A, Vector2 B) { if (A.X != 0f || A.Y != 0) return Vector2.Multiply(A, Vector2.Dot(A, B) / Vector2.Dot(A, A)); else return A; //return B; ??? } Without the zero length check in there every thing blows up because this method returns an effectively infinite length vector.  What is the best thing to return when the length of A is zero?
  13. Either you haven't explicitly defined lifetimes, or you haven't explicitly defined ownership (which goes back to my earlier point, that "shared" is not a valid definition of ownership).   If both are explicitly defined, then there cannot be any other code that refers to dead resources.       And my point is that you should be doing this implementation in C++, too. Skating by with shared ownership semantics only takes you so far.   Ok. Object 1 owns object 2. This is explicit. Object 3 has a reference to object 2 because it needs to work with some data it has. Object 1 dies, so it kills object 2 as well.  This is also explicit.    Now, we still need to inform object 3 that it's reference to object 2 is no longer valid.