Jump to content
  • Advertisement

Archived

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

Yanroy

Old questions re-asked

This topic is 6427 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have two questions that have been answered before in this forum. Thanks to the disfunctional search program for the forum, I can''t find them. So please answer them for me, without being too angry 1) To allocate a 2D array dynamically, you need to make an array of pointers, then loop through that array new-ing arrays of the object you want, right? I tried this, and it doesn''t work. Here is my code:
  
Map = new *MapTile[Width];
if (!Map)
	return false;
for (int Col = 0; Col < Width; ++Col)
{
	Map[Col] = new MapTile[Height];
	if (!Map[Col])
		return false;
}

return true;
  
2) Where can I get an accurate timer? I started out using GetTickCount(), but that is only accurate to 55ms. Then I switched to QueryPerformanceCounter(), and that doesn''t have an accuracy in MSDN, but it seems to jump around almost as bad as GetTickCount(). Is there a good function that will return a value with just a couple of ms error? Instead of locking down the framerate in my game, I am going to try the proportional motion thing, and that needs a fairly accurate timer. I haven''t tried it with QueryPerformanceCounter(), but I would think that a difference of 50ms could really throw off the formula. If you would be willing to restate past answers to old questions, I could really use them. (and if any GDNet Staff are reading this, fix the search engine!) --------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster


what is wrong with just..

int *maparray;

maparray = new int[size][size]; ??

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


what is wrong with just..

int *maparray;

maparray = new int[size][size]; ??

Share this post


Link to post
Share on other sites
Hi

2)
the only problem my compiler (MSVC++) has with such code is the line
Map = new *MapTile[Width];

but if you make
typedef MapTile* pMapTile;
Map = new pMapTile[Width];
it should work
at least it works for me if i use int instead of MapTile
and Map itself must be a MapTile** of course

2)
I myself use the QueryPerformanceCounter(), and as this is the hardware one, it is quite fast...perhaps you should test it and see if it is ok


hope that helps

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!