The Daily Click ::. Forums ::. Klik Coding Help ::. The Dreaded Fog of War
 

Post Reply  Post Oekaki 
 

Posted By Message

Rick Cameron



Registered
  11/03/2012 08:45:25
Points
  82
10th February, 2014 at 10/02/2014 08:22:33 -

Hey guys,

So I have a basic engine up at the moment which is a hex grid that can read when a player object is within the cell, and change the visibility and transparency of the shading block accordingly. IE when a player controlled unit is in the cell, set the transparency to 120-odd, else set to 40-odd and set visibility of non-terrain items to invisible.

My problem is, the smaller the cells, the higher the object count. I'm making a single-screen rts style game with a max population of about 20 units who can remove the fog, but I'm wondering if there's any tried and true techniques to have multiple vision spheres like I am envisioning?

Or alternatively, how many cells could I project onto the frame without significant lag? Just in general. Object count before detriment to performance is what I'm after.

Cheers all!

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
10th February, 2014 at 10/02/2014 13:41:10 -

Obviously it's going to depend a lot on the hardware that's running your game, but as long as you're using HWA, I doubt you'll have any trouble.

A really simple alternative to having hundreds of "darkness" objects, is to just have a single darkness layer, and then use HWA effects to illuminate the area around units (just like you'd normally do to create flashlight effects).

eg.
http://sdrv.ms/1bNlE1o
(probably should have pasted to a surface object, rather than adding as a backdrop)

This is likely to be more efficient, as you never need to do any distance comparisons and you only need one object per unit, rather than one per map hex (20 units shouldn't be any trouble at all). Plus it's all handled by the graphics card, leaving the CPU free to deal with the complicated stuff life pathfinding and AI.
If you're game isn't actually hex-based, you can also easily adapt it to use a proper circular field of vision, which looks better.

Edited by Sketchy

 
n/a
   

Post Reply



 



Advertisement

Worth A Click