Using C for game development

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pereges

    Using C for game development

    I want to begin by making simple 2D games for Dos. What particular
    features of C should I look to strengthen ? I am not asking about the
    graphics bit but in general.
  • Richard Heathfield

    #2
    Re: Using C for game development

    pereges said:
    I want to begin by making simple 2D games for Dos. What particular
    features of C should I look to strengthen ? I am not asking about the
    graphics bit but in general.
    Structure, modularity, and cleanliness. Games can rapidly become a mess of
    hard-to-maintain code if you're not very, very strict with yourself. Avoid
    goto like the plague. (I mean, I do that anyway, but I'm not being
    generally-dogmatic here, merely games-programming-dogmatic.) Avoid file
    scope wherever practical, even if it means longer parameter lists. Keep
    your loops sweet. And try to keep your hardware interface code as isolated
    as possible from your game logic and configuration code.

    In short, take all the good advice about program organisation that people
    regularly post to this group, and get religious about it. Otherwise, when
    you "only" want to make a simple modification to the game six months from
    now, you'll find it much more difficult than it needs to be.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • fnegroni

      #3
      Re: Using C for game development

      I don't disagree with Richard's advise.

      But it came as a surprise just because I was recently told by a UK
      game developer that unless you are developing an engine you want to
      sell to third parties (which most game developers don't do) then most
      of the code is write once and forget. And that seems to work well for
      game developers since they usually do not do much maintenance, and
      they live on the bleeding edge of platform specific development.

      So I wonder whether different software houses have different
      approaches to game development.

      Comment

      • Richard Heathfield

        #4
        Re: Using C for game development

        fnegroni said:
        I don't disagree with Richard's advise.
        >
        But it came as a surprise just because I was recently told by a UK
        game developer that unless you are developing an engine you want to
        sell to third parties (which most game developers don't do) then most
        of the code is write once and forget.
        ....and it shows.

        Nevertheless, remember that commercial games developers rarely work in
        isolation - rather, they work in teams. And so, albeit for different
        reasons, much the same advice applies to them, i.e. loose coupling,
        modularity, well-defined interfaces and so on.
        And that seems to work well for
        game developers since they usually do not do much maintenance,
        Certainly not as much as they should.

        --
        Richard Heathfield <http://www.cpax.org.uk >
        Email: -http://www. +rjh@
        Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
        "Usenet is a strange place" - dmr 29 July 1999

        Comment

        • cr88192

          #5
          Re: Using C for game development


          "fnegroni" <f.e.negroni@go oglemail.comwro te in message
          news:914aafcb-796f-4f79-b8a9-81e12782a553@y3 8g2000hsy.googl egroups.com...
          >I don't disagree with Richard's advise.
          >
          But it came as a surprise just because I was recently told by a UK
          game developer that unless you are developing an engine you want to
          sell to third parties (which most game developers don't do) then most
          of the code is write once and forget. And that seems to work well for
          game developers since they usually do not do much maintenance, and
          they live on the bleeding edge of platform specific development.
          >
          yes, however this depends a lot on the scale and complexity of the game.

          for some simplistic engines, say those with maybe only 40 or 50 thousand
          lines of code, and doing 2D or limited-functionality 3D gameplay, this is
          probably a workable practice.

          for much of anything much beyond this, it is very likely that the developers
          will have good reason to reuse the code, or for worthwhile games, to make
          sequels, so it also makes sense to try to keep it clean.


          at least IME, 3D and OS-specific stuff is a small portion of the total
          project anyways, most of the rest going into far more mundane tasks
          (physics, VM, scene graph, AI and scripts, ...).


          even then, most of the 3D code is pretty damn generic, and if well written,
          reusable.
          after all, shaders are not rocket science...


          same old 3D modeling and rendering code, just throwing a shader on it, and,
          POOF, the damn thing is shiny polished gold... a little more coding, and,
          POOF, the damn thing casts a real-time shadow.

          ok, ok, me typically doing 'mundane' shadow technology as well, aka,
          projection-shadows for small things, and ray-tracing+vertex-lighting for
          large things, along with good old lightmaps as well...

          IME, if done well real-time ray-casting comes out scaling better than shadow
          volumes, and does not incure the performance hit of using stenciling, or at
          least on the cards I have often ended up using...

          also possible would be to experiment with the HW-shadow support that comes
          with newer GL versions, which may also be sensible.


          teh pretties have not been a very high concern though (I am one of those
          people, apparently afflicted with the lack of an aesthetic sense, ie, I
          don't really care as much personally if stuff looks like crap...).


          of course, I am a hobbyist, so I haven't really made any "real" games (with
          a story and missions and all that), but, my lack of "creative motivation"
          does not necessarily mean I am not unfammiliar with engines (I wrote one, as
          did I write 3D modeling tools, ... so I have some idea...).

          of course, it may well be, if I am ever to make a job out of this, may well
          have to go the last few steps, and "be creative", AKA: art, modeling, maps,
          storyline, ... all things I would much rather offload to "someone else" (I
          like techie stuff, but creative pursuits are not as much my strong point),
          but alas, I am the only one here...

          I can't recruit anyone, sadly, because there is no one to recruit, and even
          if requested to do something, people don't do it, it is lame...

          not going to win the world just with technology it seems (esp all my crufty
          hobbyist crap), one needs something more directly marketable...


          So I wonder whether different software houses have different
          approaches to game development.
          I would presume so...


          some people write and maintain commercial engines.
          other people liscense their engines from others.

          some people cruft together their own engine fresh for each game.
          others keep reusing and tweaking the same old engine indefinitely.

          it all depends really...


          <psychotic_ramb ling>

          people can do whatever they want really, but in industry, it is all about
          the market, and getting a product to this market (all so we can get money,
          so we can make more products, ...).

          now, in my case, I like code and techy things, the market being both a goal
          and a tool.
          money for things and things for money, all so that one can hopefully
          increase both, in this world bent on holding us back and forcing us into
          this menial existence...

          (everyone with hopes and dreams, all dreams crushed as a prerequisite of
          joining the "real world", as we all become dull and lazy with no real hope
          of achieving anything much beyond leisure and various "pleasures"...) .

          and, for a while, one ends up buying into all this, only later to discover
          that they have at least some personal freedom, which has all been squandered
          as so many lost years of braindead conformance...

          (after all, it is not conformance making this world move along, that
          industry is driven by all our peaceful dilligence and concerns for
          "self-image", striving to "get to the top" in some elaborate popularity
          contest masquerading as a meaningful and useful existence...).


          and the end product:
          the world is a better place, since in the end all this crap ends up in the
          hands of individuals and hobbyists anyways, more power to the people as a
          whole... ever increasing the power of industry to make more products, ...


          of course, then there is this big letdown, "who am I"?... just another
          pointless hobbyist it seems, irrelevant to the larger scheme of things...

          things would be a lot easier though if I had money and people around who
          knew how to do anything useful...

          ("build it and they will come" it seems, one has to bootstrap the process
          somehow I guess...).

          oh well...


          </psychotic_rambl ing>



          Comment

          • Malcolm McLean

            #6
            Re: Using C for game development


            "pereges" <Broli00@gmail. comwrote in message
            >I want to begin by making simple 2D games for Dos. What particular
            features of C should I look to strengthen ? I am not asking about the
            graphics bit but in general.
            >
            For a simple 2D game there is quite a bit of routine code to manage the
            screen, collect input from the user, and keep score, lives, and other game
            states.

            The hard part is giving the baddies intelligence. Normally you can solve
            this by giving the baddies something that looks very clever but isn't
            really. For instance space invaders can dive using one of a variety of
            pre-generated swoop paths, maybe with a "loop radius" parameter in there to
            make it look like you've got far more paths than you really have.

            The other hard part, for an action game, is calibrating gameplay.

            --
            Free games and programming goodies.


            Comment

            • Dann Corbit

              #7
              Re: Using C for game development

              "Malcolm McLean" <regniztar@btin ternet.comwrote in message
              news:oOednRUsuu BpeI3VnZ2dnUVZ8 uCdnZ2d@bt.com. ..
              >
              "pereges" <Broli00@gmail. comwrote in message
              >>I want to begin by making simple 2D games for Dos. What particular
              >features of C should I look to strengthen ? I am not asking about the
              >graphics bit but in general.
              >>
              For a simple 2D game there is quite a bit of routine code to manage the
              screen, collect input from the user, and keep score, lives, and other game
              states.
              >
              The hard part is giving the baddies intelligence. Normally you can solve
              this by giving the baddies something that looks very clever but isn't
              really. For instance space invaders can dive using one of a variety of
              pre-generated swoop paths, maybe with a "loop radius" parameter in there
              to make it look like you've got far more paths than you really have.
              >
              The other hard part, for an action game, is calibrating gameplay.
              Suggestion to people who want to write games:

              Go here:
              Compare the best free open source software at SourceForge. Free, secure and fast open source software downloads from the largest open source applications and software directory.


              And put this in the search box:
              -has_file:(0) AND trove:(80 287 597 633 82 86 268 81 84 288 85 83)

              I got 7869 results


              ** Posted from http://www.teranews.com **

              Comment

              Working...