Advertisement

04.01 - Some Code to Ponder

Started by April 23, 2001 04:41 PM
41 comments, last by Teej 22 years, 5 months ago
Anyone that saw my post in Q&A about adding an mp3 track to Teej''s basecode. I got it sorted. Direct Music doesn''t support mp3, and while Directshow does, it severely alters the event handling of a program.

I am using the FMOD library to do it. It takes all of 4 lines of code to do it
Mitijea: I know exactly how you feel. I hated reading tutorials where all these functions would be thrown at me, and I''d always want to know how they find out what functions do what and how they all work.

Two things that i learned:
1.) Read the help files!! They''re an invaluable resource. Usually a search on a couple keywords about what your trying to accomplish will be enough.
2.) Patience. In time it will all make sense. Alot of us are still newbies to game programming (why else would we be here), but as long as your determined to learn, you''ll be an all-knowing guru like Teej in no time =)


Teej: awesome idea with the globals structure, since my last attempt at a game i was always wondering if there was a nice easy, organized way to deal with all the globals spread around my files
Advertisement
First off, I''ve added an article on that G thang in 03.03 - Selected C Topics.

About the website, well, I didn''t have the local copy of the website at the time, and tried to hack a new index.html. Obviousely, it didn''t work. As of 7pm EST today it should be repaired.

Rictus: Sorry about that! There are some things in the game template code that frankly have nothing to do whatsoever with running it. I''ve added the code to load a bitmap onto a DirectDraw surface only because it''s one of the first things we''ll want to play with. As someone mentioned, I just used a standard (slow) Windows API function to draw some text on the screen. We''ll all be 100% comfortable with the template code shortly...

Mitijea: If it''s the header file that you''re looking for, I can guarantee you that it''s on your machine (otherwise you wouldn''t be able to compile any Windows application). If you''re using MSVC, try right-clicking on the header name and select ''Open File'' (or whatever it says).

leggyguy: Although I haven''t tried it yet, there is a way to run your mp3 through Window''s APIs using an MP3 codec. Of course, you need a codec first!

shdaga: Boy, not too many people dying for some AI Well, until we get the forum to that stage, I''ll have to limit my AI discussions to general concepts. Rest assured that as our games increase in complexity, the need for clean and powerful AI will definitely warrant a section.

Boy, I''d better hurry up and place another great idea online soon -- I don''t think the ''G'' struct thing will hold me forever

Teej



Since I''m not quite on speaking terms with any Russian Hackers (at least that I know of...) and I wouldn''t want Microsoft to suffer anymore embarrassment over its ''superb'' coding... I guess I''ll just let nature take its course. Thanks all for replying: at least I''m not the only one feeling a tad bit lost in the wonderful, wide world of windows.
Mitijea, just one more thing about those include files:
#include "file.h" vs. #include < file.h>
these are 2 different ways of telling the compiling where/how to look for the file. Basicly it comes down to this: "file" tells it that it is in the current dir and < file> tells it that it's in the include dir. More info on http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/visualc/vccore/_predir_the_.23.include_directive.htm
< file> doesn't mean that it's using a dll or exe, "file" could be a header file for a dll too (but in a different dir).
Just to give you a little more info

Edited because it wouldn't show the angle brackets correctly (forum code )
Mox

Edited by - MtSMox on May 11, 2001 6:24:49 AM
How come this snippet of code doesn''t compile?

if (DirectDrawCreateEx(NULL, (void**)ⅆ, IID_IDirectDraw7, NULL) != DD_OK)
{
return -1;
}

VC complains with the following:

... (48) : error C2115: ''function'' : incompatible types
... (48) : warning C4024: ''DirectDrawCreateEx'' : different types for formal and actual parameter 3

What''s the problem? The code is pretty much the same as the BaseCode1 example (which by the way compiles without any errors or warnings)... I written everything in C in case anyone wonders...

I would appreciate any help, since I''ve run out of ideas by now...


\JWA

Advertisement
Yo, people. I''m back from the dead, and the good news is that I haven''t give up to convert this tutorial to using the SDL Library. My first significative article is done, along with a conversion of the base code.

Please read the article in this page, and send me any comments, suggestions and contributions you may have.

Just to remember: I''ll be focusing on GNU/Linux, but SDL works on many other platforms, including windows. So this code is fairly portable.
Ja ne, Pazu mailto: pazu@animegaiden.com.brClose the world, open the neXt
Anon: Is your C file using a .C extension? This may sound silly, but try renaming it to a .CPP extension. You shouldn''t have to change any code, and the error might go away. Other than that, you''ll have to provide more code.

Teej
Teej, a caveat. You said that we would be sticking to C, and forget C++. However, all COM calls in the basecode are C++ calls, and there is even a class defined. Not even on comments you''re sticking to plain C.

I know that COM programming on plain C is a pain, but... at least say that we''re "using C++ without any OO concepts beyond classes and methods".
Ja ne, Pazu mailto: pazu@animegaiden.com.brClose the world, open the neXt
I have a question in your globals.h struct G, why is it when I compile I DONT get linker errors saying already defined since it is EVERY cpp file? See I made a struct M for handling my DInput mouse varriebles and I put it in my Input.h everything compiles fine but when It comes to linking it says it''s already defined in each of the files I call #include "input.h", Why does mine do this and not yours? does it have to do with GLOBALS_OWNERSHIP? I put all my mouse data in your G struct and it worked fine. I need it in my M struct in the input.h so if some one could help me out I would appreciate it. Thanx

V^^^V
** |Mortation| **
@hotmail.com
AOL:M0RTATI0N ICQ:2515421
MortÔ¿Ô¬

This topic is closed to new replies.

Advertisement