Results 1 to 40 of 40

Thread: C++ gaming

  1. #1

    Thread Starter
    Addicted Member Osiris's Avatar
    Join Date
    Oct 2000
    Location
    Dimension Hole
    Posts
    142

    Exclamation C++ gaming

    i'm a newbie with C++ and i would like to ask something...
    is it possible to program games in C++??
    cause i can only program in that black window that only displays
    words...
    ؊Ϯϊ

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Yes, it most certainly is. C or C++ are the languages of choice for most game developers.

    I guess you are talking about the console window that you can use for input and output in your Win32 Console Application projects. They are really useful when you only need a very simple interface for your app, like command-line stuff. They are also very good when you are learning the language because it keeps the interface nice and simple and allows you to concentrate on the code you write to go behind the interface - the main application logic.

    If you want to write games that use an interface other than the command line, you need to learn about the API of another style of interface for your game. That can be:

    • Win32 APIs - this is fairly simple to learn (not that simple for anyone new to programming though) but is also pretty slow compared to other APIs. Good for stuff which isn't pushing the limits of your computer's performance when you want simple code.
    • X Windows APIs - this is basically the same as the Win32 APIs but for X Windows, which is the most common Linux/Unix windowing system. Good if you're not using Windows
    • DirectX APIs - this is Windows-specific and is more complicated than the standard Win32 APIs. It's also much lower level and faster. Contains many different APIs for input, graphics, sound, networking and so on.
    • OpenGL - this is an open-standard, well-established graphics API. Performance-wise and complexity-wise it's basically the same as DirectX Graphics. It has the benefit of being platform-independant.


    For games programming advice (especially in C/C++) you might want to try www.gamedev.net or www.flipcode.com .
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Addicted Member Osiris's Avatar
    Join Date
    Oct 2000
    Location
    Dimension Hole
    Posts
    142
    HarryW,

    thanx for the reply,
    yeah i was talking about the console window
    but how do you add pictures to C++ like you do in VB?
    or do you have to open it from the file?
    ؊Ϯϊ

  4. #4
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    Whoa whoa, you obvious have the wrong idea. Visual Basic was written in C++. If you want to draw a picture on the screen you need to use special header files that call APIs that will in turn draw pixels etc. You don't build GUI's visually in C++. You have to map out all the coordinates, width, etc. then render them on the screen through code.

    C++ is all code. There is no drag and drop, or insert image options.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Well, you can use CreateWindow to get a button, fairly simple.

    It's not as low level as all that.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    It isn't hardly low level, but maybe I'm talking too much about game programming, which I thought was the topic. For gaming you need to get low level to get bettter performance. However, windows API isn't nearly that difficult, but you still need to provide it's functions, etc. with the appropriate arguments.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by JaredM
    It isn't hardly low level, but maybe I'm talking too much about game programming, which I thought was the topic. For gaming you need to get low level to get bettter performance. However, windows API isn't nearly that difficult, but you still need to provide it's functions, etc. with the appropriate arguments.
    Maybe. But for a lot of game programming, by its very nature the final output method is abstracted away.

    Just talk to kedaman about device independence
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    Yep.

  9. #9
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    Is the windows API hard to learn?
    [p r a e t o r i a n]

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Smile Good thing about C++

    Is that it supports Generic Programming, You don't need to get down dirty to lowlevel and do **** and screw all paradigm just because of some small performance gain. C++ is the language where you build layers upon layers of interfaces which you can model into a code that is totally device independent, the timecritical blocks will be safely behind bottomlevel layers and no paradigm polution will prevent you from building your software empire, fast with safe reusable and easy OOP and highly reusable and efficient Generic Programming.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by [praetorian]
    Is the windows API hard to learn?
    No, but it takes a lot of time and worst thing is it's functional style. I'm working on a easy to use OOP version of it with a little help from parksie
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Definitely a little

    Although its functional style is a necessary by-product of the fact that it is the lowest layer, as far as your programs are concerned. Even people who program in asm call on the Win32 API.

    So, what I'm supposed to be doing is converting the API declarations into a slightly more generic-friendly interface, while ked does the real thinking
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    I'm just about to decide whether to buy Petzold's Programming Windows with the API or to get Programming windows with the MFC by Jeff Proise, I posted that question today in a new thread:
    http://www.vbforums.com/showthread.p...hreadid=123176

    The problem is thou, that I do not know so much C, but I know c++, is it possible for me to understand that book despite this?
    And be able to write programs that use API after having read that book?

    thanx!
    [p r a e t o r i a n]

  14. #14
    Zaei
    Guest
    Hehe, here is something I KNOW =).

    As kedaman said, abstraction layers are fun. At the moment, my engine has places where the abstraction goes 8 levels deep to actually get to a rendering API (Direct3D in this case), spanning 2 DLLs. I use a time tested method for combating dangling pointers, HANDLEs. You get a HANDLE for each object. You pass the HANDLE to a DLL function, which attempts to get an object. The function it tries to get an object from checks the handle, and gives out the pointer if the handle is correct, etc, etc.

    The abstraction hides all of the evil implementation stuff away from me (i hardly touch anything closer then 3 levels up from the bottom).

    The only problem with this is that it is more intuitive to create a C like interface. I then will have to wrap that up into classes (there is another layer).

    It is fairly easy to program games, or other graphical applications using C++. You just have to understand a couple of API things. I started DX in VB, then learned how to create a window... and VB went out the window. C++ is far cleaner to use, in my opinion.

    Z.

  15. #15
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's not what we meant.

    The idea is that you use templates, so all the abstraction is at compile-time (i.e. minimal or no performance penalty).

    For example, you have constant types that resolve to an int, but you can't combine them (the compiler complains). Basically it's to stop you from being an idiot, and hopefully cut down on debugging time.

    Kedaman - was that a good enough understanding of your quest for global domination?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  16. #16
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    pretty good but the power of the crystal clear paradigm of OOP is still in my head that is waiting for it's release; where objects are parameterized from interconnective units to dimensions and as nested modifier streams for further parameters and not to forget parameterization for purpose as functors to compact all activity into safe types. And then it will be borkification, a revolution for us all

    Zaei, polymorphism is good, just don't let it become an overhead in time critical procedures, whenever possible whenever you don't need to change layers at runtime you can use pseudo polymorphism using templates
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  17. #17
    Zaei
    Guest
    It's pretty fast. All rendering is done inside of one DLL, the same one where the objects are stored. This allows quick access directly into a vector with only a single HANDLE check. All Objects have a Render() function, so When I call RenderObject() the handle is pushed onto a stack, and when the scene is finished, everything is drawn in one go. I have ~0ms render time, with several thousand triangles (my card isnt so good, so thats a good number =).

    Oh, and the Handle Check is inline.

    Z.

  18. #18
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Do as you wish There's avoidable cpu cycles in the virtual function calls
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  19. #19
    Zaei
    Guest
    Virtual functions are my friend =).

    Z.

  20. #20
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    Virtual function?

  21. #21
    Fanatic Member petrus's Avatar
    Join Date
    May 2002
    Location
    pBytes[sizeof(pBytes)/2]
    Posts
    553
    There is a MUCH easier way to make windows with C++:
    MFC!!! (Microsoft Foundation Class)
    The MFC "Hides" all the rough code.
    And in Visual C++ 6 you can make a window almost exactly the way you do it in Visual Basic.
    ICQ: 128716725

  22. #22
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    MFC? Ugh.

    /slap

    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  23. #23
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    *double slap*

  24. #24
    Fanatic Member petrus's Avatar
    Join Date
    May 2002
    Location
    pBytes[sizeof(pBytes)/2]
    Posts
    553
    What???? MFC is easy!
    Do you make windows the hard way?
    ICQ: 128716725

  25. #25
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    API was easier for me when I still used Windows, yeah.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  26. #26
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Look, Ive never posted in this thread before! o.O

    MFC, a wonderful example of the sacrifice of speed, size and flexibility for ease of use.

    Z.

  27. #27
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    just might be easier to use vb in that case

  28. #28
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by kedaman
    No, but it takes a lot of time and worst thing is it's functional style. I'm working on a easy to use OOP version of it with a little help from parksie
    Really? I thought you've given up that project in favor of squirrel?!
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  29. #29
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by kedaman
    pretty good but the power of the crystal clear paradigm of OOP is still in my head that is waiting for it's release; where objects are parameterized from interconnective units to dimensions and as nested modifier streams for further parameters and not to forget parameterization for purpose as functors to compact all activity into safe types. And then it will be borkification, a revolution for us all
    *BANG* (head explodes...)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  30. #30
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I like MFC, yet I would never dare to recommend it to a programming newbie.

    MFC is somewhere in-between VB and pure API. Not as bloated as VB and faster, with the full power of C++ behind its back, but not as clean, small and fast as pure API. But it's harder to learn than VB, and even though you can use it without knowing the API doing so will sooner or later result in problems. I'd be terribly lost by know had I never learnt the API, even though I mostly use MFC for app development.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  31. #31
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by kedaman
    worst thing is it's functional style
    I can't believe i'm saying this

    wait a minute, when did I post this?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  32. #32
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    A long time ago.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  33. #33
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    its all coming back now.. memories, hehe this was even before i came up with the generic expression templates
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  34. #34
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, only later realized how old this thread is...

    Who brought this back to the front? Zaei?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  35. #35
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    petrus.

    Probably the result of a search, that's how most of them happen. Over at the antionline forums, they have a feature whereby the dates are wrapped in <blink> tags if they're older than a set period, which is quite nice.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  36. #36
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    We should recommend that over at Galahtech, it might be useful in a few months...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  37. #37
    Fanatic Member petrus's Avatar
    Join Date
    May 2002
    Location
    pBytes[sizeof(pBytes)/2]
    Posts
    553
    Yeah I searched for something and found this one...
    ICQ: 128716725

  38. #38
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Originally posted by parksie
    petrus.

    Probably the result of a search, that's how most of them happen. Over at the antionline forums, they have a feature whereby the dates are wrapped in <blink> tags if they're older than a set period, which is quite nice.
    <blink> tags don't do anything for me... maybe it should be put in a <marquee> tag.
    <removed by admin>

  39. #39
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Originally posted by CornedBee
    Yes, only later realized how old this thread is...

    Who brought this back to the front? Zaei?
    Ive enough to do without bringing up old topics! =)

    Z.

  40. #40
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Don't know, I just looked which post had the least connection with the others. I deemed it unlikely that you would really have done it, but stranger things have happened.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width