• Advertisement

Stroppy Katamari

  • Content count

  • Joined

  • Last visited

Everything posted by Stroppy Katamari

  1. fmod with unity, anyone use yet?

    Hi guys! My amateur team is trying to use the official Fmod Unity plugin to carry out the most basic of basics, but I have no Fmod knowledge, our sound artist who knows Fmod hasn't used Unity, and there's no official documentation yet.   What we have done is to place a FMOD_Listener at camera, and then from our game logic, grab the StudioSystem instance and do fmod.PlayOneShot(). This works for individual sounds. We also get background music by having a Studio Event Emitter at the same camera as the listener that starts playing on awake. But if I do something as simple as placing that same event emitter with the same asset on the player character instead, no sound comes out. I don't know how to stop and switch between sounds (e.g. for the background music). Ideally we'd like to be able to fade between different musics. Any pointers how we should do this? Either the "right way" or a "quick and dirty" way would be fine.
  2. Getting a solid grip on C++ : Where to go next?

      I feel like that difference shrinks as the caliber of the programmer goes up. Will a really good C++ and C# programmer be appreciably faster when working in C#? Not sure. C++11/14 with extensive use of standard libraries (and good 3rd party libraries) can be very expressive, and also pretty safe if you choose to use a safe coding style (which may or may not come at a performance cost). Certainly it's faster to write some things in C++ compared to e.g. Java, even for a klutz like me.   At the low end of skills the difference is the most striking. I think it's accurate to say that a poor C++ programmer will generate negative value to a project. With C++, either plan to get pretty good, or spend your time more constructively with another language.
  3. Version Control and programming with a team

    Fundamentally I'm very much on the side of putting everything in (the same) version control, and being able to reliably produce a working game by just pulling from repo and building. Part of my problem is that Unity3D seems to require or strongly encourage mixing code and data. I'm not sure if it's feasible to really clean it up, and to what degree. If only our game code and data were properly separate, and we were able to handle missing assets sensibly on the code side, life would become a lot easier. Then we could use git, hg or whatever for the code, any other solution for the data/assets (something that is easy for the artists), and the project would still be trivial to build and work on. Specific asset sets could be designated as "official" once in a while, and the build script in the code VCS would fetch the official asset set at the time of that code version.
  4. How Languages Compare?

    This example has nothing to do with your (faulty) assertion that languages do not matter. You'd be far more productive when writing your code generator in Lua than when writing it in assembler. That's because in comparison to assembler, Lua has many more features that help you get the job done. It boggles my mind that you'd even try to claim otherwise. Seriously weird strawman argument. If you have 100% perfect, 100% efficient C code that never needs to be changed again, then sure, you don't want to go in and change it for any reason. But I didn't tell anyone to do that. Rather, I'm saying there are benefits from writing the code in C++ in the first place, even if the code is not object oriented, and even if it mostly looks like C.
  5. How Languages Compare?

    I hate to nit-pick (ok, I actually love to, it seems very effective in terms of learning), but isn't it a bit misleading to refer to genetic algorithms and lambdas as being C++ techniques? Correct me if I misunderstood what you were saying but the statement seems to associate those techniques with C++, while I am pretty sure the two I mentioned existed before it did. I could not say about the others, as I am less familiar with them, and I am not very familiar with those two in the first place. They aren't C++ inventions, but I wasn't calling them as such. According to the topic of the thread, I was comparing C++ to C. C++ has language support for the things mentioned, while C does not. Also, it's "generic algorithms", not "genetic algorithms".
  6. How Languages Compare?

    Almost any piece of high level C code can be improved by applying C++ techniques. References, generic algorithms, lambdas, constexpr, smart pointers, move semantics etc. are all really nice. You don't need to write object oriented code to benefit from C++. Just the fact that C++ has a good assortment of standard containers is a huge leg up on C. If you are working in C, you'll be using containers from some 3rd party library, or have rolled your own from scratch with great time expenditure and possible quality issues, or you are effectively hamstrung by lack of appropriate tools.
  7. Version Control and programming with a team

    Also, Github has student accounts. They allow you to make up to 5 private repos. You just need to mail Github to apply. I also currently have the dilemma of what forms of version control to use. Complicating the matter: - The project only runs a couple more weeks. No time to spend on infrastructure. - Most of the team are not programmers. I'm the only one with some experience of using git/hg/svn etc., and then only with text data, not binary blobs. - Due to the skillset and time factors, I can't ask others to learn much VCS. - We use Unity3D, and projects in it do not play well with version control. - At the end we'll have quite a bit of assets. We went ahead and used git + GitHub for now, but it's so awful in these circumstances, I'm still wondering if we should just forget the repo and just dump the whole thing in Dropbox. Or what other VCS we should be using instead. I'll have another short project after this, so I really want to figure out a solution even if I don't have time to apply it for the current project. When it is easy to separate the assets from the code, and only programmers need to touch the VCS, git and hg are great. I'd recommend Hg for newbies, Git has a very long learning curve.
  8. The simplest thing you can do to make the camera lead the character is to maintain a camera offset that ticks towards 0 over time (so the camera will center on the character when not moving), is increased quickly whenever the character is running to the right, and is capped to some maximum offset value.   The general method to smooth any camera is to attach it to the point of focus with a damped spring. In this case, the point of focus is the offset position.
  9. C++ Garbage Data

    That's worse than what he's doing. A m_ prefix on everything messes up IDE/editor autocomplete features, whereas the _m postfix does not disturb the autocomplete, and will get autocompleted 95% of the time so you don't even have to type it out. There's no one right way, but I have opted to use the Google style where class members are marked with a single postfix underscore (particles_). This doesn't hurt the readability, but still clearly distinguishes members from non-members. On simple classes with public data members, I omit the underscore so it's just Position p; p.x = 123;. The correct choice in C++11 is nullptr, in C++98 0.
  10. game programming language capabilites

      dsl's:  distributed systems logic? as in distributed systems programming? Domain specific languages. To solve a set of problems, you use the high-level features of the host language to write a mini-language specifically for that kind of problem, and then use the mini-language to solve the problems. The DSL may be embedded (still valid code in the host language, but may look extremely different than typical host language code); this means you don't need a separate parser, compiler, or interface between two separate languages. The Lisp language family is famous for being used in that way. Among more recent languages, Scala has been specifically designed to be very good at DSLs. The characteristics needed from the host language are raw (expressive) power and flexible syntax. Alternatively, the DSL can be an entirely separate language in which case you write an interpreter or compiler. The same languages that are good hosts for embedded DSLs also tend to be very good for writing these tools. See here: http://www.stanford.edu/class/cs442/ http://www.scala-lang.org/old/node/1403
  11. game programming language capabilites

    A short personal wishlist of mine would include stuff like: Functional purity as default, enforced by compiler Mutation-using code allowed inside pure functions as long as it only operates on local data (and so does not cause an actual loss of purity) Can annotate an individual pure function call at call site to enforce the arguments must be const and the whole thing must therefore be eliminated at compile time Strong typing, strong type inference so you rarely have to spell out the types Deep/transitive const Generic code written with the same syntax as other code Generic containers and algorithms connected with ranges, iterators Designed to allow fast and automatic incremental compilation and re-linking on the fly while in development mode, without having to add any crud in the code to make it happen The D language already manages quite a bit of those, and also allows getting close to hardware so you don't need a separate language for that. Tim Sweeney's old opinion touches on many of the same things: http://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf
  12. Critique my code please

    It makes no sense for an abstract game object like the Ball class to be aware of characteristics of the program window. If you like, it could have functions that return the edge coordinates of the ball, which can then be compared to window coordinates elsewhere.
  13. I'm not convinced that your ships and planets are actually so related that you should try to use them polymorphically. Polymorphism is about using operations interchangeably on related objects, without having to care which actual type it is. No matter what you do, you should not have casts all over the place in your code; having to cast is a sign you are probably doing something poorly. If you get a ton of new object types, and need the grid to be able to point to them, I can see how it makes sense for them to have a common base class for that purpose. But in that case, it would be cleanest to keep the base class totally empty. I'd keep the Object pointers strictly inside the grid data structure, give the grid getter functions which return a specific type, and do no casting whatsoever outside those functions.
  14. sorting std::vector instead of array

    I'll refrain from commenting on the fundental design issues, and just point out that this kind of drilling down is atrocious to read. It will eventually lead to bugs and silly code, if it hasn't already. mEffect[fx].meshesPerMatBlended[mat].instance[m].blendedMeshIndexTemp[mEffect[fx].meshesPerMatBlended[mat].instance[m].blendedMeshOrderTemp[mi]]Using iterators rather than indices would prevent this. But if you use indices, at least use local references to clean it up: auto& inst = mEffect[fx].meshesPerMatBlended[mat].instance[m]; inst.blendedMeshIndexTemp[inst.blendedMeshOrderTemp[mi]];
  15. Almost, but not quite. The thing we're interested in is how long a particular pixel has not contained any bullets or enemies. You can do that in several slightly different ways. The way I suggested was to increment every pixel on every frame, and when drawing enemies and bullets, setting those pixels in the array to zero. You should be able to see the data in real time. Having to pause is not effective or convenient. You could indeed use a side-by-side view, where the heatmap is visible beside the normal game view, but think I would rather draw a transparent heatmap on top of the normal view, so it's easy to identify exactly which areas are problematic.
  16.  I'm using... uh, Visual Studio 2010. My stuff's kind of outdated because I haven't touched programming for a long time (a stint in the military, you see). Are C++11 features available in it? "auto" and an early version of lambdas are available, but most C++11 features are not. VS2012 adds the very useful range-for loop, but many useful features are still missing. If I were you, I'd probably switch straight into VS2013 preview version. VS2012 at least.
  17. What library to choose to write games in C + +

    Seconded. I have used a tiny bit of SFML, and it is quite easy to get started with, stick some sprites on the screen and so on. Follow some tutorial to get over the initial hurdle of getting some app to compile, and you are set. I'm planning to use SDL2 for a learning project precisely because it has less structure and hand-holding than SFML, and I would like to build my stuff from the ground up for once.
  18. Duplicated Code

    That makes no sense. The fact the booleans are mutually exclusive is exactly why they should be removed. They are breaking the DRY principle ("do not repeat yourself") because they represent the same data. Whenever xyzForm == true, the others must be false, but keeping booleans means you have to spell that out every time and it's possible to make a mistake. Whenever you have a small, fixed set of possible states for something, and exactly one of them is active at any one time, that's pretty much what enums are for. To encapsulate the possible transitions, I'd write "rotateLeft", "rotateRight" etc. functions inside the enum. For an example, see: http://stackoverflow.com/a/2647709 If you need a 0..3 integer representation for something like indexing into an array, you can always get that out of the enum with .ordinal(). (You'll see people claiming that you shouldn't rely on enum ordinals, but the reasons have to do with situations where more enum values might be added in the middle of the list; that's not an issue in this case since no more unique rotations exist.) Keeping a raw integer between 0..3, like in fastcall22's example, would also work. But also for that I would definitely write separate manipulation functions that make sure the value stays in the right range, instead of sprinkling that logic inside UI code.
  19. 2D Map - Data Structure (Not really Java specific)

    Changing data structures in unoptimized code should be easy. If it's not, that's a warning sign about code quality. Keep things simple, generic and decoupled until you have real reason to do otherwise. (One more reason to not do premature optimization: it makes it harder to later do optimization you actually need.)
  20. Graph wars

    I'm not personally fond of Java, but it would make sense for this job. You have already used it, it's multiplatform, and standard Java libraries are enough for any drawing you need. Basic drawing is this easy: http://www.zetcode.com/gfx/java2d/basicdrawing/ A quick google for "Java graphing", "Java calculator" etc. brings up a ton of Java apps like this one which also have source code available, so you can see how they did things. http://sourceforge.net/projects/funcplotter/
  21. 2D Map - Data Structure (Not really Java specific)

    It doesn't work like that. You can't sort a single array simultaneously by several dimensions of a continuous space. If you use my suggestion and just depth sort the array direction, you only have to brute force search objects with similar depth. Let's say you want to find objects within radius 1.2 from coordinates [5.5 2.1]. This gives us depth limits of 2.1 - 1.2 = 0.9 and 2.1 + 1.2 = 3.3. Then you binary search the array for the indices at 0.9 and 3.3 depth, which is practically free. Finally you brute force search only between those indices. If your map is 50x50 and objects are distributed evenly in the depth direction, only about 5% of them have to be searched in this case. Most of those 5% will be inspected very cheaply because their horizontal distance falls outside the radius. You haven't even defined a problem, other than the overlap one which was trivially solved by depth sort. It's pointless to talk about acceleration data structures, much less implement bad ones, before you have defined what operations you need them to accelerate. For instance, how many objects will there be at most, and is anything known about how they will be distributed spatially? How many "adjacent objects" queries will be made per tick at most? How many other objects will fall under the average radius of such a query? There is no universal data structure that is good for everything. If you just want to dig into the technology that exists for this purpose, read about BSP trees, quadtrees or other serious acceleration structures and implement one of them.
  22. 2D Map - Data Structure (Not really Java specific)

    You certainly could use methods 1 or 3 to solve the overlap problem, so they would "work", but there's little reason to use them because the alternatives are so much better. Method 1 is especially pointless. Even though method 3 doesn't make sense for just solving the overlap problem, you might still want to use it because it also helps with game logic, such as making it fast to find all objects in the vicinity of a given object. Depth testing with the graphics card involves zero work on your part and is essentially free performance-wise, so it is faster than any approach based on manually arranging the draw order. If that's not a possibility, then solving the overlap problem is always fundamentally a back-to-front sorting problem. The method I suggested - just sorting everything every frame - is dead simple and works for reasonable amounts of objects. If it's not fast enough, the only option is to optimize the sort. Method 3 is actually a spatial partitioning scheme, which is one way the sort may be optimized, but it's pretty crude and probably slower than the simple sort for reasonable amounts of objects. Any serious optimization effort should begin with estimating the quantities involved: how many objects may be on screen at a time, how many of them may overlap, how fast they may move, at what rates they may be created or destroyed.
  23. 2D Map - Data Structure (Not really Java specific)

    You can forget about methods 1 and 3. The overlap issue in method 2 wouldn't be an issue if you used the graphics card to draw your stuff, since you could just turn on depth testing which works automatically at the pixel level. Assuming that's not an option, the next simplest thing to fix method 2 is to sort all your objects to depth order before drawing. Then you can just draw all of them in order, pausing at tile coordinate lines to draw a row of tiles. If you run the sort before drawing every frame, moving objects do not need any special handling. Performance required by this approach shouldn't be a problem at least up to thousands of objects, but likely a lot more than that.
  24. The heatmap implementation I was thinking about is very simple. You just need to keep an extra framebuffer, the same size as the screen, which stores one number per pixel and starts zeroed out. On every frame you increment all the pixels by one. Then, whenever you draw enemies, hostile bullets or obstacles, you also draw them in the extra buffer with all zeroes. The higher the value is on the map, the longer that position has been safe. It's then trivial to draw different visualizations of that heatmap, for instance to show as transparent red any area that has been a safe spot for longer than five seconds.
  • Advertisement