Sign in to follow this  
MDCT

help with Sams Teach Yourself Game Programming in 24 Hours

Recommended Posts

MDCT    112
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

Share this post


Link to post
Share on other sites
MDCT    112
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
MDCT    112
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

Share this post


Link to post
Share on other sites
Adam Hamilton    271
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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 :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
Vegettex    124
What is wrong with the sams book series? I think that it is a decent startup for people who have experience but want to move to another language. They just read the book and know pretty the basics of that new language. Most of the language work the same, though, so you just need to know the new syntax

Share this post


Link to post
Share on other sites
Unknone    100
OK here's a tip. Do NOT use that book. I've used it, and it is rubbish. Once it gets to sprites, you need to download the code unless you have the CD. That wouldn't be a problem but it dosen't explain the code properly after that, so you can't learn to program 2D games properly independently.

Share this post


Link to post
Share on other sites
Unknone    100
By the way, why does everyone make the assumption that "EBook" means pirated? I can see the connection, but why does everyone make the assumption? Just asking...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Unknone
OK here's a tip. Do NOT use that book. I've used it, and it is rubbish. Once it gets to sprites, you need to download the code unless you have the CD. That wouldn't be a problem but it dosen't explain the code properly after that, so you can't learn to program 2D games properly independently.


I find the book rather good.

The good is pretty self explanatory and he does do a good enough job of explaining it. As I said ive modified it to run off of Allegro instead of GDI.

Share this post


Link to post
Share on other sites
Quote:
Original post by Unknone
By the way, why does everyone make the assumption that "EBook" means pirated? I can see the connection, but why does everyone make the assumption? Just asking...


E-Books are very easy to pirate, but oftentimes people who do so are lacking materials that accompany them, so they try to ask here to have them provided.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Run_The_Shadows
Quote:
Original post by Unknone
By the way, why does everyone make the assumption that "EBook" means pirated? I can see the connection, but why does everyone make the assumption? Just asking...


E-Books are very easy to pirate, but oftentimes people who do so are lacking materials that accompany them, so they try to ask here to have them provided.


Not to mention large technical ebooks are quite a pain to read especially coding ones. Most sane people would rather buy a hard copy then buy an ebook copy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this