🔴 Fog of war with surfaces [Game Maker Studio 2 | Basics]
Вставка
- Опубліковано 12 лют 2020
- This basic video tutorial shows you how to make a fog of war with a surface in GameMaker Studio.
How does this one work?
The idea is to create a surface and then poke holes in it. You may have seen almost the same in a light tutorial for gameMaker and it is very similar. But here we have to make the surface once black and only the negative poking will reveal unseen areas. Because fog of war has different interpretations I show you the the reveal once and for ever method aswell as a rudimentary one where unvisited areas become covered again.
▶ Gamemaker Studio: www.yoyogames.com/get
▶ Trial limitations: help.yoyogames.com/hc/en-us/a...
♥ My free game Clunky souls:
1up-indie2.itch.io/clunky-souls
♥ My assets:
Get some assets at itch.io 1up-indie2.itch.io/
♥ Support me and get fresh game art and game maker projects every month:
/ 1upindie
Follow me on:
/ 1upindie
/ 1upindie
/ discord
This is great, thank you! Easy to understand, not very complicated, but each step very thoroughly explained. Great show, good stuff!
Neat! Glad to hear it helped you out.
@@1upIndie It did, indeed. In fact, it was exactly what I needed. I really like that you show how to do re-fading darkness too, since certain areas in a game might be too lightless to remain discovered for long.
This is spot on. Easy to use.
thanks!
You are more then welcome mate!
Wow, didn't think you would actually do it, thank you so very much !!!
Would some random guy from the internet lie to you?... Actually, most would do :DDD
your tutorial has everything I need
Neat!
1up Indie... Making great content like always.
Thanks!
YO! This looks awesome. However there is one part that isn't implemented in yours that I need. In my game I have walls that shouldn't be able to be seen through how would you solve this problem? So far everything has been unhelpful
Well, that is a bit more complicated then and I see no easy way here to solve this issue.
The hard way would be to define the "uncover" radial part into a lots of pieces (a grid) and calculate if they can uncove. So first you would have a bunch of tiles/parts that are being flagged as "uncover" and then see with a collision check if there is a wall in the way (you go radially around in circles and stop if there is a wall on this check). If yes, this part is being flagges as "not uncover" (also in this directions line all others also). So you gather all that info and then poke holes on the surface now only those that are flagged as "uncover". For that you need to loop, which can get quite heavy on performance if you do too many collision checks.
A quick and dirty way would be to (what you see in a lot of games) have predefined areas that are being shown or not (or shown once uncovered forever). This method is called culling or you do it even simpler by enabling/disabling whole layers for secret areas:
ua-cam.com/video/0x1j00YLKRU/v-deo.html
As an alternative you could use this system mentioned here and re-purpose it to your needs. But it is a resource gobbler (not recommended).
ua-cam.com/video/0doV4ExOzdQ/v-deo.html
Or you could ask in my or the offical discord server in the respective "help" section.
Hope that helps!
the only issue with this is that that subtract is done every frame even if the mouse is not moving so it gets a weir accumulative reveal is a single spot. also if you are in fullscreen mode and switch out of it fullscreen the fog of war is removed
Yeah, surfaces are being wiped as it seems. So you would need to store it before setting to fullscreen and paste it manually in. Not the best solution, but it works more or less.
@@1upIndie I used a ds_list amd map the locations that the player as revealed the there is a check if the surface is gone and redrawes the surface subtracts as needed. So far so good.
I still have not found a good solution for the accumulative subtracts every frame. I can reset the surface to black but this prevents any persistent reveal which is what I am going for.
отлично, показательно.
Спасибо
Благодарю!!!!:)
Не за что!
If you ever played Awesome Tanks on the internet you know how i want the game to uncover itself like that, is there a way to do that?
That is more like a block fog of war. I have a video how you can do that with tilesets -> ua-cam.com/video/85uRK9j3M40/v-deo.html
Great work! What about limiting the field of view if you have a wall?
What you are looking for is this: ua-cam.com/video/0doV4ExOzdQ/v-deo.html. Technically you could do a collision check on the radius of the light circle, but that is a bit advanced plus resource heavy and I won't cover it here.
what is that music?
This is called "Complicate ya" and it a youtube internal music file.
Great lesson thank you! But how
can I add alpha ( 0.7 for example) to the surface?
You sandwich the drawing of the sprite between ->
draw_set_alpha(0.7);
draw_sprite_....
draw_set_alpha(1);
hope that helps
@@1upIndie Should it be a sprite of the surface itself?
surf = surface_create (guiWidth, guiHeight);
surface_set_target (surf);
var c = с_black;
draw_clear(c);
draw_set_alpha(0.7);
draw_sprite (spr_surf,0,x,y);
draw_set_alpha(1);
surface_reset_target();
I'm doing something similar, but GMS throws an error
@@skyrimhunton Nah, 8:12, sandwich the draw_set_alpha there.
@@skyrimhunton If you have questions or issues, maybe drop by in my discord help section where other developers actually help out.
Hahaha, the #region thing will be more usefull to me than the fog of war.
I have codes of 200+ lines
The video is very usefull for me because I can draw black thing but I wasn't able to draw transparency on black for lights an view in my 2D top down game.
Also, if I have a room of like 20K by 20K, will it work or will I need to do a sort of chunk loading.
Does it work on 1.4 ?
Well. it will work on any gms as far as I can see. But you cannot make the surface on 20k by 20k. That would be a bit much for the game. So here try to refresh the surface and place it around your camera.