Jump to content


Photo

How to cover only the view with objects? and...


  • Please log in to reply
3 replies to this topic

#1 8feet

8feet

    GMC Member

  • GMC Member
  • 104 posts

Posted 13 May 2011 - 08:56 AM

Is there a way how to automatically make objects that will automatically cover only the view?
And remove em outside the view?
Used for fog of war...

God Bless!!!

Edited by 8feet, 13 May 2011 - 05:17 PM.

  • 0

#2 chaz13

chaz13

    GMC Member

  • GMC Member
  • 3822 posts
  • Version:Unknown

Posted 13 May 2011 - 09:31 AM

Yeah, use two loops inside eachother. This will be horrifically slow though, just to warn you, and there are much better ways of doing fog of war. Surfaces, ds_grids, anything is better than objects. Even an array that draws the sprites to fill the room would be much faster. This is because evey object in gm has many many variables assigned to it, has to undergo collision checks, draw, etc every single step. It's a waste of speed and memory and your game will lag horribly.

There are many examples of fog of war engines in tutorial section, some that work wonderfully well. I'd personally use surfaces as they allow you a lot of control and nice smooth effects, but it's up to you.

Here's how you'd do what you want though:

var xx,yy;
xx=0

while(xx<room_width){
yy=0
while(yy<room_height){
instance_create(xx,yy,obj_fog)
yy+=(height of the fog object)
}
xx+=(width of fog object)
}


I really don't suggest doing this though. Tell me a little bit more about how you want your fog of war to work (does it just show a part around the units, or once they discover somewhere is it visible for ever, etc) and I'll explain how to use surfaces to do what you need :)
  • 0

#3 8feet

8feet

    GMC Member

  • GMC Member
  • 104 posts

Posted 13 May 2011 - 05:03 PM

Yeah, use two loops inside eachother. This will be horrifically slow though, just to warn you, and there are much better ways of doing fog of war. Surfaces, ds_grids, anything is better than objects. Even an array that draws the sprites to fill the room would be much faster. This is because evey object in gm has many many variables assigned to it, has to undergo collision checks, draw, etc every single step. It's a waste of speed and memory and your game will lag horribly.

There are many examples of fog of war engines in tutorial section, some that work wonderfully well. I'd personally use surfaces as they allow you a lot of control and nice smooth effects, but it's up to you.

Here's how you'd do what you want though:

var xx,yy;
xx=0

while(xx<room_width){
yy=0
while(yy<room_height){
instance_create(xx,yy,obj_fog)
yy+=(height of the fog object)
}
xx+=(width of fog object)
}


I really don't suggest doing this though. Tell me a little bit more about how you want your fog of war to work (does it just show a part around the units, or once they discover somewhere is it visible for ever, etc) and I'll explain how to use surfaces to do what you need :)


Oh your right Lolz;D!!! It is slow! But you see I do know how to use surfaces... is just that every time you press Ctrl+Alt+Del the surface vanishes and it defeats the purpose. Also this one is too slow.
What should I do...AHA!!!

I have a question? How about only create the the objects in the view only! And every time the player moves w/ the view. It creates new objects. But to prevent making objects outside the view. It destroys the objects outside the view?
Will that work?

God Bless and I appreciate your help Lolz;D!!!
  • 0

#4 chaz13

chaz13

    GMC Member

  • GMC Member
  • 3822 posts
  • Version:Unknown

Posted 13 May 2011 - 05:22 PM

Please for the love of god (..pun intended) stop saying Lolz ;D

But yeah, that'd be slightly slower but not much better. Surface are by far the best way to go, it only needs to be the size of the view.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users