Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Must know for Game developers.<-Part 1

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
benlue
Moderator
Reputation: 0

Joined: 09 Oct 2006
Posts: 2142

PostPosted: Tue Apr 03, 2007 2:00 am    Post subject: Must know for Game developers.<-Part 1 Reply with quote

If you guys read my other post , it was short and pretty much basic .
I feel that the community of game developers need to know how to actually comprehend the basics .
Please read on .
If anyone wants the Quake 2 source code , i wouldn't mind posting it up . <needs 10 people at least>

This isn't useless as many people out there have thought of making a game or started unsuccessfully . (Trust me)

Getting Started
Using Windows programs
Resources is very important .
Simple resource script: (please study it)
Code:
#include "resource.h"

// icons
ICON_MAIN     ICON    myicon.ico

// bitmaps
IMG_TILESET1  BITMAP  tileset.bmp
IMG_TILESET2  BITMAP  tileset2.bmp

ICON_MAIN and IMG_TILESSET are numeric strings for the confused people out there .

Windows is apart of all of us ( tell me waht the code does .hints)
Code:
WNDCLASSEX sampleClass;                                    // declare structure variable

sampleClass.cbSize =        sizeof(WNDCLASSEX);            // always use this!
sampleClass.style =         CS_DBLCLKS | CS_OWNDC |
                            CS_HREDRAW | CS_VREDRAW;       // standard settings
sampleClass.lpfnWndProc =   MsgHandler;                    // message handler function
sampleClass.cbClsExtra =    0;                             // extra class info, not used
sampleClass.cbWndExtra =    0;                             // extra window info, not used
sampleClass.hInstance =     hinstance;                     // parameter passed to WinMain()
sampleClass.hIcon =         LoadIcon(NULL, IDI_WINLOGO);   // Windows logo
sampleClass.hCursor =       LoadCursor(NULL, IDC_ARROW);   // standard cursor
sampleClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);  // a simple black brush
sampleClass.lpszMenuName =  NULL;                          // no menu
sampleClass.lpszClassName = "Sample Class"                 // class name
sampleClass.hIconSm =       LoadIcon(NULL, IDI_WINLOGO);   // Windows logo again


This is used to handle the cursor which is currently loading:
Code:
HICON LoadIcon(
    HINSTANCE hInstance,  // handle to application instance
    LPCTSTR lpIconName    // icon-name string or icon resource identifier
);

HCURSOR LoadCursor(
    HINSTANCE hInstance,   // handle to application instance
    LPCTSTR lpCursorName   // name string or cursor resource identifier
);


HINSTANCE hInstance: This is a handle to the instance of your application. To load resources from your program, just pass the HINSTANCE that is passed to your WinMain() function when the program is executed. To use standard Windows resources like we did in the window class above, set this to NULL.

LPCTSTR lpIconName, lpCursorName: This is a string identifier that identifies the resource you want to load. If your script file refers to resources by string, simply pass the string. But if you're using numeric constants, the Windows header files include a macro that changes an integer to a form compatible with this parameter called MAKEINTRESOURCE().

The icon:
Code:
#include "resource.h"

ICON_MAIN     ICON    myicon.ico
CURSOR_ARROW  CURSOR  arrow.cur


Part 2
Bitmaps
Including bitmap resources is probably the easiest way to add images to your program .

It's exactly what you're thinking: a giant table full of strings. There are any number of purposes for using a string table. You can use it to store data filenames, character dialogue for a game, message-box text, text for menus that are generated by the program, anything you want. Creating a string table in your script file is easy. Here's what it looks like:
Code:
STRINGTABLE
{
// entries go here
}


An entry in a string table consists of a number to identify the string, followed by a comma, then the string itself, enclosed in double quotation marks. The strings in a string table can include escape sequences like \n or \t. Note that the string table itself does not have an identifier, so each program you write can include only one string table. A simple string table might look something like this:

Code:
// program information
STRINGTABLE
{
1, "3D Space Game v1.0"
2, "Written by The Masked Coder"
3, "(C) 2000 WienerDog Software"
}


To load a string from your program's string table, you use the -- you guessed it -- LoadString() function. Here it is :
Code:
int LoadString(
    HINSTANCE hInstance,  // handle to module containing string resource
    UINT uID,             // resource identifier
    LPTSTR lpBuffer,      // pointer to buffer for resource
    int nBufferMax        // size of buffer
);

The integer returned by the function is the number of characters, excluding the terminating null character, that were successfully copied into the buffer. This corresponds to the length of the string. If you load a blank string, or if the function fails, the return value is 0. Take a look at the parameters:

Code:
HINSTANCE hInstance
: Once again, this is the instance of your application .

