Game Power in C and C++

This is a discussion on Game Power in C and C++ within the Game Programming forums, part of the General Programming Boards category; I just started learning C and C++, and im planning on making some pretty big games with them. I know ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    9

    Question Game Power in C and C++

    I just started learning C and C++, and im planning on making some pretty big games with them. I know C++ can make the games, but I LOVE C, its more neat and clean.

    Could I make a retail quality game in C? I really dont expect I can, but Id rather make sure then spend all my time programming in a language that confuses me.

    Now Bjarne Stroustrup (creator of C++) compiled a list of things we use in our dayto day lives the use C++...Phone Companys, Cencus, Immigration...And so on, yet what interested me is that all Microsoft games are written in an engine made with C++... This amazed me, As I said im new to C and C++. Right now im starting a small Game Making Team...Were almost a year old. Were Semi-successful yet we, thus far used game creation programs. I want to make our own programs, with those program you must learn basic languages of course, and i am studying C and C++...So I have a very vague idea of their power. But I cant learn C++, I read the tutorials over and over again...Something about it just doesnt stick. So if there isnt a way to make a game (IE Halo, ElderScrolls 3 Morrowind) in C, does anyone have any tips on learning C++?
    (I use this sites tutorial)

    Thanks much,
    Shadok

    Note: Sorry for ALL the spelling errors, I have horrible spelling and spell check doesnt work
    Last edited by shadok; 08-19-2006 at 11:10 PM.

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    You can.

    By the way... can you tell me how C is neater than C++ in any way ?
    Code:
    /* The C way */
    
    int add(int, int);
    float add(float, float);
    double add(double, double);
    long add(long, long);
    
    /* ... */
    
    // The C++ way
    
    template <class T>
    T add(T, T);
    There are *many* other situations where C is ugly and C++ is way more elegant. Not to mention that you don't need to code custom linked lists and such because they are provided by the STL and containers like maps have no equivalent in C. Beat that ! ;-)

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    9
    I quess I worded that way wrong. I never was good at learning things, from Elementry to highschool. But certain methods of doing things always seemed to work better for me, even if they were more complex.

    But for some reason I can learn C easier then C++. I see you suggest C++ is better...But I try and try, it just doesnt stick

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    903
    Ahah, you use what best fits you, it's just a matter of preference... but I know what you mean. It happens to me too. In 6th grade I even confused the hell out of my math teacher because she couldn't understand how I got the right answer without using her way =D Ok maybe she was dumb -.- To each his own.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Desolation
    You can.

    By the way... can you tell me how C is neater than C++ in any way ?
    Code:
    /* The C way */
    
    int add(int, int);
    float add(float, float);
    double add(double, double);
    long add(long, long);
    
    /* ... */
    
    // The C++ way
    
    template <class T>
    T add(T, T);
    There are *many* other situations where C is ugly and C++ is way more elegant. Not to mention that you don't need to code custom linked lists and such because they are provided by the STL and containers like maps have no equivalent in C. Beat that ! ;-)
    You do know that in C you can simply use the + operator to add. Now I may not know a lot of C++, but I'm fairly sure you can even use that in C++.
    Code:
    c = a + b;
    Templates are ugly. Oh, and operator overloading? Don't get me started!


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    Quote Originally Posted by Desolation
    int add(int, int);
    float add(float, float);
    double add(double, double);
    long add(long, long);
    C doesn't support function overloading, so you'd probably have to name them like addi, addf, addd, addld or just use the + operator instead.

    I prefer C because the OO in C++ is ugly and other things like printf being prettier than cout as it first gives you a nice overview of the layout of things to be printed looking at the format string.
    Code:
    //C++ way
    class coord {
    	int x, y, z;
    
    	public:
    		int getX (void)
    		{
    			return x;
    		}
    		int getY (void)
    		{
    			return y;
    		}
    		int getZ (void)
    		{
    			return z;
    		}
    		void setX (int _x)
    		{
    			x = _x;
    		}
    		void setY (int _y)
    		{
    			x = _y;
    		}
    		void setZ (int _z)
    		{
    			x = _z;
    		}
    };
    
    //C
    typedef struct {
    	int x, y, z;
    } coord;
    Of course you could do it just as pretty as C but that's just not the OO way of doing things, everything has to be private for some reason and everyones seems to follow it as well.

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    903
    Huh, that was an example for the point of being an example -.- You've got the point ;-)

  8. #8
    Registered User
    Join Date
    Mar 2006
    Posts
    9
    Also all I see made with C is DOS games. I require 3D games, my team sells games. You cant sell a DOS game these days.

    Wait, so your telling me C and C++ are just different languages with the same power?

    C is the base of most languages, C++ is based off C. So how is it the C and C++ would have the same power?

  9. #9
    Registered User
    Join Date
    May 2006
    Posts
    903
    Quote Originally Posted by OnionKnight
    C doesn't support function overloading, so you'd probably have to name them like addi, addf, addd, addld or just use the + operator instead.

    I prefer C because the OO in C++ is ugly and other things like printf being prettier than cout as it first gives you a nice overview of the layout of things to be printed looking at the format string.
    Code:
    //C++ way
    class coord {
    	int x, y, z;
    
    	public:
    		int getX (void)
    		{
    			return x;
    		}
    		int getY (void)
    		{
    			return y;
    		}
    		int getZ (void)
    		{
    			return z;
    		}
    		void setX (int _x)
    		{
    			x = _x;
    		}
    		void setY (int _y)
    		{
    			x = _y;
    		}
    		void setZ (int _z)
    		{
    			x = _z;
    		}
    };
    
    //C
    typedef struct {
    	int x, y, z;
    } coord;
    Of course you could do it just as pretty as C but that's just not the OO way of doing things, everything has to be private for some reason and everyones seems to follow it as well.
    Everything doesn't need to be private. In your example, there is absolutely no reason for x,y,z to be private thus those functions have no reasons to be there and you end up with the same solution. The only time you will need to use get/set methods is when a member variable's value affects directly other components of your application or other variable values. If you create a TextBox class, changing the variable m_lpszCaption wouldn't change the text of the text box so it would be better to make m_lpszCaption private and have set method to do both jobs at the same time (assign the new value and change the text box's caption) and of course a get method to retrieve the value anytime wanted.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well, considering neither of them is a truely OO language...

    Some mod want to split this thread and take it to the general forum? Isn't there a 'dead horse' forum we can stick this in?


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Registered User
    Join Date
    May 2006
    Posts
    903
    Quote Originally Posted by shadok
    Also all I see made with C is DOS games. I require 3D games, my team sells games. You cant sell a DOS game these days.

    Wait, so your telling me C and C++ are just different languages with the same power?

    C is the base of most languages, C++ is based off C. So how is it the C and C++ would have the same power?
    I would see C++ as a side-project of C just like A Perfect Circle is a side-project of Tool's Maynard (their singer). They are difference... yet using a C++ compiler should make you able to compile any C code with little to no modifications *and* of course C++ code. If you want to make 3D games, you want to either do it the hard, custom way using OpenGL and DirectX or use a rendering engine like Ogre or Irrlicht (don't try to pick up on me, I know DirectX isn't only a rendering engine..) which is a lot easier, in my opinion.

    Edit:
    Were Semi-successful yet we, thus far used game creation programs. I want to make our own programs, with those program you must learn basic languages of course, and i am studying C and C++...
    An alarm just went off. So you've used RPG Maker (or some sort) to make games and now you believe you can make like.. a WoW clone using *simple* languages like C and C++ ? If you want to start with a simple language, start with something like C#, Java or VB. C and C++ are much more likely to give you headaches.
    Last edited by Desolation; 08-19-2006 at 11:40 PM.

  12. #12
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Define power. Then we can discuss which has more 'power.'

    C and C++ are both good languages, but in **general** it is easier to program in a modular manner in C++. Which is important for game development due to how the different engines should work together. Not nocking C, tons of thing are/were made with it and they are still great. But most serious game programers work in C++.

    I see C being used for embeded or kernel level things more often than I see C++. Not that develpment is restricted to that (Win32 API is in C, along with many other GUI APIs)

  13. #13
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    Quote Originally Posted by Desolation
    Everything doesn't need to be private. In your example, there is absolutely no reason for x,y,z to be private thus those functions have no reasons to be there and you end up with the same solution. The only time you will need to use get/set methods is when a member variable's value affects directly other components of your application or other variable values. If you create a TextBox class, changing the variable m_lpszCaption wouldn't change the text of the text box so it would be better to make m_lpszCaption private and have set method to do both jobs at the same time (assign the new value and change the text box's caption) and of course a get method to retrieve the value anytime wanted.
    No I know that but student material and various guides I've read seem to think otherwise. Java is also a prime example of this nonsense, for example http://java.sun.com/j2se/1.3/docs/ap...Dimension.html

  14. #14
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The whole point of OO is to only give access to an interface. The guts should never be exposed. That's why we have skin. Of couse C++ isn't fully an OO language, so there ya go.


    Quzah.
    Hope is the first step on the road to disappointment.

  15. #15
    Registered User
    Join Date
    Mar 2006
    Posts
    9
    Quote Originally Posted by Desolation
    I would see C++ as a side-project of C just like A Perfect Circle is a side-project of Tool's Maynard (their singer). They are difference... yet using a C++ compiler should make you able to compile any C code with little to no modifications *and* of course C++ code. If you want to make 3D games, you want to either do it the hard, custom way using OpenGL and DirectX or use a rendering engine like Ogre or Irrlicht (don't try to pick up on me, I know DirectX isn't only a rendering engine..) which is a lot easier, in my opinion.

    Edit:An alarm just went off. So you've used RPG Maker (or some sort) to make games and now you believe you can make like.. a WoW clone using *simple* languages like C and C++ ? If you want to start with a simple language, start with something like C#, Java or VB. C and C++ are much more likely to give you headaches.

    I said ive used programming before...I didnt say I havnt used other languages...And no I dont "Beleive" anything...I KNOW ill make something great....Ive done coding and programming before...Ive used VBS alot...But i only know the basic of all the language...Right now im figuring out which language to use my make a HUGE game...I have one novice programmer and one professional programmer (but he is at home for another 3 months, they had a baby). Usually he would help us, but he said he doesnt know how much time he has to help anymore now that he has a kid.

    Nobody said I made only RPG's. Ive made 1 MUD, 2 Shooters, 1 MMORPG. I just need to know what coding language is powerful enough for me.

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21