Some questions

Started by
7 comments, last by Will F 18 years ago
Can I write C# programs in Borland compiler ect.? What exactly is a library? Whats all it used for? Direct X is this a Game Programming language? //Beginning Game Programming //Chapter 2 //Hello World Program #include <window.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR 1pCmdLine, int nShowCmd) { MessageBox(NULL, "All of your base's Belong to me!", "Hello World", MB_OK | MB_ICONEXCLAMATION): } Ok now I know this is a hello program, but exactly what am I looking at here? Can some one be oh so kind is to break the lines down and explain this to me? all help well appreciated
Advertisement
Quote:Original post by cocaroach
Can I write C# programs in Borland compiler ect.?
What exactly is a library? Whats all it used for?
Direct X is this a Game Programming language?


//Beginning Game Programming
//Chapter 2
//Hello World Program
#include <window.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR 1pCmdLine, int nShowCmd)
{
MessageBox(NULL, "All of your base's Belong to me!",
"Hello World", MB_OK | MB_ICONEXCLAMATION):
}




Ok now I know this is a hello program, but exactly what am I looking at here? Can some one be oh so kind is to break the lines down and explain this to me?

all help well appreciated


I wouldn't know about C#. I haven't really looked at it yet. I think it's the latest version of C++ with variations or something.

DirectX is a library I guess.

that code means:
#include <window.h> - include the Win32 API I think

int WINAPI WinMain - WinMain function. Starting point for all Windows Programs.

(HINSTANCE hInstance, - Not quite sure, but to my knowledge, it means "occurance" basically

HINSTANCE hPrevInstance, - Previous instance

LPSTR 1pCmdLine, - can't remember

int nShowCmd) - can't remember

{ - starts scope

MessageBox - Message Box function. Creates message box.

(NULL, - Window (HWND)

"All of your base's Belong to me!", - Text to be displayed in box

"Hello World", - Title of box

MB_OK | MB_ICONEXCLAMATION); - box features. MB_OK means OK button only. MB_ICONEXCLAMATION means exclamation mark on side
} - end scope

Hope I helped! Sorry about it not quite being easy to read.



Regardz,UnknoneCheck out my site! Click Here!
I believe C# is only supported in Visual Studio.NET, however Microsoft is currently allowing free downloads of the 2005 express edition.

A library has various possible meanings. The most general way to describe it would be 'A collection of functions and classes'

DirectX is a complete multimedia API. While it is primarily focused on games, there's nothing stopping you from using it for other projects.

Line 1-3: comments
Line 4: the #include directive tells the preprocessor to inline the contents of the header listed
Line 6: [Return Type][Call Type][Function Name]([Parameter type][Parameter name],etc
Line 7: [Parameter Type][Parameter Name], etc)
Line 8: The brace denotes the start of a block of code
Line 9 & 10: The MessageBox function creates a message box using the parameters given it. My Win32 API is rusty, but I believe the first parameter is the parent window, the second is the window title, the third is the window text, and the fourth is the window style. Note that the '|'(bitwise inclusive OR) operator allows the function to merge multiple styles
Line 11: The closing brace

Honestly I expect you're not going to understand the vast majority of that description, so you should should probably go back to chapter 1 and read more about the syntax of C style languages, or find another book or resources to explain it to you. I'd recommend Here
Hey cocaroach, welcome to GDNet :-).

If your compiler is Borland C++ then no you can't. I recommend you download Visual C# Express - it's free! Click here.

A library basically allows you to do more than what the language by itself allows you to do. For example, if you wanted to work with 3D graphics in your application then C# simply can not do this on its own, it needs a library/API to allow it to do it. There are many libraries out there, and 99% of them are free.

DirectX is a library that allows you to do many things. Although it's commonly used within game development for Windows systems, that's not all it's used for. DirectX allows the programmer to do many things that a stand-alone programming language (such as C#, C++, Java etc.) simply wouldn't allow them to do. The DirectX API (library) allows the programmer to do various things, such as: work with 3D/2D graphics with Direct3D, work with 2D graphics specifcally with DirectDraw, work with networking with DirectPlay, work with mouse, keyboard, joystick and gamepad inputs with DirectInput and audio with DirectSound (3D and 2D audio). This is a very small list of what can be achieved with DirectX, but you get the idea.

I don't have the time to break down the code for you, but it's a Windows application using the Win32 API. It's in C++ by the way.

I recommend you stay away from areas such as libraries, DirectX and the Win32 API until you're confident with advanced topics within the language of your choice. Start right from the bottom, create small applications and then gradually work your way up. Text-based games such as guess the number, pong, breakout, hangman and tetris are all great for getting you started.

Best of luck to you :-).
c# is part of the microsoft .net framework- im afraid only M$ products can compile this (though you can write the code in the DOS editor if u want u just have to use visual studio to make it into a program)

