• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Teej

02.07 - The Readiness Test

215 posts in this topic

Oh Goody, Code Time! Alright recruits, we’re about to test your compiling and linking skills. I’ve added a zipfile called BASECODE1 on my website that I’d like you to download now (don’t unzip it yet though!). The zipfile contains the following files:
  • Globals.h – the main header file for the game template
  • WinBase.cpp – the windows application overhead we’ve discussed
  • InitTerm.cpp – the initialization/shutdown functions
  • GameMain.cpp – where the game code goes
  • Utils.h – prototypes for our helper functions
  • Utils.cpp – the helper functions themselves
  • Resource.bmp – a sample bitmap
  • Sample.wav – a sample WAV file
Once you have this file in your possession, it’s time to create a project for our game template. Folks, the following discussion pertains specifically to those using the Microsoft Visual C++ (MSVC) IDE (a part of Microsoft Visual Studio). If you’re doing something else, you might need to raise a fuss by replying to this article if you need assistance. Create a New Project To create a project, Choose File|New , and select Win32 Application from the list of project types. Provide a name and location for this project (BaseCode1 would be a good idea) and let the IDE create an empty project for you. Once it’s done, there will be a new directory created for you with some standard project files already there. This is where we’d like the BaseCode1 files to end up, so go ahead and unzip the archive to there. The end result is that you’ll have a single directory (perhaps called BaseCode1 ) that contains all of these files. Adding these files to our new project involves nothing more than selecting the FileView tab on the bottom left of the IDE (or wherever you placed the project view) and right-clicking on BaseCode1 files . Add them all in by selecting them and there you have it! Ah, but wait! We’re not ready to attempt building the project yet. A couple more steps are involved. Tell the IDE Where to Look Move to Tools|Options|Directories , and you’ll see a list of locations that the IDE searches through when looking for project files. We’re not talking about our files here – they’re all in the project’s directory and therefore easy for the IDE to find. No, what the compiler is really going to have a hard time finding without our help is all of the DirectX header files that we intend to use. So, here’s what you do. Where did you install your DirectX SDK? Mine is at C:\DXVCSDK , so I’ll use that as an example (substitute with your own). All of the DirectX header files are located in the INCLUDE subdirectory, so you’d add an entry like this to the list: C:\DXVCSDK\INCLUDE Now that you have it in the list, and this is very important, move the entry up until it’s the very first one. The reason for this is because MSVC comes with some older DirectX header files, and if the IDE looks in the MSVC default directories before trying yours, things will be screwed-up. Tell the Linker Where to Look The IDE may now know where all of the header files are (in our project directory and in the DirectX SDK include directory), but it also needs to know where the ‘real’ DirectX code libraries are. After all, the header files only contain prototypes (kind of like usage instructions) for the DirectX components – the components themselves are in DLL files on your system. What the linker needs to do is know which libraries (files with linking instructions) are needed for our project. We’ll be looking at compiling and linking in a later article, but for now here’s what I’m talking about: Our project uses these files:
  • DDRAW.H
  • DINPUT.H
  • DSOUND.H
…which contains prototypes for the DirectDraw, DirectInput and DirectSound components we’re using. The actual components (the DirectX runtimes) are called:
  • DDRAW.DLL
  • DINPUT.DLL
  • DSOUND.DLL
…which are the files that everyone has for playing DirectX games with. Finally, we have library files that connect code using DirectX components:
  • DDRAW.LIB
  • DINPUT.LIB
  • DSOUND.LIB
Okay, so just read this next sentence very carefully and you’ll be fine: Our source code is compiled with instructions contained within header files, and linked with instructions contained in library files, which ultimately allow our code to use the components in the runtime (DLL) files. So, where was I? Oh yeah… Head to Project|Settings|Link , and you’ll see an edit field called Object/library modules . You may even see some entries already here, all ending in .LIB. All we need to do is add our library files here, and they happen to be located in a directory called LIB inside our main DirectX folder. What I do is add this to the front of the library list: C:\DXVCSDK\LIB\*.lib If there are other libraries in this list already, leave them after yours (separated by a space). Now, there happens to be one other library that we’re using (for our sound code), so you’ll need to add WINMM.LIB to this list as well. So, to recap, let’s say that when you first showed up in this dialog, the edit box showed something like: SOMELIB.LIB OTHERLIB.LIB YETMORE.LIB… (Whatever their names actually are, who cares). Now it should be: C:\DXVCSDK\LIB\*.lib WINMM.LIB SOMELIB.LIB OTHERLIB.LIB… Got it? Mission Control… Now for the big moment. Build the project (by hitting F7), and pray that you see ‘0 errors, 0 warnings ’ when it’s done. If you are having problems, first realize that the build process involves two stages, compiling and linking, both with their own types of errors. For instance, the link process won’t even begin if there were errors in the compile stage. Either you saw ‘Linking…’ in the output window or you didn’t. If you are getting complaints like:
Compiling...
GameMain.cpp
c:\gdn\basecode\globals.h(87) : error C2146: syntax error : missing ';' before identifier 'lpDD'
c:\gdn\basecode\globals.h(87) : error C2501: 'LPDIRECTDRAW7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(87) : error C2501: 'lpDD' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(88) : error C2146: syntax error : missing ';' before identifier 'lpDDSPrimary'
c:\gdn\basecode\globals.h(88) : error C2501: 'LPDIRECTDRAWSURFACE7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(88) : error C2501: 'lpDDSPrimary' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(89) : error C2146: syntax error : missing ';' before identifier 'lpDDSBack'
c:\gdn\basecode\globals.h(89) : error C2501: 'LPDIRECTDRAWSURFACE7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(89) : error C2501: 'lpDDSBack' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(90) : error C2146: syntax error : missing ';' before identifier 'lpDDSRes'
c:\gdn\basecode\globals.h(90) : error C2501: 'LPDIRECTDRAWSURFACE7' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(90) : error C2501: 'lpDDSRes' : missing storage-class or type specifiers
c:\gdn\basecode\globals.h(94) : error C2146: syntax error : missing ';' before identifier 'lpDI'
c:\gdn\basecode\globals.h(94) : error C2501: 'LPDIRECTINPUT7' : missing storage-class or type specifiers
  
