• entries
    743
  • comments
    1924
  • views
    578703

Bit of progress

Sign in to follow this  
Aardvajk

69 views

Improved the fog effect a bit, and implemented the line of sight stuff for removing it:



I'd like to pretend that the line of sight stuff works by raycasting or some such cleverness, but I've found it is really hard to get it looking and working right on a low granularity 2D map, so here's the fog removal code (brace yourselves):


void CFog::Reveal(int X,int Y)
{
int V=1;

Set(X,Y,V);
Set(X-1,Y-1,V);
Set(X,Y-1,V);
Set(X+1,Y-1,V);
Set(X-1,Y,V);
Set(X+1,Y,V);
Set(X-1,Y+1,V);
Set(X,Y+1,V);
Set(X+1,Y+1,V);

if(See(X,Y-1)) Set(X,Y-2,V);

if(See(X-1,Y-1) || See(X,Y-1)) Set(X-1,Y-2,V);
if(See(X+1,Y-1) || See(X,Y-1)) Set(X+1,Y-2,V);

if(See(X,Y+1)) Set(X,Y+2,V);

if(See(X-1,Y+1) || See(X,Y+1)) Set(X-1,Y+2,V);
if(See(X+1,Y+1) || See(X,Y+1)) Set(X+1,Y+2,V);

if(See(X-1,Y)) Set(X-2,Y,V);

if(See(X-1,Y-1) || See(X-1,Y)) Set(X-2,Y-1,V);
if(See(X-1,Y+1) || See(X-1,Y)) Set(X-2,Y+1,V);

if(See(X+1,Y)) Set(X+2,Y,V);

if(See(X+1,Y-1) || See(X+1,Y)) Set(X+2,Y-1,V);
if(See(X+1,Y+1) || See(X+1,Y)) Set(X+2,Y+1,V);

if(See(X,Y-1) && See(X,Y-2)){ Set(X,Y-3,V); Set(X-1,Y-3,V); Set(X+1,Y-3,V); }
if(See(X,Y+1) && See(X,Y+2)){ Set(X,Y+3,V); Set(X-1,Y+3,V); Set(X+1,Y+3,V); }
if(See(X-1,Y) && See(X-2,Y)){ Set(X-3,Y,V); Set(X-3,Y-1,V); Set(X-3,Y+1,V); }
if(See(X+1,Y) && See(X+2,Y)){ Set(X+3,Y,V); Set(X+3,Y-1,V); Set(X+3,Y+1,V); }

if(See(X-1,Y-1) && (See(X-1,Y) || See(X,Y-1))) Set(X-2,Y-2,V);
if(See(X+1,Y-1) && (See(X+1,Y) || See(X,Y-1))) Set(X+2,Y-2,V);
if(See(X-1,Y+1) && (See(X-1,Y) || See(X,Y+1))) Set(X-2,Y+2,V);
if(See(X+1,Y+1) && (See(X+1,Y) || See(X,Y+1))) Set(X+2,Y+2,V);
}





Mmm. Nice. [smile]

Still, sod it. It works pretty well in practice, although extending the line of sight range by another cell would be a horrible task.

Don't care really. I've been working on this for several days now and have finally got it acceptible so onwards.

The cursor you can see in the image highlights the cell that the mouse is currently over, since otherwise it can get confusing due to the Zelda angle of viewing.

At the moment, clicking on a cell just reveals the cell and the surrounding cells you can "see".

Next up is to have the little character move about when you click. Plan is to implement pathfinding so you just click on any visible cell and it moves there, but smoothly on a pixel by pixel rather than grid movement basis. Done this before so should be okay.

---------------------------------------------------------------------

Interview yesterday seemed to go pretty well, although it is always hard to tell.

It's going to be a long application process - will be two weeks before I hear if I made the second interview stage, then if I did it will be online psychometric tests then the interview itself.

If I am still in the running at that point, back for a third interview, attended by the company MD, then if I actually get the job, it will be starting in September.

We shall see. Don't want to be to optimistic or pessamistic really. Just need to forget about it for now and concentrate on finding some work for the end of this month and August.
Sign in to follow this  


1 Comment


Recommended Comments

Haha that's such a hack!! :D From my experience putting together a brute-force ray casting algorithm is easy, what kind of problems did you find? The granularity problem was solved simply with more rays and less space between them :)

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now