Jump to content


Photo

Exploration Fog Ideas


  • Please log in to reply
2 replies to this topic

#1 goofoffjw

goofoffjw

    GMC Member

  • GMC Member
  • 11 posts

Posted 23 January 2011 - 05:43 AM

I'm working on a sidescroller/platformer with a focus on exploration. It's not very far into development right now, so I'm still figuring out the basic concepts.

What I'm trying to work out right now is a method of blocking view of areas you haven't explored. Ideally I'll be able to also track the amount of the area a player explores, and show them what percent of the world they've explored.

I have a video of a really basic (and pretty crappy) version of what I'm trying to do.



Right now I'm using objects that are destroyed on a collision event with the player, and they increment an exploration variable before they are destroyed. It doesn't look very good right now though, and I'm looking for ways to make it better.

Important factors:
*Needs to be persistent, so that it's explored when the player comes back later
*Needs to track how much is explored
*Ideally would look nice

A big reason I want this type of mechanic: the player will be able to switch to a view of the whole current room (kind of a map view) and I want it to be concealed to make finding things a bit harder at first.

I'm also having trouble with the player getting stuck on the fog (collision or similar) if I don't destroy it immediately on collision with the player, but that's a separate/less important problem.

Any advice on this would be great.
  • 0

#2 Canite

Canite

    Canigget

  • GMC Member
  • 1358 posts
  • Version:GM8

Posted 23 January 2011 - 06:16 AM

Instead of using objects and collisions, I would just use sprites and/or particles and then use a global 2d array to keep track of what is explored and what is not. Something like...
Create event
globalvar fog_array;
for(i=0; i<(room_width/16);  i+=1) // this would make 16 x 16 squares for the fog
{
    for(a=0; a<(room_height/16); a+=1)
    {
        fog_array[i,a] = 0 // 0 would mean this section is not explored, 1 means it is
    }
}
Step event (or alarm if you don't want it to update every step)
for(i=0; i<(room_width/16);  i+=1) 
{
    for(a=0; a<(room_height/16); a+=1)
    {
        if point_distance(obj_player.x,obj_player.y,(i*16),(a*16)) < 50 // 50 is the distance to make the section "explored"
        {
            fog_array[i,a] = 1 // 0 would mean this section is not explored, 1 means it is
        }
    }
}
And the draw event..
for(i=0; i<(room_width/16);  i+=1) 
{
    for(a=0; a<(room_height/16); a+=1)
    {
        if fog_array[i,a] // if it isn't explored..
        {
            draw_sprite(spr_fog,0, (i*16), (a*16)) // make sure the origin of the sprite is at (0,0)
        }
    }
}

It would probably be better to use particles instead of sprites and to also only draw and check the things inside the view, but you should get the idea and may need to tweek it to suit you.

Edited by Canite, 23 January 2011 - 06:19 AM.

  • 0

#3 goofoffjw

goofoffjw

    GMC Member

  • GMC Member
  • 11 posts

Posted 23 January 2011 - 07:10 AM

I like this idea a lot, especially the array to keep track of explored areas. I was having trouble finding an easy way to save the explored area data to a file with my previous method too, and your method makes that simple.

I've only touched particles like once, but I'll look into it.

Thanks for the help, I'll hopefully eventually get around to updating this post with results.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users