As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

Game Development Omni-thread [Unity, XNA, UDK, etc]

DelzhandDelzhand Hard to miss.Registered User regular
edited August 2012 in Games and Technology
Welcome to the Game Development Omni-thread, formerly the XNA thread! Any discussion of game programming, development, or (within reason) asset creation can go here. Up until page 55, you'll pretty much just see XNA discussion, so if you want to talk about something else, don't feel compelled to read the entire thread.

Original OP is in the spoiler.
cco_shell_default_header_xna_logo_print.jpg

What's all this, now?
The prior thread died of old age, so I'll take up the mantle of threadkeeper. This thread is about using XNA and C# to make your own games.

Oh, yeah, Xbox Live Indie Games. I've been meaning to check those out.
No! This thread isn't for info on new releases or reviews or discussion of the existing catalog. I'm sure another thread will be along shortly. Be honest - do you want to wade through five pages of discussion on content pipelines and compiler errors and streamwriters to find out if someone liked Shoot 1Up as much as you did?

No, not really.
Good.

Okay.
Alright.

So... what's up?
Huh?

I still don't know what this thread is about.
Oh, yeah. Sorry. This thread is for PA community members to discuss their works in progress, whore out their latest releases, and to get help with various technical issues regarding game development.

So is this a new thing?
No! XNA has been around for over 2 years now. Version 4.0 comes out pretty soon here. In fact, several forumers here have been developing games ever since it came out, myself included!

Oh yeah?
Yeah.

Like who?
RainbowDespair and Slash000 are working on a 2d sprite based JRPG called Breath of Death, a spoof of Dragon Quest featuring a largely undead cast. Savooiperd has a stylish 2d platformer with customizable weapons. Trumpets has a pretty rad looking platformer as well. AlejandroDaJ has a geography game called Around the World that seems close to playtest stage. These are just from looking at a random page in the last thread. For more details, watch the thread.

Man, I wish I knew how to program.
Well, if you can't you're SOL.

Ha ha ha!
I'm serious. This isn't like RPG Maker 2000. You'll have to build everything yourself. XNA just takes care of stuff like loading assets, drawing objects, playing sounds. All the game logic is up to you.

What do I need, assuming I have some programming skils?
First, you'll want Visual Studio C#. Express 2008 is a free download. http://www.microsoft.com/express/Windows/
Second, you'll want XNA itself. Get it here: http://creators.xna.com/en-US/
If you want to test/release games on Xbox Live, you'll need a Creator's Club account, which runs $99 per year. It also gets you playtest access to upcoming titles. I'm on the fumes of a trial membership, so I can't say too much about full fledged Creator's Club. Maybe I'll update this when it runs out on the 24th.

I know some programming, but I don't know much about game programming specifically, or XNA
Well, the most amazing resource is Ziggyware. Sike! It got infested with malware and Ziggy didn't want to deal with it or something. There isn't really a site that matches it yet, but you can check out http://rbwhitaker.wikidot.com/xna-tutorials or http://www.riemers.net/eng/Tutorials/xnacsharp.php. Also, Shawn Hargreaves runs a pretty rad blog, which is pretty technical, but useful: http://blogs.msdn.com/shawnhar/default.aspx

To get the thread jump started, I hope people with current projects will repost their current or latest info, because I don't really want to cull 100 pages of thread.

Old hands at XNA may with to PM me with additional info they think should be in the OP, and I'll modify it accordingly.

Edit:
RELEASED!
bod7boxart.jpg
Download it now! Show support for PA devs!
http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d802585504bd/

Delzhand on
«134567100