A code library is a set of usefull functions/classes that you put in a file / set of files for use multiple projects- its to stop you re-inventing the wheel everytime u make a project.. You can also download librarys that other people have written

Direct X is whats called an API (Application program interface) You can use it in your code to interact with the hardware in a machine.. Its very nice because it allows you a common interface to all direct x compatable hardware (what isnt nowadays??)
Its not a language- but you need to learn a lot of funky syntax to use it (which depends of course on the language you are using it with) ;)



//Beginning Game Programming
//Chapter 2
//Hello World Program
#include

this is where they include the windows library- basically a bunch of structs/classes/functuions that let u make pretty windows applications instead of the lovely console apps ;)

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR 1pCmdLine, int nShowCmd)
//If youve done C/C++Console... this is the windows equivalent to the 'main' function
Every program has a function that it enters into.. for windows its this one- basically your code starts here!
The parameters are for you to use in ur app (warning these are from memory and i havnt done windows programming in a while)
HINSTANCE hInstance is whats called a 'handle'- it lets u identify your program
HINSTANCE hPrevInstance is not used ;)
LPSTR lbCmdLine is a pointer to the command line args that were provided to your application (i.e. yourapp.exe -a testing!)
int nShowCmd is an int telling you how ur app shoudl display on start up
The WINAPI bit is just to tell the compiler ur doing a windows function (i think its because they do something weird with the parameters :S)
return type of the function is always int
{
MessageBox(NULL, "All of your base's Belong to me!",
"Hello World", MB_OK | MB_ICONEXCLAMATION):
this function is part of the windows library that puts up a msgbox with a geeky title for which the author needs to be shot ;)
content of "Hello World!"
the other parameter are option flags
most windows function takes these, they are binary bit patterns that you can bitwise or together to choose mutiple... now in english :P
You can specify as many as you want with a | between them and they affect what the function does.. to get a list of these for each function i reccomend google/the msdn ;)
}

hope that helped you :)
Quote:Original post by cocaroach
Can I write C# programs in Borland compiler ect.?

You can with the Borland C# IDE, but changes are you are better off using the Microsoft Visual Studio .NT 2005 Express edition. This can be found here and is 100% free of charge.

Quote:
What exactly is a library? Whats all it used for?

A library is simply a collection, or 'library', of what are called functions and objects. Compare it to a book library where you can go in and get a certain book. A programming library is the same, whereas instead of books, you go in a get a function or an object.

Quote:
Direct X is this a Game Programming language?

No, this is a Multi Media Programming API. It can be used for all sorts of applications, not just games. It consists of multiple components such as Direct 3D, Direct Music and Direct Play, amongst others. Visit the official Direct X home page here for more information.

The source code that you have posted is in a language called C. Because you want a line by line explanation of this, chances are that you do not know this programming language. My suggestion though, as you have mentioned C#, is to either learn that. But if you have bought this book, then learn C so as to now be wasting money. In order to learn these languages, post here on GameDev.net and Google such things as 'C++ tutorials' or 'C# tutorials'. You will find these very useful!

I'll give a quick overview on this code because you did ask [smile]

Quote:
//Beginning Game Programming
//Chapter 2
//Hello World Program

The above is what is called a comment. This is normally a description of the code that is below it.

Quote:
#include <window.h>

This 'includes', or pastes in, extra code that is in a file called 'windows.h'. This file provides useful function prototypes and structures like those seen below (I respect that you probably don't understand this description)

Quote:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR 1pCmdLine, int nShowCmd)

The entry 'function'. This is the portion of code that the program will always start in.

Quote:
{

Indicates the begining of the above function

Quote:
MessageBox(NULL, "All of your base's Belong to me!",
"Hello World", MB_OK | MB_ICONEXCLAMATION):

This is a function. It displays a message box, much like what you have seen before, on the screen with an 'OK' button and an Exclamation mark icon with the text "All of your base's Belong to me!"

Quote:
}

Indicates the end of the above function.

Although you will more than likely not understand much of what I have described, you will as you learn about C or C#.
Also, you should start of with Console Applications. I have a really good book on this that leads you from hello world to Blackjack in Console Apps. It's called "Premier Press - Beginning C++ Game Programming". This is where I started programming, and am very happy that I did. It's worth doing before learning any Windows Apps.
Regardz,UnknoneCheck out my site! Click Here!
Well I bought a book yesterday called beginning Game Programming by Jonathan S. Harbour. All of the programs are written in C++, but earlier today some where I read where it is easier to start out with something like C#. Yes all of the code break down which I appreciate is very confuesing"dont understand". But anyhow thanks for allthe help guys.
Quote:Original post by Anonymous Poster
c# is part of the microsoft .net framework- im afraid only M$ products can compile this


What about Mono?

Which by the way is included in Fedora Core 5 (and probably other linux distros i'm unaware of).

This topic is closed to new replies.

Advertisement