#### Archived

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

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

## 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.

Visit the ROAD Programming Website for more programming help.

##### Share on other sites

what is wrong with just..

int *maparray;

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

##### Share on other sites

what is wrong with just..

int *maparray;

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

##### 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

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633312
• Total Posts
3011310
• ### Who's Online (See full list)

There are no registered users currently online

×