(…on and on…) then you probably need to make sure that you’re pointing the IDE to the DirectX header files (look in Tools|Options|Directories ). If you have other compile errors, try to get ahold of me (teej@gdnmail.net or 70816765 on ICQ) or post a reply to this article with your questions. As for the linking, well, that’s primarily the job of the LIB list we prepared under Project|Settings|Link. Here’s an example of having it entered incorrectly:
Linking...
InitTerm.obj : error LNK2001: unresolved external symbol _DirectDrawCreateEx@16
InitTerm.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
InitTerm.obj : error LNK2001: unresolved external symbol _c_dfDIKeyboard
InitTerm.obj : error LNK2001: unresolved external symbol _GUID_SysKeyboard
InitTerm.obj : error LNK2001: unresolved external symbol _IID_IDirectInputDevice7A
InitTerm.obj : error LNK2001: unresolved external symbol _DirectInputCreateEx@20
InitTerm.obj : error LNK2001: unresolved external symbol _IID_IDirectInput7A
InitTerm.obj : error LNK2001: unresolved external symbol _DirectSoundCreate@12
Debug/basecode.exe : fatal error LNK1120: 8 unresolved externals
Error executing link.exe.

basecode.exe - 9 error(s), 0 warning(s)
  
As you can see, since the libraries weren’t included properly, the poor linker was lost when it came to including these symbols. Once again, let us know if you’re stumped. NOTE: When we added the libraries in for the linker, you may have noticed on the left side of the screen that there was a box that had ‘Settings for: Win32 Debug ’. Keep in mind that these libraries that you’re adding are only valid when in Debug mode. You can either change this box to read ‘All Configurations ’ before entering your libraries, or enter them a second time when in Release mode. So Far So Good… If you managed to reach the finish line, ‘0 errors, 0 warnings ’, run the program (CTRL-F5) and hopefully you’ll be rewarded with some text on the screen. The space bar will cause a sound to play, and ESCAPE will exit the program. If you aren’t here yet, don’t bother continuing in the forum! That’s why this is called the ‘Readiness Test’… if you can’t get this stuff to run you need to let us know so that we can help rectify the situation. What about the program itself? On the surface, it doesn’t seem to do much. In fact, it uses DirectDraw, DirectInput and DirectSound in proper form (initialization, use and shutdown), so it’s a good learning example. In later articles we will be using and building on this framework, so it’s a good idea to get your DirectX online documentation ready and try going through the code. Of course, the documentation provides excellent introductory material on each of these components, and if you take the time to read some of it you’ll be ahead of the game. The Ladder series was designed to represent ‘prerequisite knowledge’. You know have everything you need to start on your path to enlightenment:
  • An introduction to game development
  • A basic windows application framework
  • C language resources
  • A quick overview of some of the basic tools required
  • Some insight into how a game might be written
  • Information on resolutions, colors and pixel plotting
  • The role of DirectX in our games
  • A first run with some game template code
Congratulations… You have your compiler/linker in order, the DirectX runtimes and SDK installed, the online documentation at your fingertips, and some template code that sits before you like an open book with blank pages – ready to be filled in with the knowledge and practice that is the rite of passage for any apprentice. Get ready folks, because next up is the proverbial ‘Square One’. See you there. Questions? Comments? Can’t get the damned code to build? Reply to this article – help is on the way! Edited by - teej on April 20, 2001 11:10:00 AM
0

Share this post


Link to post
Share on other sites
i can build the program fine errors 0 and warnings 0
but when i try to run it says DD_init faild.|-7
please help!

Fighterdude(A Baldurs Gate Fan)
0

Share this post


