• Content count

  • Joined

  • Last visited

Community Reputation

191 Neutral

About zalzane

  • Rank
  1. I know you've put a lot of thought into your way of avoiding globals, but your editor example is a good example for passing references. At first many may think, I have this model editor and it can only do one model at a time. I've made a model editor and made the same assumption. Sure if that's true, just use a global or singleton rather than a more complex organization just to avoid using globals. But really, will an editor only store ONE model? Maybe this editor allows you to load a character model, but it can also load attachments like weapons. The editor can manipulate the character and the attachments. It seemed like only one model was needed, but after adding more functionality, now you need more than one. So when you open a dialog or tool in the editor, the dialog or tool will need to be passed a reference of what it will manipulate. I'll admit my example really wasn't that great, but inheritance based global access isn't around to replace something like a class full of references.   An infinitely better example would be an static-inheritance class giving access to something like the graphics device. On one of my older projects, the "sprite" class is typically accessed very far down the call stack. From the entrypoint of the program, you have to go through a few layers of gamestate logic, then UI logic, then all the way at the bottom is the sprite class. The sprite class needs access the graphics device, or whatever class is handling the graphics device. Instead of passing down a reference to the graphics device down a dozen layers of call stack, the Sprite class would inherit from a static class that contains the graphics device.   This way, access to the graphics device has to be explicitly defined through the use of inheritance, and any usage of the graphics device can be found by just looking at all the child classes that inherit from it. In addition, it's one less piece of trash floating around the global namespace.   I'll admit it's hacky as hell, but I'd rather have an ugly hack than restructure 10k lines of UI logic.
  2. One of the clever, but more contraversial alternatives I've found for sharing data between classes is to use inheritance/static fields. Let's say you're programming a 3D editor of some sort, and a list of vertexes in your model has to be shared between many classes. The options in this thread include simply passing the list as a parameter, setting up a singleton, or setting up a container class that gets passed at runtime.   With my inheritance method, you set up an abstract class that contains protected static fields for shared information - such as the list of vertexes that has to be shared. Any class that needs access to those vertexes would inherit the abstract class.   This can be extended into a tree of inheritance to allow different child classes to have different read/write permissions on the abstract class' fields, but I would restrain myself from doing this too much at risk of ending up with 3-4 depth inheritance trees.   The most significant issue with this model is that without the proper visualization tools, maintaining code that runs under this system can be very complicated, especially if you have poor docs.  In addition, if someone else was to read your code without knowing what you're doing - it's likely they would get very confused very fast. If you use this system extensively, I suggest writing an addon/macro for your development environment that lets you inspect what kind of inherited fields each class has without actually opening up the abstract class.
  3. Triangle strips are a major pain in the ass, especially when you're programatically generating geometry. Don't use them.   Depending on how you generate the terrain, it may be faster to just generate it each time the game loads rather than loading it from a file. I have a demo that uses opencl to generate terrain, and it can generate terrain an order of magnitude faster than it would take to load said terrain from disk.   For figuring out which triangle the mouse is mousing over, check this out.   You can basically copypaste their code for it.
  4. You could construct a linked list to represent the planet's mesh.     enum Direction{ Above, Below, Left, Right }; struct Vertex{ float phi; float theta; float r;  float cost; Vertex *neighbors; };   Using this method, the only real effort required is in the initial assembly of the linked list. For pathfinding you would just iterate through the linked list like you would for a normal array.
  5. Your Worst "Gotchas" ever in programming

    pretty much anything i've done involving c++ has been riddled with gotchyas, I hope I never have to use that language again
  6. Here's a short list of features that C# has that java doesn't. To be quite frank, C# was really designed to be a 'better' Java, and has succeded in many aspects. - Value types vs. reference types - Named and optional arguments - Built-in events - Lambda expressions - Value types allowed as generic parameters; generic constraints - Co/contravariance - Delegates - Methods are not overridable by default - Better interop support with unmanaged code - Pointers - Properties (getters/setters) - Operator overloading - 'async' methods - More flexible exception throwing* - Ability to allocate memory not managed by the GC - Standard IO library that is not complicated and overly verbose ================================================================================ * adding 'throws' to a method in Java requires snowballing changes to all methods that make use of that method, which requires changes to those methods, etc... Also, Java being more portable than C# is partially incorrect. Through Mono, you can compile C# code for a huge variety of platforms including Linux, Mac, PS3, and loads more I can't remember. The only problem with C# is that we'll never know if it ends up being a microsoft patent trap.
  7. Progamming for beginners

    [quote name='greenthingsjump' timestamp='1349612353' post='4987657'] Thanks! Im new and know I want to get into game programming. I have no Idea where to start. Everyone says C++ Is the way to go... for games. I would was thinking of doing 2d games for now just to get a good understanding of how to develop them. Then later move on to something more advanced. I will be reading in depth on python and lua now. Thanks! [/quote] C++ is the industry standard for games so a lot of people suggest it, but it's a horrible starting point for a beginner looking to make their own games. I back the python recommendation.
  8. Slowdowns / 'Anti-Hotspot'

    Quadtrees tend to be very computationally expensive, and even worse - tend to do lots of heap allocations in loops. I couldn't tell you without looking at your code, but it may be possible that the problem is the garbage collector. If you wanted to stay using c#, you may be able call the GC class and have it clean up after every node is created. It's unusual that the garbage collector would block you that badly unless you were doing LOTS of heap allocations that keep the variables alive for periods of time where the garbage collector can't figure out if it should treat the variables as a short-lifespan object or a long-lifespan object. I suggest you read this article and become more acquainted with the GC.
  9. Everyone in this thread is a naysayer. The first thing you do to create a game engine is to program several games. Take note what kinds of tools and algorithms you reuse in each game, and build a framework off those algorithms. Needless to say, once you've programmed several games, you won't actually be a beginner anymore.
  10. Some newbies (like me) do love to code in C++

    The only people I've ever met who consider C++ to be an adequate solution for creating videogames are people who have never programmed in a language that wasn't C++. The only reason it's still around is because it's what everybody uses, so if you're hiring C++ programmers for a game, you have a lot more choice than if you're hiring haskell or C# programmers.
  11. Is c++ better?

    [quote name='xhh' timestamp='1348224219' post='4982312'] XNA/C#? I've heard bad things about it. I've also heard it's slowly dying. [img][/img] I also like distributing games as single-file executables or at least very few files. With XNA you have to distribute the XNA Framework. [/quote] You probably heard that from some other thread in the beginner's forum. I would take it with a grain of salt, this isn't necessarily a good place for the kind of business analysis involved in determining whether or not microsoft is going to drop XNA. However, it's extremely unlikely microsoft plans on dropping C# any time soon. They invested far too much money and resources to drop it and go back to C++. Assuming I'm wrong and microsoft drops XNA -and- C#, it would ultimately be irrelevant because of mono and monogame.
  12. Is XNA dying and MS forcing to C++?

    Whether or not microsoft condones C#/XNA is irrelevant in the long run thanks to mono/monogame.
  13. how to unlearn a language

    I had the same problem as you OP. C++ was my first language, however after using it for quite awhile I would still have issues with what I call "macro code", or code that dictates how larger parts of a program interact. For me that encapsulated how classes should interact with each other, inheritance, doing #includes correctly, and a few other tidbits. Unfortunately I have never found a text that really teaches how to create good macro code. Here's how I dealt with it and maybe it will help you out. Eventually what happened is I started programming in another OOP language, C#. For C#, OOP is very much more set in stone, and after programming a medium sized project with it, I learned more about OOP than I had learned in almost a year and a half with C++. However this didn't solve my issues with learning how to prevent #include circles, I eventually said 'screw it' and switched over to C# completely. To this day I've never had to tolerate C++'s god-awful translation unit system since then. [spoiler]I promise I dont work for microsoft[/spoiler]
  14. Which level of programming detail is best?

    [quote name='Olof Hedman' timestamp='1335894725' post='4936471'] Are successful big game companies really that sloppy in how they hire? [/quote] Big video game companies suffer the same issues as normal companies. There are HR people who have no idea what they're doing. There's a few who do. I would expect the HR guy at Valve or Dice for example to know their shit a lot better than an HR guy at EA or Activision. I'm not saying that every video game HR rep is an idiot, but based on my experience with HR people who hire for any kind of technical job, many of them don't actually know what they're looking for in a new hire other than making sure they fit the job description. Your results may vary.
  15. Navigation in a big world

    I believe this may be a scenario where it would be a good idea to assist with pathing speeds through caching. I assume you're making some kind of adventure game with towns and roads and such. When the world is generated you might be able to cache the roads and the locations where they lead to and kinda "add them" into your current pathfinding solution. For a case in which something is pathing from one side of the map to another, I imagine this would cut down the path generation time by a few orders of magnitude, in addition to having it so npcs actually use roads.