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

#61 Ible   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 June 2001 - 04:00 PM

I have the same problem, when I am using both the right arrow key and the up or down I can''t use the space bar and so on, but it only happens on my laptop, not on my desktop. I think it has something to do with the way your computer reads in the keys, it can''t respond to certain combinations. But I am just guessing Does anyone have a better explanation?



"Fall seven times, stand up eight."
-Japanese Proverb

Sponsor:

#62 Dionysis   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 June 2001 - 05:29 PM

I don''t have an explanation but I was having the same problem with detecting the space key when i was pushing two arrow keys. I tried hooking up a different keyboard and everything worked perfectly. So I''m assuming it does have something to do with the hardware, either that''s the way it was designed or it''s broken.

#63 joruli   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 June 2001 - 09:16 AM

Ok, I had the whole G thing and the struct figured out until I went back and looked at it again a hundredth time.

#ifndef GLOBALS_OWNERSHIP
extern
#endif
blah blah blah

I thought that the usual way this worked was (with headers).
If not defined...Header.h
then define Header.h
End if

But in the above snippet, I see in GameMain where Globals_Ownership is defined with #define GLOBALS_OWNERSHIP

So why doesn''t the above code say...
if not defined Globals_ownership (which it already is)
extern the following struct
end if
...and then skip over the extern keyword?

Or am I looking at this backwards? Is this code forcing everything to extern G until Game Main gets called and then it is defined? But what keeps the compiler from looking at GameMain until last if this is the case?

#64 joruli   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 June 2001 - 09:51 AM

Nevermind the last post. I understand it again after re-reading the post in 3.03.

Thanks.

#65 Ible   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 June 2001 - 02:28 PM

HELP!! I am about to kill my computer. I am trying to put all the code for making sprites into a class, and in doing so I have set up some static member variables to hold the details that are consistant like the height and width of the sprite. The code looks something like this.

class sprite
{...
public:
static int height;
static int width;
static int movementRate;
...
};

There are some functions and stuff but this is all thats important. The file compiles fine but it dies on the linker. I get a whole lot of errors like:
sprite.obj: error LNK2001: unresolved external symbol "public: static int sprite::height" (?height@sprite@@2HA)

I can''t figure out why. Any suggestions would be welcome.




"Fall seven times, stand up eight."
-Japanese Proverb

#66 acraig   Members   -  Reputation: 471

Like
Likes
Like

Posted 08 June 2001 - 03:20 PM

quote:
Original post by Ible

HELP!! I am about to kill my computer. I am trying to put all the code for making sprites into a class, and in doing so I have set up some static member variables to hold the details that are consistant like the height and width of the sprite. The code looks something like this.




Try giving your statics a value when you declare them in the class. Ie:
  
class sprite
{...
public:
static int height = 32;
static int width = 32;
static int movementRate = 5;
...
};





-------
Andrew

#67 Ible   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 June 2001 - 06:49 PM

Alas no luck, that gives me a "illegal pure syntax" error. Thanks though. I think I might just give up on making the members static for now. It will be far less efficient but that isn't really a concern yet

Edit: I got it! Thanks to whoever recommended Thinking in C++, that book did the trick, for free no less. I'll get this thing up and running yet!

"Fall seven times, stand up eight."
-Japanese Proverb

Edited by - Ible on June 9, 2001 3:48:11 AM

#68 RandomGamer   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 June 2001 - 04:11 AM

Ible... what solution did you use? I had a similar problem and I just gave up on that aspect, and made each object static instead of their variables.

#69 Sir Melvalot   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 June 2001 - 04:44 AM

a static class member is where one variable is used for every object of that class. You must actually create an instance of each of the static variables globally, since a new instance is not created when you create an object of the class.

#70 Weatherman   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 June 2001 - 04:45 AM

Ible:

quote:

HELP!! I am about to kill my computer. I am trying to put all the code for making sprites into a class, and in doing so I have set up some static member variables to hold the details that are consistant like the height and width of the sprite. The code looks something like this.

class sprite
{...
public:
static int height;
static int width;
static int movementRate;
...
};

There are some functions and stuff but this is all thats important. The file compiles fine but it dies on the linker. I get a whole lot of errors like:
sprite.obj: error LNK2001: unresolved external symbol "public: static int sprite::height" (?height@sprite@@2HA)



You can't initialize a static data member inside the class declaration. Remember that the class declaration only describes the class - it doesn't actually allocate any memory.

You should allocate memory for the static member with a statement in the file that contains the definitions of the class methods. You should also use the scope resolution operator :: to tell the computer which class the member belongs to.

In your example, you could have the following statements in your definitions file (if you were to put these statements in your header file, you would probably get a lot of linker errors saying that you have multiple definitions):

int sprite::height = 32;
int sprite::width = 32;
int sprite::movementRate = 100;

(use whatever values make sense to you).




Edited by - Weatherman on June 10, 2001 11:49:10 AM

#71 Roof Top Pew Wee   Members   -  Reputation: 226

Like
Likes
Like

Posted 10 June 2001 - 03:44 PM

There''s a little bit of code that I''ve added to my GameMain() and for some reason I''m getting wierd results.

if (KEYDOWN(DIK_M))
{
ShowCursor(TRUE);
MessageBox(G.hWnd, "Work", "Work all day", MB_OK);
}