Link to post
Share on other sites
I can''t get my modem to download those directx files.. the connection is too slow, and it stoppes after a while
If anyone could upload the files on a better server (or buy me a better modem!), I would be gratefull!



-Lord Maz-
0

Share this post


Link to post
Share on other sites
Fighterdude: make sure you have the resource.bmp and sample.wav files in the same directory as your executable.
0

Share this post


Link to post
Share on other sites
Fighterdude: make sure you have the resource.bmp and sample.wav files in the same directory as your executable.
0

Share this post


Link to post
Share on other sites
Hey Fighter dude!

You haven´t got the "resource.bmp" file in the same catalog/dir.
as the other files.
Just put it there and it´ll work fine.



0

Share this post


Link to post
Share on other sites
i have them all in the same directory
and it still does the same thing.
please help

Fighterdude(A Baldurs Gate Fan)
0

Share this post


Link to post
Share on other sites
Forget the last post i just got what you were saying and it works now Thanks Guys

Fighterdude(A Baldurs Gate Fan)
0

Share this post


Link to post
Share on other sites
Just wonderin Teej is the next artical the C LANGUEGE or you gonna post a new one? Great job Teej i realy like it!

Fighterdude(A Baldurs Gate Fan)now that''s a good Game
0

Share this post


Link to post
Share on other sites
Just wonderin Teej is the next artical the C LANGUEGE or you gonna post a new one? Great job Teej i realy like it!

Fighterdude(A Baldurs Gate Fan)now that''s a good Game
0

Share this post


Link to post
Share on other sites
do i have to get the online version or can i get it in word format?

Fighterdude(A Baldurs Gate Fan)
0

Share this post


Link to post
Share on other sites
Well I''ll be darned! It worked at the first build! Should I be surprised



"You won''t get wise with the sleep still in your eyes." - Neil Peart
0

Share this post


Link to post
Share on other sites
Why do I get this error?

Compiling...
WinBase.cpp
InitTerm.cpp
Utils.cpp
GameMain.cpp
Linking...
LINK : fatal error LNK1104: cannot open file "C:\program.obj"
0

Share this post


Link to post
Share on other sites
Please help!
I get the following messages while I try to compile:
Linking...
d:\dxvcsdk\lib\ddraw.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x389bc793
Error executing link.exe.

I checked the path to my lib file, it is fine, also, I still have some 150MB of free space on my HD.

Any ideas?

Thanks in advance.
0

Share this post


Link to post
Share on other sites
Thalion,

I had the same error as you, so I deleted the project, re-installed the SDK, followed Teej''s instructions again and it all worked fine. Try it, you never know it might work?

Scogster.

PS. Teej your a top man.

0

Share this post


Link to post
Share on other sites
i cant find the site if you can send me the adress or the files to my email i will apreciate it.


you are doing a good job

my email is thadarkangel@hotmail.com

Edited by - thadarkangel on April 21, 2001 9:44:42 PM
0

Share this post


Link to post
Share on other sites
As for readiness, are we expected to know and understand what the heck all those utility functions do? Or know exactly how the implementation works?

"You won''t get wise with the sleep still in your eyes." - Neil Peart
0

Share this post


Link to post
Share on other sites
At this point, just think of it as a black box "template" to program your game code in. The only function you need to worry about if you use the template is really the Game_Main function, and perhaps a bit about the shutdown and/or init functions. Don''t get overwhelmed. If you''re completely lost, there are some good tutorials around on DirectX to learn more than what Teej overviewed thus far, and he might even go more in-depth at a later time.
0

Share this post


Link to post
Share on other sites
I can''t seem to find the DirectX 7 SDK anywhere. Microsoft only has 8 listed on their website. I have downloaded the SDK for version 8 already. Will 8 be suffecent?
0

Share this post


Link to post
Share on other sites
Device: Just check to make sure the files ddraw.h and ddraw.lib are on your machine from the DX 8 SDK. If you''ve got those files, then that''s all it''ll matter for doing the programming in here. You can tell DX that you want to program in version 7, as Teej does in his basecode, and it''ll listen and follow instructions.
0

Share this post


Link to post
Share on other sites
As has already been said, you can use the dx8 SDK, but you''ll want the dx7 documentation, Microsoft has a version available for download at:

http://http://msdn.microsoft.com/downloads/default.asp?URL=/code/topic.asp?URL=/msdn-files/028/000/114/topic.xml

This is a 14Mb download containing both the vb and the c++ documentation.

------------------
It''s me again!
0

Share this post


Link to post
Share on other sites
Hi everyone,

Could somebody send me ddraw.lib? My project doesn't link properly and I suspect this file might be corrupt. Since I would like to avoid downloading the entire SDK from Microsoft again I figured this would be faster. I use DirectX ver 8.0 and the file can be sent to my e-mail at attila_007@hotmail.com.

Thanks a lot in advance for any help,

Cheers

Edited by - Higgenkreuz on April 22, 2001 12:10:37 AM
0

Share this post


Link to post
Share on other sites