Code:
UINT uID
: This is the number that identifies the particular string you want to load.

Code:
LPTSTR lpBuffer
: This is a pointer to the location you want the string copied to.

Code:
int nBufferMax
: This is the size of the buffer in bytes. If the string to be loaded is longer than the buffer can hold, the string is truncated and null-terminated.

Third Chapter
Menus/Consoles
This is the last type of Windows resource I'll go over, and it's also one of the most useful. Menu resources are used to define the menu bar that would appear underneath the title bar of your application, and are loaded during the definition of the window class. Looking back, in the window class we developed during the last article, there was a line that looked like this:

Code:
sampleClass.lpszMenuName = NULL;


If you're creating a windowed application, chances are that you'll want to have a menu bar of some sort. This is done using the menu resource. The script file entry for this one can get a little complicated, but here is its most basic form:

Code:
[identifier] MENU
{
    POPUP [menu name]
    {
        MENUITEM [item name], [identifier]
    }
}


The identifier is what you're used to: either a string or a numeric constant that is used to refer to the menu. Within the MENU brackets, there can be one or more POPUP menus, each of which represent a pull-down menu, whose name is given by [menu name]. Within the POPUP brackets, there can be one or more MENUITEMs, each of which represents a final menu selection, with a name given by [item name] and an identifier that must be a numeric constant. Within the menu and item names, if you want that option to be accessible by a keyboard shortcut, you precede the letter of the shortcut with the ampersand (&). For instance, if you want to create a File menu accessible by pressing Alt+F, the menu name should be &File. Menu and item names should be enclosed in double quotation marks. With that, here is an example of a simple menu resource:

Code:
MAIN_MENU MENU
{
    POPUP "&File"
    {
        MENUITEM "&New",        MENUID_NEW
        MENUITEM "&Open...",    MENUID_OPEN
        MENUITEM "&Save",       MENUID_SAVE
        MENUITEM "Save &As...", MENUID_SAVEAS
        MENUITEM "E&xit",       MENUID_EXIT
    }
    POPUP "&Help"
    {
        MENUITEM "&Contents",   MENUID_CONTENTS
        MENUITEM "&Index...",   MENUID_INDEX
        MENUITEM "&About",      MENUID_ABOUT
    }
}


You can also create submenus by including one POPUP inside of another, specify menu items as being initially grayed or checked, or do several other more advanced things, but I'm not going to go into that here. To obtain a handle to a menu resource, use the LoadMenu() function whose prototype is shown here:

Code:
HMENU LoadMenu(
    HINSTANCE hInstance,  // handle to application instance
    LPCTSTR lpMenuName    // menu name string or menu-resource identifier
);


As you probably remember, Windows messages are handled by a special callback function usually called WindowProc() or something similar. The simple one we wrote last time was called MsgHandler(), and its prototype looked like this:

Code:
LRESULT CALLBACK MsgHandler(
    HWND hwnd,     // window handle
    UINT msg,      // the message identifier
    WPARAM wparam, // message parameters
    LPARAM lparam, // more message parameters
};


PLEASE CHECK OUT PART 2 .
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Tue Apr 03, 2007 5:12 am    Post subject: Reply with quote

ftp://ftp.idsoftware.com/idstuff/source/quake2.zip
Back to top
View user's profile Send private message MSN Messenger
benlue
Moderator
Reputation: 0

Joined: 09 Oct 2006
Posts: 2142

PostPosted: Tue Apr 03, 2007 5:16 am    Post subject: Reply with quote

noz3001 wrote:
ftp://ftp.idsoftware.com/idstuff/source/quake2.zip
Saved my time . Thanks . Smile
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Apr 03, 2007 11:45 am    Post subject: Reply with quote

I think there is a limit on how many letters you can put in one post
_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Tue Apr 03, 2007 3:57 pm    Post subject: Reply with quote

forum software doesn't let you make consecutive posts without having someone else reply Sad
_________________
Back to top
View user's profile Send private message
benlue
Moderator
Reputation: 0

Joined: 09 Oct 2006
Posts: 2142

PostPosted: Tue Apr 03, 2007 11:04 pm    Post subject: Reply with quote

x0r wrote:
I can't believe how f*cking stupid and pathetic you are. Stop the spamming and delete all the other parts and next time, put them all into one topic.
It would be too long ...

EDIT: I put all in one topic and it got cut-off . So i can't put it into one topic . Rolling Eyes
Back to top
View user's profile Send private message
ravicus
Master Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 464

PostPosted: Tue Apr 10, 2007 8:14 pm    Post subject: Reply with quote

Looks like x0r has been a mod too long. He doesn't even know about the double post rule.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites