Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

03.01 - Q&A

  • You cannot reply to this topic
120 replies to this topic

#41 leggyguy   Members   -  Reputation: 128

Like
Likes
Like

Posted 05 May 2001 - 05:00 AM

Ok. I have been playing around with DX show.

I have managed to get my mp3 playing, but it turns out that DX Show alters the way events are handled. Basicly, DXShow overrides everything else in the program. I could certainly change it to what I need if I continued working on it, but it isn''t worth it right now.

What it boils down to is, I want this mp3 to play using DXmusic. But how? is the question. Maybe we can convert it to a mid file, or to one of the other file types that DXmusic accomodates. But what will do it for us?

Any ideas?

Sponsor:

#42 Lord Maz   Banned   -  Reputation: 110

Like
Likes
Like

Posted 06 May 2001 - 05:15 AM

Hi, I have got 3 Q''s for someone nice to answer:

1. How do i get a random number? I know there''s a rand() function, but I''m not sure how it works..

2. What are all those macro things good for? How do they work?

3. Bitshifting, Hex values, and all that other weird stuff - Are there any good tutorials or something for this?

Thanks!

-Lord Maz-

#43 leggyguy   Members   -  Reputation: 128

Like
Likes
Like

Posted 06 May 2001 - 08:46 AM

OK Lord Maz, here are your answers. In reverse order


3/ I don''t know about tutorials for these. You wont be needing them for this game project of Teej''s, I shouldn''t think. What you do need, Teej will cover. But seriously, you won''t be needing these things for general game development.

2/ Macros are very useful little things. You normally make a macro by using #define. For example:

#define PI 3.14159265 - this statement means now that if you want to devide something by PI you wouldn''t need to do this everytime:

x = a/3.14159265; - but you could simply use

x = a/PI;

This same macro notion works with variable, as above, or can be used to represent a (small) function. Basically, whenever you later type in the name you defined (like PI above) that text is
replaced in the compiled program with the code you replaced it with.

#define identifier replacement is the syntax.

1/this code will return a random number:

srand (time(NULL));
rand();
int whtinj = rand();

The integar whtinj is now a random number.

2 things to note. C, and C++ cannot generate a truly random number. If you call rand, then call it again after restarting the program, you will receive the same number, everytime. So what we do is use the srand function first, to give rand() a different starting point each time it is called, or at the start of the program. Then call rand() once and disregard it, because the first call to rand is always a bit dodgy.

To all users of this forum, I strongly suggest you get yourself a C (preferably C++) reference book. You cannot build anything independantly without one, guaranteed. You could follow Teej''s examples, but in the end he is going to be teaching you DX and and some graphics basics, and game design methods and ideas. He isnt teaching you C. And you do need to be able to use C or C++ effectively in order to make anything useful, be it a game or an app.

#44 Weatherman   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 May 2001 - 03:24 AM

An excellent resource, available for free on-line, is:
"Thinking in C++" 2nd edition (volumes 1 and 2) by Bruce Eckel.
These books are available from www.mindview.net (click on "books").

I guarantee that you won''t find a better value than this.

#45 Corrosive   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 May 2001 - 07:47 PM

Hi, i have programmed in c++ for the last 2 years!!! Have a litlle experience and i want to figure out how to acess bits in a byte!!! for example, just an stupid question, in the pcx function to read an pcx file, it have an rle that verifies the last two bits of the byte.. How can i set just on bit of the byte, how can i choose what bit i want to set, and how can i read just one bit from the byte and the bit i want.. ex.: bit 2, 3 or four of 8-bit!!! Any help will be welcome!

#46 Teej   GDNet+   -  Reputation: 176

Like
Likes
Like

Posted 08 May 2001 - 08:55 AM

Corrosive: We use the & operator to mask bits. For a single bit, recall the value of the column it''s in, e.g.


1
2 6 3 1
8 4 2 6 8 4 2 1
---------------
7 6 5 4 3 2 1 0


So the value of bit 5, let''s say, is 32. Here''s some examples on putting this to use:

  
BYTE val;

val = 42; // test value


if (val & 1) printf("Bit 0 is ON");
if (val & 2) printf("Bit 1 is ON");
if (val & 4) printf("Bit 2 is ON");
if (val & 8) printf("Bit 3 is ON");
if (val & 16) printf("Bit 4 is ON");
if (val & 32) printf("Bit 5 is ON");
if (val & 64) printf("Bit 6 is ON");
if (val & 128) printf("Bit 7 is ON");


There ya go...

Teej



#47 Corrosive   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 May 2001 - 07:40 PM

Thank´s Teej!!! you are doing an Exceptional job here!!!

Just one more question... How can i treat an 32 bit number using this method you have described me? or an 16 bit number, etc!!!

I will have to treat byte per byte? like 8bits numbers separated?

#48 nmoog   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 May 2001 - 02:44 PM

I have a simple C question, that relates to the game. How do I setup a structure in, say, game_initalise() in the InitTerm.cpp and then use it in game_main() in the GameMain.cpp?
Do I have to define it somehow in Globals, or do I use pointers, or should I just go watch TV? (Please note, I would rather poke out my eyes with a spoon than watch TV - so your help would be appreciated!)




#49 Biere et punk   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 May 2001 - 09:14 AM

One more silly question...

What does the (0 ? 1 : 0) opearotr do?
I''ve seen it in defines but never knew what it does exactly...

Thanks

Biere et punk

#50 Piotyr   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 May 2001 - 09:50 AM

Ahh, the ternary operator. Basically, it''s a shorthand if-then-else statement. The format works like so:

(condition) ? (then statement) : (else statement)

For example, if you wanted to do a

if (x > y)
{
x = 0;
}
else
{
x++;
}