Posts

  • DelzhandDelzhand Hard to miss. Registered User regular
    edited April 2010
    I personally have a variety of projects in various stages of abandonment. Shame on me, honestly. But currently I find my time engaged by an SRPG my best friend and I have been kicking around for about 10 years in conceptual form.

    http://www.youtube.com/watch?v=Cr95rIDKr28

    Delzhand on
  • fragglefartfragglefart Registered User regular
    edited April 2010
    Last week had an explosion of new games, last time I checked there were 888 titles exactly (!)

    Eight hundred and eighty-eight.

    Now that is a lot of games. Getting harder and harder to find the gems.

    fragglefart on
    fragglefart.jpg
  • HandkorHandkor Registered User regular
    edited April 2010
    Ah man new thread, wow. I need to focus on a small project. I keep starting and moving on to new ideas. I am trying to put more games out but so much to play and I get distracted by new games. Hopefully I'll have a new game out be the end of the summer. You know something with unicorns and zeppelins and explosions... yeah that would be nice.

    Delzhand you have been moving ahead quite nicely.

    Handkor on
  • mere_immortalmere_immortal So tasty!Registered User regular
    edited April 2010
    I have 100 points floating on my gamertag.

    What game should I get?

    mere_immortal on
    Steam: mere_immortal - PSN: mere_immortal - XBL: lego pencil - Wii U: mimmortal - 3DS: 1521-7234-1642 - Bordgamegeek: mere_immortal
  • fragglefartfragglefart Registered User regular
    edited April 2010
    fragglefart on
    fragglefart.jpg
  • IzzimachIzzimach Fighter/Mage/Chef Registered User regular
    edited April 2010
    Handkor it sounds like you should make an XNA version of Post-Apocalyptic Unicorn Uprising. Hell, maybe I should make it.

    Here's my first boss, a giant two-headed troll.
    trollrave20100406213553.png

    I hope to make him into some sort of DMC-type boss, with easily telegraphed attacks and lots of hit points. Seems a bit counter to the rest of game (mostly an action RPG) but we'll see how it works out.

    Izzimach on
  • RainbowDespairRainbowDespair Registered User regular
    edited April 2010
    Breath of Death VII will enter official playtesting for testing & debugging at http://creators.xna.com tomorrow, 4/7/2010. Maybe as soon as in a few hours if I decide to stay up all night finishing the game up. I’ll post when it’s done.

    Whew! Almost there!

    RainbowDespair on
  • amnesiasoftamnesiasoft Thick Creamy Furry Registered User regular
    edited April 2010
    Man, I really do need to stop being lazy and do something cool in XNA...

    amnesiasoft on
    steam_sig.png
  • gjaustingjaustin Registered User regular
    edited April 2010
    Man, I really do need to stop being lazy and do something cool in XNA...

    Join the club

    gjaustin on
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited April 2010
    Good OP! Also, "psych" != "sike".

    I'm in the middle of a sad, graphicless platformer right now, but I've been thinking of making a TRPG for about 10 years as well! How did you deal with displaying the tiles? Are they each a discrete unit, or did you just overlay a grid on top of a piece of terrain?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • NamrokNamrok Registered User regular
    edited April 2010
    Finally got around to working on game stuff on the train back from PAX. Finished up the keyframe animation system I'd cooked up for my procedural model system. Been sneaking in time here and there to work on collision detection. I'm abusing the crap out of the BoundFrustrum class. It's fun!

    Won't be so fun shifting everything over to XNA 4.0, but we'll see how it goes.

    Namrok on
  • amnesiasoftamnesiasoft Thick Creamy Furry Registered User regular
    edited April 2010
    gjaustin wrote: »
    Join the club
    Where do I sign up? :P

    amnesiasoft on
    steam_sig.png
  • PrimePrime UKRegistered User regular
    edited April 2010
    I shall be picking your collective brains in the weeks to come!

    Prime on
  • DelzhandDelzhand Hard to miss. Registered User regular
    edited April 2010
    templewulf wrote: »
    Good OP! Also, "psych" != "sike".

    I'm in the middle of a sad, graphicless platformer right now, but I've been thinking of making a TRPG for about 10 years as well! How did you deal with displaying the tiles? Are they each a discrete unit, or did you just overlay a grid on top of a piece of terrain?

    I have a terrain class that has width, height, scale, and a list of tile objects. Each tile object has four variables for corner heights, a bool for whether the tile is walkable (which may be expanded to an enum of ground types like grass/carpet/water/inaccessible), and a bool that determines which way the triangle hypotenuses go through the square when drawn. This is all stored in XML. When the gameplay screen load, it converts each tile to a set of vertices (including automatically building vertical walls, which I will probably avoid since I don't know how to texture them), indices, and texture coordinates. When there is a range of selectable tiles, those tiles in the list are used to create another set of vertex data and drawn after the terrain with an vertical offset of .5f.
    Namrok wrote: »
    Won't be so fun shifting everything over to XNA 4.0, but we'll see how it goes.

    I hear they're doing away with point sprites, which is kinda odd, but I never did get point sprites working in my platformer engine, so I guess I'll be learning a new method for particles. Or maybe I'll wait - Hargreaves said something about updating the 3d particle example.

    Edit: something else I'm worried will break my code is their change to renderstate handling. The whole "2d sprites turn my 3d models inside out" solution of saving the renderstate every time you start a spritebatch is being pretty radically reworked. I'm sure it will be better in the long run, but still...

    Delzhand on
  • Dodge AspenDodge Aspen Registered User regular
    edited April 2010
    What's up with all these Old Spice games showing up this week?

    Dodge Aspen on
    Xbox - Dodge Mega
    Switch - SW-3699-5063-5018

  • templewulftemplewulf The Team Chump USARegistered User regular
    edited April 2010
    What's up with all these Old Spice games showing up this week?

    Because this game is the game you wish your game could smell like.

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • savooipeerdsavooipeerd Registered User regular
    edited April 2010
    What's up with all these Old Spice games showing up this week?

    Microsoft has a contest for XNA games called Dream Build Play, and the last iteration of it had an additional contest sponsored by Old Spice. Now that the results are in the people that didn't win are submitting their games to XBLIG because hey, why not?

    savooipeerd on
    [SIGPIC][/SIGPIC]
  • DelzhandDelzhand Hard to miss. Registered User regular
    edited April 2010
    templewulf wrote: »
    What's up with all these Old Spice games showing up this week?

    Because this game is the game you wish your game could smell like.

    Look at your game. Now look at mine. Look at yours, back to mine. Your game couldn't be mine. But it could smell like mine.

    I'm on a horse

    Delzhand on
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited April 2010
    Delzhand wrote: »
    templewulf wrote: »
    Good OP! Also, "psych" != "sike".

    I'm in the middle of a sad, graphicless platformer right now, but I've been thinking of making a TRPG for about 10 years as well! How did you deal with displaying the tiles? Are they each a discrete unit, or did you just overlay a grid on top of a piece of terrain?

    I have a terrain class that has width, height, scale, and a list of tile objects. Each tile object has four variables for corner heights, a bool for whether the tile is walkable (which may be expanded to an enum of ground types like grass/carpet/water/inaccessible), and a bool that determines which way the triangle hypotenuses go through the square when drawn. This is all stored in XML. When the gameplay screen load, it converts each tile to a set of vertices (including automatically building vertical walls, which I will probably avoid since I don't know how to texture them), indices, and texture coordinates. When there is a range of selectable tiles, those tiles in the list are used to create another set of vertex data and drawn after the terrain with an vertical offset of .5f.
    That's about what I'm doing except for a.) the bolded portion; why would that be important? and b.) I have no textures for my tiles. Do you just index into an old-schooly spritemap for your tile texture? Do you just slice up larger-than-one-tile items into multiple textures?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • ImperfectImperfect Toronto, Ontario, CanadaRegistered User regular
    edited April 2010
    I really want to get back into playing around with XNA - Christ, it's what I bought Windows 7 FOR.

    I'm still a little flummoxed though by how to properly organize things. When I get home (if I remember), I'll dig up my sources and see if I can identify some specific questions I had to pose to all you more practiced programmers.

    Imperfect on
  • StargliderStarglider Registered User regular
    edited April 2010
    templewulf wrote: »
    Delzhand wrote: »
    a bool that determines which way the triangle hypotenuses go through the square when drawn.
    That's about what I'm doing except for a.) the bolded portion; why would that be important?

    Changing the orientation of the diagonal based on the vertex heights can produce smoother looking terrain. Personally I use a grid of equilateral triangles instead of squares, because this further reduces visual artefacts. Neither of these are really necessary for an RPG style game that isn't going for graphical realism.

    Starglider on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    So...is this only for XNA games? Or can I talk about my awesome indie game I'm making using the OGRE 3D engine?

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • ImperfectImperfect Toronto, Ontario, CanadaRegistered User regular
    edited April 2010
    GnomeTank wrote: »
    So...is this only for XNA games? Or can I talk about my awesome indie game I'm making using the OGRE 3D engine?

    GET OUT SCUM

    But srsly, we all love games here. While OGRE 3D may be off-topic a bit, I don't think anyone will flame you so long as you do not completely derail the thread in a non-fun, non-intuitive way.

    My own plan is to maybe make something using XNA, then build Steamworks into it and put it up on Steam. Steam generally seems to be the better distribution portal, offering neat promotions, even for indie titles.

    Imperfect on
  • DelzhandDelzhand Hard to miss. Registered User regular
    edited April 2010
    Starglider wrote: »
    templewulf wrote: »
    Delzhand wrote: »
    a bool that determines which way the triangle hypotenuses go through the square when drawn.
    That's about what I'm doing except for a.) the bolded portion; why would that be important?

    Changing the orientation of the diagonal based on the vertex heights can produce smoother looking terrain. Personally I use a grid of equilateral triangles instead of squares, because this further reduces visual artefacts. Neither of these are really necessary for an RPG style game that isn't going for graphical realism.

    Close - it's not about smoothness, but uniformity. Imagine a square laying flat on the ground. If you raise a single corner, one of two things will happen - if the corner touches the shared hypotenuse of the triangles that make up the square, you'll have a downward facing "fold". Otherwise, you'll have an upwards facing "fold" (in this case, you still have a whole triangle flat on the ground.

    Is that clear at all?

    Edit:
    tiles.jpg

    Delzhand on
  • tastydonutstastydonuts Registered User regular
    edited April 2010
    What's up with all these Old Spice games showing up this week?

    Microsoft has a contest for XNA games called Dream Build Play, and the last iteration of it had an additional contest sponsored by Old Spice. Now that the results are in the people that didn't win are submitting their games to XBLIG because hey, why not?

    ah. that makes sense.

    I'm thinking about scrapping my project (again) because of how much I seem to be developing a genuine hatred of 3d animation, and the horrible cycle of the only way you can get better at it is to keep doing it to get better at it but it's just evil. I imagine I will repeat this cycle again a few more times before I get to the point of putting a game out there, or just go "screw it" and charge forward, horrible animations and all.

    tastydonuts on
    “I used to draw, hard to admit that I used to draw...”
  • IzzimachIzzimach Fighter/Mage/Chef Registered User regular
    edited April 2010
    I imagine I will repeat this cycle again a few more times before I get to the point of putting a game out there, or just go "screw it" and charge forward, horrible animations and all.

    Just go "screw it" dude. Have you seen some of the available games? Some of them are terrible, terrible abominations, even for 80 points. Plus, rough animation and graphics isn't a death sentence; games like Johnny Platform's Biscuit Romp are still pretty good even if they look like they're done with MS Paint.

    Izzimach on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    Nice spam bot.

    Anyway, one of my big complaints with using C# for game development (and mind you, I love, love, love C#), is the lack of multiple inheritance, which makes doing a truly component based game architecture difficult, without jumping through some odd hips. This is one of those edge cases where true multiple inheritance is a god send.

    This is one of the primary reasons I've shied away from XNA. If you look at my C++ engine that uses OGRE, my game objects are built as composites from many smaller, specialized, working parts.

    So every object in the game sub-classes from Object, which provides some basic things all objects need (tags, id's, etc). But beyond Object, the game objects composite themselves. For instance, my Actor class is a sub-class of Object, but also mixes in (via multiple inheritance) the MeshRenderable and Scriptable components. What they do is pretty self evident by their names.

    You could do this in C# using interfaces and some hackney eyed default-implementation scheme. You could also try and do it with a single inheritance tree, but you'd end up with a ton of bases classes that were only base classes because you needed that particular combination of mixin components in the inheritance chain.

    How are you guys handling this in your XNA engines? Or are you not even trying to architect your game engines at that level? I write commercial software for a living, so I don't tend to "hack" anything together, I tend to design things right "the first time" and leave myself a maintainable, extensible, code base for later.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • NamrokNamrok Registered User regular
    edited April 2010
    GnomeTank wrote: »
    Multiple Inheritance rant

    Honestly, I've never run into a situation where I felt I needed multiple inheritance. Most of the examples I've seen appeared contrived to me. Then again, I haven't used C++ in a while and have completely internalized the design perspective of C#. A friend of mine who codes mostly in C/C++ also seemed troubled that C# didn't have multiple inheritance, and seemed to dislike how if you attempt the same thing using interfaces, you end up with a lot of code duplication. But in actual use, I don't think it's come up.

    I can only compare it to when I switch from Java to C# and vice versa. When I'm writing Java, it goes just fine. But Java does not support passing by reference, where as C# does. So what I find happening is that I will do lots of it in C#, but the thought never even occurs to me in Java. It's only when I try to translate one codebase to another that I even realized the difference in my coding habits with respect to the language I'm in.

    Namrok on
  • ImperfectImperfect Toronto, Ontario, CanadaRegistered User regular
    edited April 2010
    Ugh, you described largely my problem with XNA, actually. Previous to this, I was working on a Dwarf-Fortress-alike But With Zombies, and the lack of really extensible classes was driving me crazy. Plus, try to work out how to do really dynamic object instantiation in C# without losing your cheese.

    I kind of dread going back there. I could do that shit in, say, PHP (not an especially concise language) in one line. In C#, it's like, four functions spread out amongst three classes and WTF I AM JUST TRYING TO LOAD A TREE BASED ON AN INI FILE.

    Imperfect on
  • DelzhandDelzhand Hard to miss. Registered User regular
    edited April 2010
    What? I'm almost certain C# allows multiple inheritance. I know you can inherit from a class and several interfaces, at the very least.

    Delzhand on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    Namrok wrote: »
    GnomeTank wrote: »
    Multiple Inheritance rant

    Honestly, I've never run into a situation where I felt I needed multiple inheritance. Most of the examples I've seen appeared contrived to me. Then again, I haven't used C++ in a while and have completely internalized the design perspective of C#. A friend of mine who codes mostly in C/C++ also seemed troubled that C# didn't have multiple inheritance, and seemed to dislike how if you attempt the same thing using interfaces, you end up with a lot of code duplication. But in actual use, I don't think it's come up.

    I can only compare it to when I switch from Java to C# and vice versa. When I'm writing Java, it goes just fine. But Java does not support passing by reference, where as C# does. So what I find happening is that I will do lots of it in C#, but the thought never even occurs to me in Java. It's only when I try to translate one codebase to another that I even realized the difference in my coding habits with respect to the language I'm in.

    What I wrote wasn't a 'rant', and my example is not contrived at all. Notice how I am building object in a composite fashion. This is hard to do without multiple inheritance. I also noted that it's an edge case, and in many cases multiple inheritance isn't needed (I don't find myself ever wanting it at work, where I write C# for a living).

    But, this isn't a programming zealotry thread. I was simply asking how people were architecting their game engines with XNA, using how I use multiple inheritance in C++ as a backdrop for the discussion.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    Delzhand wrote: »
    What? I'm almost certain C# allows multiple inheritance. I know you can inherit from a class and several interfaces, at the very least.

    Nein sir. It supports multiple interface implementation, it does not support true multiple implementation inheritance.

    A C# class can implement multiple interfaces, but cannot inherit multiple classes.

    e: Bah.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • NamrokNamrok Registered User regular
    edited April 2010
    GnomeTank wrote: »
    Namrok wrote: »
    GnomeTank wrote: »
    Multiple Inheritance rant

    Honestly, I've never run into a situation where I felt I needed multiple inheritance. Most of the examples I've seen appeared contrived to me. Then again, I haven't used C++ in a while and have completely internalized the design perspective of C#. A friend of mine who codes mostly in C/C++ also seemed troubled that C# didn't have multiple inheritance, and seemed to dislike how if you attempt the same thing using interfaces, you end up with a lot of code duplication. But in actual use, I don't think it's come up.

    I can only compare it to when I switch from Java to C# and vice versa. When I'm writing Java, it goes just fine. But Java does not support passing by reference, where as C# does. So what I find happening is that I will do lots of it in C#, but the thought never even occurs to me in Java. It's only when I try to translate one codebase to another that I even realized the difference in my coding habits with respect to the language I'm in.

    What I wrote wasn't a 'rant', and my example is not contrived at all. Notice how I am building object in a composite fashion. This is hard to do without multiple inheritance. I also noted that it's an edge case, and in many cases multiple inheritance isn't needed (I don't find myself ever wanting it at work, where I write C# for a living).

    But, this isn't a programming zealotry thread. I was simply asking how people were architecting their game engines with XNA, using how I use multiple inheritance in C++ as a backdrop for the discussion.

    Sorry, I didn't mean to insult by calling it a rant, I just didn't want to quote a large post.

    Mostly I just don't think in terms of class heirarchies which converge instead of branch. It not being an option, I haven't even thought of what to do instead, because I never do that in the first place.

    I do know that I have multiple subsystems in my game class library already. Anything that collides with something else needs to support ICollidable so my collision event service can do what it needs to do. Anything that accepts user input needs to support IControllable so that my control hub knows how to route controls around. My model animation system has IMeshAnimation interfaces and so on (since I have keyframe animation systems and procedural animation systems).

    In theory, I could make all those interfaces classes, and then multiple inheritance things together when a class needs all of them. But frankly, almost every time I implement one of those classes, I do it in a radically different way, save for getting and setter functions on my various ICamera implementation (Ortho, Perspective, etc). And if a class needs them all, I've done something wrong. Because once upon a time, I did that, and it was a horrible debugging clusterfuck of a disaster.

    Seriously, it was horrible, and the reason my first game never got close to finished.

    Namrok on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    If you're in a situation where you're writing "vastly different implementations" per-object, you may be designing something wrong to begin with, or your original base was not general enough.

    I don't have the code here, so I can't post the header for any of my components, but basically if you look at Scriptable it contains all the pieces you need to wire up scripting for an object: storage for the script context, script context initialization, generic methods to call script functions, generic ways to load a script in to the context. These are operations that should, if things are designed correctly, be absolutely 100% the same for everyone object. If you do need to overload the default behavior, everything is marked virtual (except getters and setters, makes them too slow).

    The inheriting component object can then use those generic facilities to wire up scripting in an object specific way.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • IzzimachIzzimach Fighter/Mage/Chef Registered User regular
    edited April 2010
    Well, I just use interfaces and aggregation; I don't even have a "base class" which all game objects inherit from. I only have about six interfaces and I don't need every combination of them, so the combinatorial explosion isn't a problem in practice. If I used inheritance I would just be overriding methods, so my game wouldn't gain much from it I think.

    I'm curious as to what tutorials/samples people have folded into their game. I know I have the Skinned animation sample, particles sample, and deferred shading tutorial (from Catalin Zima). What other stuff? I think I saw the "safe area" component being used in someone's video (Delzhand's?).

    Izzimach on
  • NamrokNamrok Registered User regular
    edited April 2010
    GnomeTank wrote: »
    If you're in a situation where you're writing "vastly different implementations" per-object, you may be designing something wrong to begin with, or your original base was not general enough.

    I don't have the code here, so I can't post the header for any of my components, but basically if you look at Scriptable it contains all the pieces you need to wire up scripting for an object: storage for the script context, script context initialization, generic methods to call script functions, generic ways to load a script in to the context. These are operations that should, if things are designed correctly, be absolutely 100% the same for everyone object. If you do need to overload the default behavior, everything is marked virtual (except getters and setters, makes them too slow).

    The inheriting component object can then use those generic facilities to wire up scripting in an object specific way.

    Well, the reason I'm using interfaces instead of inheritance is because they are vastly different implementations. There is zero commonality between how a keyframe animation system calculates its animation matrix and how a procedural one does.

    Namrok on
  • gjaustingjaustin Registered User regular
    edited April 2010
    GnomeTank wrote: »
    If you're in a situation where you're writing "vastly different implementations" per-object, you may be designing something wrong to begin with, or your original base was not general enough.

    I don't have the code here, so I can't post the header for any of my components, but basically if you look at Scriptable it contains all the pieces you need to wire up scripting for an object: storage for the script context, script context initialization, generic methods to call script functions, generic ways to load a script in to the context. These are operations that should, if things are designed correctly, be absolutely 100% the same for everyone object. If you do need to overload the default behavior, everything is marked virtual (except getters and setters, makes them too slow).

    The inheriting component object can then use those generic facilities to wire up scripting in an object specific way.

    I think in all my years of programming I've run into a situation where I needed multiple inheritance once. And it only came up because I had to create an extension to an existing class hierarchy that I couldn't change.

    It sounds like you're designing much more monolithic classes than would work in C# and XNA. My design is split into more interchangeable parts.

    I make heavy use of utility classes and methods. So while your class might look like:
    public class Entity : Object, Scriptable
    {
       public void RunScript()
      {
          this.ExecuteScriptAction();
      }
    }
    

    Mine looks like:
    public class Entity : Object implements IScriptable
    {
       public void RunScript()
       {
           this.ScriptAction.Execute();
       }
    }
    


    So they work fundamentally the same way, but mine is less tied to a specific implementation of scripting, since I could always just instantiate a different class.

    Edit: To be fair, yours has the advantage of saving a few lines of code in the Deserialization method.

    gjaustin on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    gjaustin wrote: »
    GnomeTank wrote: »
    If you're in a situation where you're writing "vastly different implementations" per-object, you may be designing something wrong to begin with, or your original base was not general enough.

    I don't have the code here, so I can't post the header for any of my components, but basically if you look at Scriptable it contains all the pieces you need to wire up scripting for an object: storage for the script context, script context initialization, generic methods to call script functions, generic ways to load a script in to the context. These are operations that should, if things are designed correctly, be absolutely 100% the same for everyone object. If you do need to overload the default behavior, everything is marked virtual (except getters and setters, makes them too slow).

    The inheriting component object can then use those generic facilities to wire up scripting in an object specific way.

    I think in all my years of programming I've run into a situation where I needed multiple inheritance once. And it only came up because I had to create an extension to an existing class hierarchy that I couldn't change.

    It sounds like you're designing much more monolithic classes than would work in C# and XNA. My design is split into more interchangeable parts.

    I make heavy use of utility classes and methods. So while your class might look like:
    public class Entity : Object, Scriptable
    {
       public void RunScript()
      {
          this.ExecuteScriptAction();
      }
    }
    

    Mine looks like:
    public class Entity : Object implements IScriptable
    {
       public void RunScript()
       {
           this.ScriptAction.Execute();
       }
    }
    


    So they work fundamentally the same way, but mine is less tied to a specific implementation of scripting, since I could always just instantiate a different class.

    Edit: To be fair, yours has the advantage of saving a few lines of code in the Deserialization method.

    The problem here is that you have to re-implement IScriptable every time you want to create a scriptable object. You don't get any advantages of having the most mundane, completely generic, parts of scripting be drop-and-drop mixable.

    I have several places this makes a lot of sense to me. For instance, my Actor class is Scriptable, so is my CombatEngine class. They share no other similarities, except they both need a place to store a scripting context, and both need a way to call methods inside that context. My Static class and my Actor class are both Scriptable, and both game Objects, but one is a AnimatedRenderable, the other is a MeshRenderable...because static object's don't need to render an animated mesh. Yes, I could have had an IAnimatedRenderable and an IMeshRenderable, but again, I would be stuck reimplementing the same interface twice on two separate objects.

    I could have an IScriptable interface, but then Actor and CombatEngine would both need to implement IScriptable (or would need to aggregate an object that does, which is by no means any cleaner). I need to do neither, I just need to publically inherit Scriptable. The illusion that using interface implementation and aggregation gives you the magic bullet so that you can easily change scripting engines is just that, an illusion. It's no easier, or more difficult, than for me to simply change the Scriptable base class implementation.

    Object composites are that edge case where multiple inheritance clearly outshines interface implementation and aggregation. This is why there are several C# engines out there trying to provide object composites that don't look horrible in the framework of interface implementation and aggregation.

    e: Also, by the very definition of my system, my classes are not monolithic even in the slightest. Scriptable does scripting, that's it. It does it very well, and in a completely sub-class agnostic way. I can hang Scriptable off of anything, not just game objects sub-classing from Object. And I do, given by my CombatEngine v. Actor example. Both are Scriptable, but share zero similarities beyond that. That's is the exact definition of extensible and reusable (aka not monolithic).

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • SeolSeol Registered User regular
    edited April 2010
    You keep talking about object composites. So... why not use composition, instead of inheritance? It sounds like you're creating things like scripting contexts as standalone conceptual entities: so make them member objects, not base classes?

    edit: Yes, this is a bit more of a pain in the neck to implement: you need a scripting context getter, and interfaces to support accessing contexts, and it makes it more awkward if you want to access two conceptual entities at the same time. On the other hand, it protects you from the reasons why multiple inheritance was considered dangerous in the first place: if you do something in ScriptContext which conflicts with AnimationContext - give two fields the same name, for example - then that's not a problem, because they're entirely separate entities.

    Seol on
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2010
    Seol wrote: »
    You keep talking about object composites. So... why not use composition, instead of inheritance? It sounds like you're creating things like scripting contexts as standalone conceptual entities: so make them member objects, not base classes?

    edit: Yes, this is a bit more of a pain in the neck to implement: you need a scripting context getter, and interfaces to support accessing contexts, and it makes it more awkward if you want to access two conceptual entities at the same time. On the other hand, it protects you from the reasons why multiple inheritance was considered dangerous in the first place: if you do something in ScriptContext which conflicts with AnimationContext - give two fields the same name, for example - then that's not a problem, because they're entirely separate entities.

    You answered your own question in your edit. If I was doing this in C#, I would have no choice but to do what you suggest (which is composition through aggregation, btw). The "danger" of multiple inheritance is not lessened in C#. I can still have two interface that have a conflicting method, or property, signatures. I just have to implement one of the interfaces explicitly (IInterface.ConflictingMethod), rather than implicitly. In some ways, this is more dangerous than the multiple inheritance case. At least one tells me at compile time I have an ambiguous symbol, the other lets me work around it and then basically hide the conflicting method, rather than correctly design my interfaces.

    Also, if you keep your fields 'private' in C++ (which you should be doing, sub-classes don't need to access fields, they should have protected/public getters/setters if they need access), then you can have 15 base classes all with the private field '_name' and not conflict.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
This discussion has been closed.