• ### Popular Now

• 11
• 9
• 10
• 9
• 10

#### Archived

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

# performance problem

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

## Recommended Posts

i almost got my first FPS game finish.it is a doom clone uses advanced raycasting.at the moment,in the map i have 4 sectors of map.each of them contains about 15 walls.so in the worst case 3 sector will to be check for intersections.there are only 2 sprite at the moment which perform some moving functions.all went well until i put the texture for floor and ceil.the algorithm i use for that is calculate the distance from every pixel on the screen which is not draw as a wall to the floor or ceiling,then find the offset and memcpy the value from bitmap.the screen resolution is only 320X200.at the moment i just render the floor on and its damn slow.i tried to do some optimisation,but it doesnt make too much difference.also i havnt put my A* pathfinder in as well.cant imagine what it will be like when i finish the whole thing.im sure there is something wrong with it.my cpu is celeron 2.4Gh.there is no way i cant do a doom clone on it.here is the code i done for drawing floor:

inline int raycaster::Draw_Floor_and_Ceiling(int x,int y,int r,int face,int px,int py,int destlpitch,unsigned short* destination,int bitmappitch,unsigned short* bitmap)
{
int dr;
int distance_to_point;
int Xincr;
int Yincr;
int offsetX;
int offsetY;
for(int i = y;i < PROJECTION_HEIGHT;++i)
{
dr = abs((int)(face - r + lookup->ANGLE360)%lookup->ANGLE360);
distance_to_point = 32 * 277 / (i - PROJECTION_HEIGHT/2) / lookup->cosTable[dr];
Xincr = (int)(distance_to_point * lookup->cosTable[r] * -1);
Yincr = (int)(distance_to_point * lookup->sinTable[r] * -1);
offsetX = abs((px + Xincr)) % 64;
offsetY = abs((py + Yincr)) % 64;
memcpy(destination + i*destlpitch + x,bitmap + offsetY*bitmappitch/2 + offsetX,2);
}//for

return (1);
}//Draw_Floor_and_Ceiling


somebody please help me.thanks very much. [edited by - jimywang on April 14, 2004 11:20:33 PM] [edited by - jimywang on April 14, 2004 11:21:25 PM]