Advertisement

Some troubles with a gamedev tutorial

Started by March 06, 2003 06:46 AM
6 comments, last by taZman 21 years, 8 months ago
Hello, I am new to the world of game programming and gamedev...I have been reading some of the posted articles/tutorials as of late and have run into a bit of an issue with one of the examples..Game Programming Genesis: Adding Characters in particular...I pulled down the example that accompanies this article and have looked at the code and read the article...But, when I try to compile the example (yes, I know that a pre-compiled binary is included) I get 4 compiler errors... [*]characters.h(84) : error C2061: syntax error : identifier ''LPDIRECTDRAWSURFACE7''
[*]characters.cpp(24) : error C2146: syntax error : missing '';'' before identifier ''lpdd7''
[*]characters.cpp(24) : error C2501: ''LPDIRECTDRAW7'' : missing storage-class or type specifiers
[*]characters.cpp(24) : fatal error C1004: unexpected end of file found
Before I get flamed a bit of background...I am not new to programming in general but have recently began learning C/C++ in more detail...I have been programming in visual basic 6 for my company for a little over 2 years...I write code that excercises our circuit packs and typically interact with databases...I have familar with C/C++ syntax but do not know all the ins and outs yet...So a bit of assistance would be greatly appreciated... My first question on this issue is on the line of code in question in the first error ''int LoadBitmap(char *lpszName, int x, int y, LPDIRECTDRAWSURFACE7 lpdds);''...I am not sure on this misterious "*" in front of lpszName I have not seen this used and am not familiar with its purpose...So this leaves me wondering if it truely is supposed to be there? My second question points to errors two and three...These both point back to this line of code ''LPDIRECTDRAW7 lpdd7 = NULL;'' which is the initialization of the variable...This I understand...What I do not get is if there is a reference that is supposed to be made to DirectDraw from within the project? The compiler errors lead me to believe that this is so...If so what are the files I need to reference? Thanks
Did you link the directx7 libraries ?

#pragma comment("dx7.lib",lib)

^^^ something like that
Advertisement
I realized that I had skipped a tutorial and didn''t realize it...This made the difference I hope...I am pulling down the DirectX SDK''s right now...I went ahead and pulled down 8.1b and 9 and will then pull down 7.0...I am curious if I can use 8.1b or 9.0 in place of 7.0 in these articles...I am not sure if these are fully backwards compatible or not...I guess I will find out when I get the SDK''s down and have a chance to read their respective documentation...

Thanks for the quick response...I have a good feeling about this forum/site and expanding my knowledge quickly and effectively
For the most part you cant substitute directx8 for directx7 because they are quite different. Directx8 really doesnt support much 2d and same with 9 but it has improved in 9.

It really depends on what you want to do:

Directx7 = good for 2d
Dirextx8/9 = good for 3d

Thanks for that bit of info...Since this is a new area to me all information is very welcome...It is interesting that 2D is not supported hardly in 8 or 9...Hmmm, but then again 2D games versus 3D games aren''t very exiting for the most part either
ok your getting wrong info time to clarify it for ya!

Yes it is FULLY backward compatible for RUNTIME DirectX so if you had DirectX9 it would run anything made prior.
If you specifically mean the SDK''s , then no, each SDK only supports that One Update. However many features remain the same and used in the same connotation.

As for 3D, You can do ANYTHING in 2d with Directx 7+ versions then you can do before with the seperation between Direct3d and DirectDraw. In fact they made it alot easier to create 2d scenes in my opinion with DirectX 8.1 and 9 then ever before. And alot more power to them as well.
Theres many excellent tutorials on this site that explains how to use DirectX 7+ for drawing 2d scenes still.

as for the * character you referenced, it is used in c++ language as a pointer to the actual memory location of the data, instead of creating a copy of it.
so for Char type if you excluded the * it would only give you a single char storage capacity, with the * is allocated however much it needs to the declaration.
Example:
char *Example1 = "hello";
char Example2 = "hello";

cout << Example1;
cout << Example2;

would give you the output of:
hello
h

since Example2 is a copy it can only hold ONE char type = first Char in string = h
Example 1 is a pointer to memory location, so it assigns as many char types as it needs to fullfill the string asignment.
Basically it is how you create String types in C, and in C++ (if not using your own array of chars, or using CString)

if you need more help on pointers, just let me know, but having yrs experience in VB, im assuming you know what a pointer is

As for the Errors:
Yes you are not including the DirectX librarys in your project.
You have to include them in your files (Which im sure your already doing, especially since there examples)
But..
you also need to include the .lib files to your project itself. This is found under project properties usually depending on what your using.
<=- Talon -=>
Advertisement
uhmmm, just a little further clarification regarding backwards compatibility of the sdks.

you most definitely can build dx7-based applications using the dx8 sdk. i can state this because i am doing it now.

why? because the dx sdks prior to dx8 used a different set of headers and libs. for dx7, you #include ddraw.h and d3d.h (and d3dx.h if using the helper library.) these headers are still available in the dx8 sdk. ditto for the libraries.
Thanks very much for the information...I was thinking yesterday and knew I had seen the infamous ''*'' in code I worked on here at work...But, just never knew exactly why it was there...

I figured that the run-times had to be backwards compatible...Microsoft usually attempts to make most everything backwards compatible to a certain degree...

This topic is closed to new replies.

Advertisement