Skip to main content
deleted 26 characters in body
Source Link
user1430
user1430

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture 

Kind regards - Jakob

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture 

Kind regards - Jakob

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture 
added 20 characters in body
Source Link
Xnafan
  • 126
  • 3

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture 

Kind regards - Jakob

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture

Kind regards - Jakob

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture 

Kind regards - Jakob

Source Link
Xnafan
  • 126
  • 3

Are you making sure you are only checking the visible tiles, and not the tiles for the entire map? This can greatly benefit your FPS. It looks to me as if your two foreach loops are checking every tile on the map up against every other tile. That will be VERY expensive in CPU cycles.

If your lights are in fixed positions, then I suggest you create a light-map: a doublearray of int to store the lighting. Then you can perform a check once, before the game begins to set the light-values from 0 to 5 of every tile.

When you draw the textures, you can lookup into the light-map to find how bright the texture should be.

If you have moving lights as well, then you could create another light-map which you update every time one of the moving lights actually move to another tile.

Then your draw routine would be:

foreach visible tile from the map get the texture find the corresponding tile in the the stationary light-map and the moving lights light-map use the highest lighting value from these to draw the texture

Kind regards - Jakob