Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  [SOLVED] "Fog of War"  (Read 1080 times)
0 Members and 2 Guests are viewing this topic.
Offline duce

JGO n00b
*

Posts: 47



« on: 2011-12-23 21:10:44 »

Is there any way I can have it so I can't see units a certain distance away? I thought of drawing only units that intersect with an oval around my player, but it would look weird when they came into view, as they would just pop up. I also thought of a vignette image I could lay over the canvas, but not sure if that would work.
Offline namrog84

Full Member
**

Posts: 245
Medals: 12


Keep programming!


« Reply #1 on: 2011-12-23 21:26:16 »

Fog of war, the units do just pop in when they come out of the fog, don't they?

You could have 2 circles, and when they intersect the larger one, start their fade at 0.1(almost fully transparent) and when they reach the inner smaller circle, have their fade be at 1(fully opaque) and interpolate between the 2.

instead of using a circle though, I'd just use a range check against units.  You could also leave a few "sight entities" behind when units move around, so that when you are moving fast, many games you cna still maintain sight for a few moments before it disappears, just have the sight entity with a deteriorating health. Obviously the sight entity isnt visible or renderable, just an entity that can add to your vision.

Edit:

Is this a 2D or 3D game?  Top down perspective? side view? first person?  That could change some things.



"Experience is what you get when you did not get what you wanted"
Offline theagentd

JGO Wizard
****

Posts: 1392
Medals: 88



« Reply #2 on: 2011-12-23 23:42:14 »

Calculate the distance between the units and fade them between two distances?

There is no god.
Games published by our own members! Go get 'em!
Offline delt0r

Sr. Member
**

Posts: 412
Medals: 12


Computers can do that?


« Reply #3 on: 2011-12-24 05:00:25 »

Most games they do just pop into view. Sometimes they animate a fade in over time to avoid visual popping. 

I have no special talents. I am only passionately curious.--Albert Einstein
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #4 on: 2011-12-24 06:43:01 »

Just blend em in from transparent -> fully visible until they're out of the fog.

Cas Smiley

Offline duce

JGO n00b
*

Posts: 47



« Reply #5 on: 2011-12-24 08:35:49 »

Thanks a lot. All of these answers are great.
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.091 seconds with 19 queries.