A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: warcraft fog effect

Hybrid View

  1. #1
    Senior Member martin47's Avatar
    Join Date
    Dec 2000
    Posts
    413

    Thumbs up

    Have you ever played wrcraft??? OK, did you see how fog works? Once the character walks a terrain, it gets visible, but if you haven´t walk in there, it remains black.
    Im working a game, similar interface and Im haveing hard time tryiing to come up with a procedure to make that efefect work.
    So far, my character is a movie clip that moves over other movie clip that is the terrain. Hittest is being used to run into stuff.

    Any suggestions of how to try to solve this foggy problem????
    Thanks, as ussual.

  2. #2
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    I think the name is Fog of War right ive done something in this sence:

    http://members.nbci.com/savco/tutorials/maze.swf
    hope it works.

    is that it:

    mad_sci

    PS for more information and fla look for the maze tutorial in my footer. In the above example I siple have a mask a top layer..

    mad_sci

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    425
    that's not really the effect. I know what he's talking about. it is more like this.

    you have a character that can move around the screen. at the beginning, the entire world is covered by a black cloud. each character has a "light radius" around them. now when this player walks, his light radius turns the "fog" into viewable area. so it reveals the map to the player. this way, you have to walk into the enemies base befor you can see what he's doing. there for making the game a bit more challenging.


    All i can think of is having many small black or tinted MCs over the game and having an almost invisible circle aroundthe player. then on hittest with the circle, set the alpha of the black MCs to zero. you could even have a timer option that slowly increases the alpha of the MCs so that it recovers up what you have found.

    Just an Idea

  4. #4
    Senior Member Olorin's Avatar
    Join Date
    Aug 2000
    Posts
    1,151
    it's actually a bit more complicated than that... At first, the hole screen is black, axcept for the bits where your troops are standing. When they move on to an unexplored area on the map, the black bit disappears and the map is shown. However, if they move away from that area, it doesn't turn black again. It does get a little darker, but you can still see the terrain. But you can't see enemy movement there, unless you're close enough.
    So there are 3 'layers'

    1: completely black, undiscovered land
    2: dark, but visible, discovered land
    3: clearly visible, land within sight of troops (this is the only place where you can see enemy troops)

    So, I'd probably use an array to store this setting for each tile and change the _alpha value of the tile accordingly. (1 = alpha 0, 2 = alpha 50, 3 = alpha 100)

    Olorin

  5. #5
    Senior Member martin47's Avatar
    Join Date
    Dec 2000
    Posts
    413
    Yes, that is the effect. Ill be happy if i just can make it desappear (im not interested in the grayed areas. The multiple movieclips is an idea i tested without very good results. it turn very geometrical, squary.. i don{t know how to express it). it also slows down the game a lot.

    any other ideas?
    thanks.

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    425
    i would think that you could use hit test to fade the black out, but then again you would still need multiple MCs. instead of making a bunch of squares, make a bunch of small dots, i mean a lot!. then have each dot me an MC, no instance name needed, have actions in each one stating that on hittest (character + eval[x]) this._alpha --
    this will slowly fade the blackness, if you want it to be faster, instead f this._alpha --, have this._alpha = this._alpha - Fadespeed.

  7. #7
    Senior Member martin47's Avatar
    Join Date
    Dec 2000
    Posts
    413

    Thumbs up

    I came up with this simple version that seems to not make the mvie run too slow:

    http://200.26.70.70/testmartin/borrar/main.swf

    Im sure it can still be improved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center