Thread: game programming with c or c++

  1. #1
    spectum48k
    Guest

    game programming with c or c++

    are new games developed in c or c++ ?
    just curious..

    thnx in advance.

  2. #2
    most are

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Usually both. Lots of times the core of the engine is done in C and assembly, but it's usually C++ for all of the more high-level aspects such as the actual enemies, AI, etc. I always go completely C++ just because I love OOP, but then again, I'm not a professional game developer... yet

  4. #4
    I go full C++, I don't like mixing stuff together, and I am very fond of OOP.

  5. #5
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    Depends on the platform though - the PS2 when it was released was predominantly coded using C and Assembly. In fact Ratbag games in Adelaide have been recruiting programmers with embedded systems and Assembly language experience for their PS2 games.

    I think there is a shift though on the whole to OOP principles with gaming - as compilers get better and the performance difference between C and C++ diminishes (as it has been for a long time now), OOP becomes very attractive for large projects.

    I know of at least one developer who began investigating the possibilities of using Java to write a large scale RTS. But they couldn't get the performance they required and thus moved to C++.

    From the game dev's I know and have talked with - it appears as though the only three current options in game development are C/C++ and Assembly.
    Last edited by foniks munkee; 12-23-2002 at 06:27 AM.
    "Queen and huntress, chaste and fair,
    Now the sun is laid to sleep,
    Seated in thy silver chair,
    State in wonted manner keep."

  6. #6
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Yeah, it's mostly C++, and if not, then it's most-likely just because there isn't a C++ compiler for the particular platform (or at least not one that's very optimized). In terms of performance, there shouldn't be any difference in speed when using the C subset of C++ than from actually using C itself. In that respect, there really isn't a need for actual C at all (though actually coding directly in assembly for certain things still has a lot of benefits).

    In fact, some large-scale games are done almost completely in assembly (IE Railroad Tycoon).

    ... although even he admits it was a rather silly thing to do ...
    Last edited by Polymorphic OOP; 12-23-2002 at 06:36 AM.

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Is the difference in speed between c and c++ big?
    Because i'm not using classes or any other c++ advantages.

  8. #8
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    There shouldn't be a speed difference when using the C subset of C++ in comparison to just using C, but that of course all depends on how good the compiler is.

    When using the OOP parts of C++, you can't really compare it to C because there isn't a direct correspondence to things like polymorphism in C. However, what it comes down to is if you wanted to use the OOP aspects of C++ in C and actually manually went in and made your own vtables and manually did all of the casting in C, then you probably wouldn't have code as optimized as you would if you'd just used OOP C++ and you would have had to do a hell-of-a-lot more coding.

    Even using classes and member functions (without inheritance) and templating should not make your code any slower because all of that is generally just a syntactical variant on things in C.

    What it really comes down to is just preference in terms of whether you'd use C or C++, unless you are limitted by your compiler. Even if you don't like OOP, there's still templating, etc. that C++ has which C doesn't. For just about all games nowadays, developers recognize the benefits of OOP and the enhanced typesafety of C++ and all its other boops and beeps, so they use it for most or all of their projects, but C and assembly are still used a lot as well.
    Last edited by Polymorphic OOP; 12-23-2002 at 07:09 AM.

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Oke, i think i will stick to my c++ compiler anyway,
    will use classes in the future, im just not comfortable with
    them, thx
    Last edited by Travis Dane; 12-23-2002 at 09:42 AM.

  10. #10
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Travis, I strongly suggest that you start to use classes. Classes can be extremely beneficial and should be used by every C++ coder. If you don't understand them well enough right now, then take some time out and get to understand them better. Trust me, it will be worth it.

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    I know how classes work just fine, i tried them many times
    but always ended up trashing the program,most of the times
    the reason is that i don't know wich function could go best
    in wich class, any tutorials on that? or on the layout of a game?

  12. #12
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    It's really subjective how you set up the classes, but if you aren't sure which functions should be a part of which classes then just use the logic "Is this object the one performing the action." If it is then that's the class the function should be a member of.

  13. #13
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    Travis - I would suggest you pick up a book on Object Oriented Programming. Something generic that discusses the design of a program in an OOP fashion, not nessecarily language specific. It sounds as if you understand how to code a class, but just need to have some guidance as to what makes an effective class - when to inherit etc. This in itself is a skill that has to be learnt.

    There used to be a speed difference between C++ and C. But this was not the fault of C++ itself. It was generally to do with the compiler - but compiler technology has come along way, unfortunately the perception that C++ is slow still lingers.

    It is true that if you use some of the features of C++ you can have some performance hits - stuff like RTTI (Run Time Type Information), but you would normally pick and choose the time to use these facilities - and really that is to be expected in that case.

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Any online tutorials covering those aspects recomendable??
    Programming books are almost impossible to get where i live,
    so if there are any tutorials out there i would love to hear em

  15. #15
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    Travis, I've been thinking about creating a tutorial for my site that is going to show how to display a bitmap (along with maybe a few other things in the tutorial) using OOP with Allegro. I'm not sure which API you use, but you would probably be able to get the relative content out of the tutorial. I'll send you a PM if/when I put up the tutorial.

    Also, if you go to a store like Barnes and Nobles or most bookstores you can find good programming books, or you could buy one online. For Christmas I'm getting The C++ Programming Language: Special Edition book. I recommend getting this book, because it is a must read book for any C++ user. Other than that I'm not really sure where you could find some OOP tutorials.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM