Advertisement

Old questions re-asked

Started by January 13, 2001 03:29 PM
2 comments, last by Yanroy 24 years ago
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.

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

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.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com



what is wrong with just..

int *maparray;

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

Advertisement


what is wrong with just..

int *maparray;

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

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

This topic is closed to new replies.

Advertisement