help with Sams Teach Yourself Game Programming in 24 Hours

Started by
14 comments, last by GameDev.net 18 years, 1 month ago
this is an e-book so i cant say what page it is but its "Building the Skeleton Example Program" heres the code: ************** Skeleton.h **************************************** #pragma once //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include <windows.h> #include "Resource.h" *************** Skeleton.cpp ************************************** //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include "Skeleton.h" //----------------------------------------------------------------- // Global Function Declarations //----------------------------------------------------------------- LRESULT CALLBACK WndProc(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam); //----------------------------------------------------------------- // Global Functions //----------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT("Skeleton"); WNDCLASSEX wndclass; HWND hWindow; MSG msg; // Create the window class for the main window wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SKELETON)); wndclass.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SKELETON_SM)); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szAppName; // Register the window class if (!RegisterClassEx(&wndclass)) return 0; // Create the window hWindow = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); // Show and update the window ShowWindow(hWindow, iCmdShow); UpdateWindow(hWindow); // Enter the main message loop while (GetMessage(&msg, NULL, 0, 0)) { // Process the message TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; } LRESULT CALLBACK WndProc(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam) { HDC hDC; PAINTSTRUCT ps; RECT rect; switch (msg) { case WM_PAINT: // Draw some text centered in the client area of the main window hDC = BeginPaint(hWindow, &ps); GetClientRect(hWindow, &rect); DrawText(hDC, TEXT("This is a skeleton application!"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hWindow, &ps); return 0; case WM_DESTROY: // Exit the application PostQuitMessage(0); return 0; } return DefWindowProc(hWindow, msg, wParam, lParam); } ************* Resource.h ***************************************** //----------------------------------------------------------------- // Icons Range : 1000 - 1999 //----------------------------------------------------------------- #define IDI_SKELETON 1000 #define IDI_SKELETON_SM 1001 ************* Skeleton.rc ***************************************** //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include "Resource.h" //----------------------------------------------------------------- // Icons //----------------------------------------------------------------- IDI_SKELETON ICON "Skeleton.ico" IDI_SKELETON_SM ICON "Skeleton_sm.ico" ******************************************************************** the compile works ok but when its time to build i get this: --------------------Configuration: Skeleton - Win32 Debug-------------------- Compiling resources... C:\Documents and Settings\Skeleton.rc (9): error RC2135 : file not found: Skeleton.ico C:\Documents and Settings\Skeleton.rc (10): error RC2135 : file not found: Skeleton_sm.ico Error executing rc.exe. C:\Documents and Settings\Skeleton.rc(9): Could not find the file Skeleton.ico. C:\Documents and Settings\Skeleton.rc(10): Could not find the file Skeleton_sm.ico. Skeleton.exe - 2 error(s), 0 warning(s) ********************************************************************** its supposed to be just a simple blank window but i cant figure out the .rc file i am a beguinner so be gentle ;) i may need a more detail explanation,thank you very much for any help
Advertisement
1. Pirating books is bad
2. There was a thread almost exactly like this one less than a week ago
3. SAMS books suck. Read real books instead.
4. Learn how to use google
its not pirated book,i have a subscription ;)


anyways i have several books but i know i am doing something wrong with the compiler and not the code because i keep getting a few messeges like theres no file association or .rc files errors.........thats the only thing keeping me from progressing

thanks for the advice anyways :)

somebody help
Quote:Original post by MDCT
its not pirated book,i have a subscription ;)


anyways i have several books but i know i am doing something wrong with the compiler and not the code because i keep getting a few messeges like theres no file association or .rc files errors.........thats the only thing keeping me from progressing

thanks for the advice anyways :)

somebody help


SAMS has an online support area for their books.
its an e-book so i dont have that USBN code

like i said before i have alot of books and theres no explanation on the rc files,if i run the files from the CD they work but when i write the code,or even copy and paste,i end up with some trouble with the rc file.........i am doing something wrong,its probably something simple but i dont know much about the visual C++ 6 compiler,hence i have no clue what to do with the rc file,wich is what i am asking for help

thanks anyways
Forget the SAMS ebook...

If you have Visual C++ 6.0 and above then you can create a skeleton app by creating a Win32 project, click on Windows Application option and make sure that Empty Project is unchecked

It seems that everyone has forgotten the errors you posted.

What is happening is that the resource compiler is looking for two sets of icons. One is the application icon (Skeleton.ico) 32x32 size which you will see when you view your .exe in a folder and the other (Skeleton_sm.ico) 16x16 size which is the icon used in the titlebar on the left.

You can create these with an icon editor or if you have Visual Studio 6 (or .NET (not version 8)) you can create one in it's icon editor.

Hope this helps you out.

hi I have read that book twice and honetly feel its a pretty good introduction,however it is easy to get bogged in the code, good luck in your studies
Hi there

It would seem that the .ico files have beeen included in the VC++ project as resources, and when u copy paste / type the code into a new project its not bringing the resources with it

Visual Studio lets you put images/icons etc into the project and compile them into the application

see this link on the msdn
http://msdn2.microsoft.com/en-us/library/7zxb70x7(VS.80).aspx
(or if the direct link doesnt work google: "visual studio" "including resources" )

Of course I could be way off (im not a guru myself ;) ) but hopefully this will help you :)
The book is a great book to get started with

Anyways, doa google search on the author's name and you will find his website which contains all the code.

And I like his game coding style, some of the code seems a bit "slow" to me, but otherwise the concepts are good and the engine you develop can be made to work with other libraries. Im working on an extremely updated version of the original engine using Allegro. In fact the engine no longer looks anything like the original one, but the book does teach you good coding techniques for games.
BTW you can probablly find this book or similiar ones at your local library, ive taken out about 6 books on Game coding and OpenGL so far from my library!g

This topic is closed to new replies.

Advertisement