the syntax for the ternary operator would be:

(x > y) ? (x = 0) : (x++);

#51 Sturm   Members   -  Reputation: 124

Like
Likes
Like

Posted 10 May 2001 - 10:33 AM

The ternary operator is also often used a kinda assignment operator, hence:

x = (bClear == true) ? 0 : 100;

which will set x to either 0 or 100 depending on bClear

---------------------------------------------------
Life after death? No thanks, I want to live NOW
--- Sturm 2001

#52 Corrosive   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 May 2001 - 06:58 PM

Hi, I want to know what this means:

.... (void **) duh...

Why the two *... what diference this makes?
It´s declarating the type of the variable duh isn´t?
I just wonder what it is!!! thank´s!! bye!

#53 Teej   GDNet+   -  Reputation: 176

Like
Likes
Like

Posted 22 May 2001 - 05:58 AM

I''ve just posted an article in Selected C Topics that deals with pointers, and consequently, **.

Either one of two things will happen; either you''ll come away with a better understanding, or end up worse-off than before you read it

Teej



#54 Roof Top Pew Wee   Members   -  Reputation: 226

Like
Likes
Like

Posted 25 May 2001 - 12:52 PM

I''m trying to add a menu to my game and am having trouble doing it. I only know how to put up menus with the MFC libraries, which I know are a no no on games. I could do it by having each menu a bitmap, but that would eat up my VRAM. .. so I''m left with trying to find out how to do regular menus. In my game programming book, the author mentioned something about an IDE editor. I have no clue what that is. If someone could give me some direction, I''d really appreciate it. Thanks.

--Vic--

#55 j_cochran   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 May 2001 - 07:01 PM

Well, I''ve been following this forum, and have looked at multiple other forums on here and have come to the basic conclusion that my c skills aren''t anywhere near good enough to think about games right now. I guess all I''m looking for here is some direction on where to start...I have sam''s teach yourself c++ in 24 hours, and the immortal "Tips and tricks of the windows game programming guru''s", and some other reference books. I figured I would start out with the sam''s book and work my way through. I was wondering if I should maybe start out with a text based game or something, in order to hone my skills...if anyone has any suggestions on stuff that helped them get here, I''m all ears. Thanks for all your help.




#56 SKULLZ   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 June 2001 - 08:02 PM

1 Funny thing I found about this whole project is:
Teej''s profile:
------------------------------------
Get to know Teej...
Full Name Tim Boston
Nickname Teej
State/Province, Country Ontario Canada
blah blah.....
Contributions to the Site
>>>No Contributions have yet been made to Gamedev.net
-----------------------------------------------

If not like this, How can you contribute to the site than I am curios?
By the way Teej I live in Ontario too. Haha!
Are you by any chance Ukrainian?(just asking)





-SKULLZ

#57 Lancelot du lac   Members   -  Reputation: 130

Like
Likes
Like

Posted 02 June 2001 - 08:22 AM

Hey Teej, i am from Quebec. We are supposed to hate each other... ;D (politics, what a waste of time anyway)

Hey J_COCHRAN, take the advice from WEATHERMAN:

---------------------------------------------------------------
An excellent resource, available for free on-line, is:
"Thinking in C++" 2nd edition (volumes 1 and 2) by Bruce Eckel.
These books are available from www.mindview.net (click on "books").

I guarantee that you won''t find a better value than this.

---------------------------------------------------------------

I agree with him. I did a bit of C long time ago and i forgot everything. I use that book to start up again and i am only to the final exercices of chapter 6 (of 16, book 1 of 2) and i''m suprised to be able to follow whitout being totaly overwhelm. Take a look at it, it''s free. You have nothing to loose.

My question: If i want to find a class that does a specific action (ex: get the system clock, performe a mathematical calculation, etc...). Where do i start to look to see if it''s been already written? And once i found it, how do i know what header file to include to make shure it works?

Thanks to anyone.


Lancelot

Life is endlessly short.

#58 Teej   GDNet+   -  Reputation: 176

Like
Likes
Like

Posted 04 June 2001 - 11:46 AM

SKULLZ: I think someone at GDN was watching...it doesn''t say that any longer

Lancelot du lac: Canada, Quebec, English, French... bah humbug.

If you need to do something that requires the assistance of the operating system, it will already be available. By far the ultimate resource for finding out what''s at your disposal when programming is the MSDN library... go to the Index tab and type away -- you''ll always find interesting and pertanent information.

If you''re asking about classes specifically, start at the Microsoft Foundation Classes overview (MFC). If it''s related to Windows, it''s in there, not to mention convenience classes for many other areas of Win32 programming.

Other than that, well, experience prevails.

Teej


#59 Lancelot du lac   Members   -  Reputation: 130

Like
Likes
Like

Posted 04 June 2001 - 01:51 PM

It is always a long journey to get from no experience to great experience. But, i don''t see a better place to start then here and now.

Thanks Teej for the infos.

Lancelot

Life is endlessly short.

#60 RandomGamer   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 June 2001 - 12:34 PM

Would anybody have any idea why when I hold down the up arrow key and the left arrow key, certain other keys don''t seem to register? Other key combinations seem to cause this type of thing to happen in my program, but I can''t see any reason for it.

Also, I''m having trouble with some class stuff in c++. I have created a class called Sprite, and I created a member function that will take in another member of the class sprite and then check to see if the calling sprite''s bullet has hit the passed in sprite. Here''s the problem, I wanted to create an array of Sprites (so that the number of sprites created is easily managed with a define statment) but that caused my old member function to crash the program. I need to be able to change the data in the Sprite array member being passed in. I''m not sure what I should do, so any help would be greatly appreciated.





PARTNERS