I started programming today and have some questions?

Alright well i started programming today. i decided to use the C language to start out b/c it sounded the most simple. So right now im learning C through you tube but when i get good at C do i have to learn C+ or C# to understand C++? Also, I am interested in programming games. How do you make a game with code? If you write out everything that is suppost to happen how is it then translated into a first person shooter or a platformer for examples? Is there another program you have to use that uses your code in sprites and animates the whole thing? because write now it just opens in a CMD window when i run my basic code. here is what i did today...

#include <stdio.h>

#include <conio.h>

int main( void ) {

int num1;

int num2;

int sum;

printf( "Type Your Sum Equation Here:" );

scanf( "%d", &num1 );

scanf( "%d", &num2 );

sum= num1 + num2;

printf( "The sum is %d\n", sum );

printf( "Press Any Key To Exit!" );

getch( );

}

now lets say how do i get this to display on a fancy application and not just on the cmd? is that what unity and stuff is for? is it called a game engine? like cry engine? ty sorry i typed so much :D

3 Answers

Relevance
  • 6 years ago
    Favorite Answer

    I'm not really into games so I've never programmed one or used a game engine. However, let me explain the difference between the cmd window, which is text based, and a Graphical User Interface (GUI - "gooey") like Microsoft Windows.

    Programming a GUI, like Windows, is a separate programming topic in itself. So before you can use Windows, you have to know how to program (there are some exceptions though). The cmd window is just text based, you can only display text based characters from the keyboard, or from the extended ASCII character set. So you can't do any graphics in the cmd window, but you can have all kinds of colors for the background and foreground if you want. Since the printf function prints to this cmd window easily, it is what is used when learning to program just so you can see your output for now.

    So how do you output to a regular real window (we will call this regular "real" window a Window from now on). Well your program uses various functions to communicate with Windows (the GUI) just like the function printf sends information to the screen. But Windows has literally thousands of functions used to control it, for setting up the Window and determining the Window type and if it will have vertical and horizontal scroll bars, and the colors and the menus, etc, etc. Not only that, but Windows will talk back to your program, like if the mouse is moved Windows will send a message to that effect to your program. The message will include the time the mouse was moved and the vertical and horizontal coordinates of the new mouse position. Windows will also send a message when there is a key press on the keyboard, and give information as to what key was pressed, etc. And if the user moves the Window, then a message is sent to your program with the new coordinates so the contents of the Window can be redrawn. So as you can see, making your program operate in a Window is much more involved than using the cmd window.

    Now, all of these various functions that you use to interface to Windows are called the Windows API (Application Programming Interface), or formally called the Win32 API. And using the API is like "bare bones" programming. But you really don't need to know the Windows API in order to program for Windows. There are what are called wrapper programs that wrap the Windows API in a program that allows you to more easily implement the Windows GUI in your programs. Windows Forms is an example of such a wrapper, as is Windows Presentation Foundation ( and the older deprecated MFC - Microsoft Foundation Classes). These are like drag and drop programs and more, like Dreamweaver for web page development, which allows you to develop GUI applications or web pages without having to know the underlying code.

    However, if you are serious about game programming, I would at least get familiar with the basics of using the Windows API directly. That way, you will have a better understanding of these wrapper programs. Also, you may need to delve deeper down into the API when using any of these wrapper programs to tweak things up a bit, since these programs have their limitations, but using the API directly gives you the full power of the GUI. An excellent book to get started with is "Programming Windows" by Charles Petzold - ISBN # 1-57231-995-x. It's an older book, but it is still excellent and relevant for learning Windows programming.

    http://msdn.microsoft.com/en-us/library/windows/de...

    Update: Also, just so you know, any program that is running under an operating system like Windows has to work through Windows and all of the layers involved with that. To get the fastest speed possible, you can bypass the operating system all together by simply not using one. Instead of loading Windows, the game program is loaded as the operating system, so then it has direct control of all the hardware and doesn't have to go through Windows to get anything done. So to take advantage of the full power and potential of the machine, have the game loaded in place of the operating system and take direct control of the machine. That's how some of the high end computer games work.

    • ...Show all comments
    • mark_poc
      Lv 6
      6 years agoReport

      Some games DO run without an operating system for maximum speed. They boot up directly into the game environment. Even if not, anyone is free to write such a program
      http://stackoverflow.com/questions/17331390/how-were-games-for-playstation-programmed-with-no-operating-system-at-all

    • Login to reply the answers
  • 6 years ago

    I would suggest learning C# as it is GUI Based and allows you to develop windows applications more easily. For the game engine I would suggest using XNA, I used it when i started out and it helps alot with getting used to coding games. Start off creating some simple 2D games and then grow from there. I found this to be the best way especially if you are planning on teahcing yourself.

    • jake6 years agoReport

      Cool thanks

    • Login to reply the answers
  • Anonymous
    6 years ago

    here's a FREE online book for game programming with Python and Pygame

    Program Arcade Games With Python And Pygame

    http://programarcadegames.com/

    The book was written and is used by a professor for his Introduction to Programming class.

    Since it is an introduction, it assumes no experience. So it starts off at the very beginning.

    Python is a very powerful language

    it is used by MIT in their first few programming courses

    and Python is used by many companies

    (read what some of them have to say about the language)

    www.python.org/about/quotes/

    here's a video of a game one of his student's made

    /watch?v=S7eMdoM1MTc

    https://www.youtube.com/watch?v=S7eMdoM1MTc

    Youtube thumbnail

    nothing too fancy, but pretty impressive for their first game

    here's some more

    http://www.youtube.com/playlist?list=PLUjR0nhln8uZ...

    the Python book is full of videos and code and tells you how to install and get started with Python

    there is also 3 hour tutorial video on the pygame home page

    /watch?v=bMt47wvK6u0

    https://www.youtube.com/watch?v=bMt47wvK6u0

    Youtube thumbnail

    http://www.pygame.org/news.html

    (but starting with the book is easier)

    After you've worked through the book, and watched all the videos and made a few games then you can continue with Python and make more advanced games

    or you can download the Unreal Engine

    and program games in C++

    https://www.unrealengine.com/

    https://docs.unrealengine.com/latest/INT/

    or download Unity 3D

    and start programming with C#

    here's some great tutorials

    https://unity3d.com/learn/tutorials/modules

    you'll find a couple of video playlist tutorials here on C++ and C#

    https://www.youtube.com/playlist?list=PL0EE421AE8B...

    https://www.youtube.com/playlist?list=PLAE85DE8440...

    but I think starting with Python is easiest and quickest

    Python is SO MUCH easier than C, C++ or C#

    (there is no such thing as C+ by the way)

    the C++ videos tells you how to install a C++ compiler and program the C++ language

    the C# videos tells you how to install a C# compiler and program the C# language

    • Login to reply the answers
Still have questions? Get your answers by asking now.