Originally in the WinMain the ShowCursor was set to FALSE. I''m expecting this to create a Message box which the user can then click on with the mouse to make it disappear. However, when I press ''M'', the program freezes as expected, but sometimes the message box doesn''t appear. At that point, the only way to get the GameMain() function to continue is by pressing ESC. What can I do to get my messagebox to show up all the time?



#72 joruli   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 June 2001 - 04:59 PM

I have a question about the executable. I entered the code from one the examples in 4.03 (the random expanding squares) it runs from within the IDE and I would like to take the .exe and put it on another computer to use as a screen saver. First however, I tried to run the .exe from Windows Explorer on the computer which the code was entered and compiled on and I get DD_Init Failed: -7 DirectX Intialisation Error both the debug and release versions.

Can someone tell me how I can compile and distribute the .exe? Even to the computer it was developed on...


#73 Spaul   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 June 2001 - 09:29 PM

Yeh, I had this problem myself. I''m using Visual Studio and the executable is placed in a folder named Debug or Release depending on the build, but the error comes up because it cannot find the resources. If you copy the resources to the folder it should work fine.

Hope this helps. Bye

#74 Ible   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 June 2001 - 10:26 PM

Randomgamer: I did the same thing that Weatherman suggests and in the class''s CPP file just before the function definitions i have lines like:
int sprite::width = 31;
int sprite::height = 32;

and so on. I did have one interesting experience though maybe someone could explain to me. I tried to inherit a bullet class from my sprite class i.e.

class bullet : public sprite
{...};

But it seems to have created only one instance of the static member variables, that is there is one width(etc) variable for both sprite and bullet, so sprite::width and bullet::width both access the same thing. Am I doing something wrong or is it supposed to work like that?

"Fall seven times, stand up eight."
-Japanese Proverb

#75 joruli   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 June 2001 - 05:05 AM

Thanks. Copying the resources into the folder fixed the problem.



#76 RandomGamer   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 June 2001 - 03:26 PM

Ible... whenever you create a Bullet that is a Sprite the Bullet also creates a Sprite. Proof of this could be shown if you put a message in the sprite's constructor and then create a bullet. If you want this to be different, I'm not sure what to do, though. Would it be possible to make it a virtual static variable? I don't know if that would work.

Edited by - randomGamer on June 13, 2001 4:48:39 PM

#77 Black_Flag   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 June 2001 - 04:23 PM

I have a problem

If I take the basecode and do nothing but change the following

Globals.h
..

//----------------------------------------------------------------------------
// Global Defines
//----------------------------------------------------------------------------

(from this) #define SCREEN_BITDEPTH 16
(to this ) #define SCREEN_BITDEPTH 8

If I compile and run the program runs fine but upon exit I get a DDHELP popup stating a general page fault has occurred in an module at some address.

And if I change it back to #define SCREEN_BITDEPTH 16 and recompile and run it locks up the program and have to use CTRL-ALT-DEL to cancel it and if I change back to #define SCREEN_BITDEPTH 8 I will get errors upon trying to run. I have to completely reboot to clear whatever flag is set.

A similar situation occurs when i call some functions incorrectly the first time, and then no matter if i correct it i get a runtime error, i have to reboot

I consulted the DX7 help and it states :
When Ddraw.dll is first loaded by a DirectDraw application, it in turn loads Ddhelp.exe, which enables DirectDraw to restore the proper screen resolution and perform other cleanup tasks in the event that an application fails to do so. KillHelp is the only way to remove Ddraw.dll and Ddhelp.exe from memory without actually restarting the system.
DX8 help does not even list it.

Any ideas why this happening and how to fix it?



//UPDATE

Well after thinking it through and taking a guess i decided to update my not so old ASUS drivers to NVidia drivers, when i did this all the freaky DX8 errors went away.... go figure


Edited by - Black_Flag on June 24, 2001 10:24:18 PM

#78 tripnotize   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 June 2001 - 12:28 PM

Quick question, how come vc++ IntelliSense doesn't work half the time when I use directx functions? It'd be nice to not have to make so many trips to the sdk. Also IntelliSense doesn't work for the struct G either, even though I think it should.

Thx Teej!

# Andrew

/*
Friends can see your Privates, but a Friend of a Friend cant.
*/

Edited by - tripnotize on June 18, 2001 9:09:37 PM

#79 Roof Top Pew Wee   Members   -  Reputation: 226

Like
Likes
Like

Posted 18 June 2001 - 04:35 PM

I''m not necessarily a problem, but I have a question on improving efficiency. I''m writing a program that is going to run with 16 bit graphics, but my Adobe Photoshop only saves .bmp files in 24 bit. This is taking a lot of memory up, and I assume, is also making the program run slower than it could if the .bmps were 16 bit. Anyone know of any programs that can convert the 24 to 16?

Vic

#80 tripnotize   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 June 2001 - 09:17 AM

There should almost definately be an option in photoshop to choose the bit-depth of your .bmp. If you can''t find it or if you are sure it doesn''t exist, try jasc paintshop pro, which has a 60 day free trial. It can convert almost any format.

http://www.jasc.com/

I will try a version of photoshop and if i can figure it out i''ll edit this post.

# Andrew

/*
Friends can see your Privates, but a Friend of a Friend cant.
*/





PARTNERS