🔴 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

КОМЕНТАРІ • 44

  • @digusbickus
    @digusbickus Рік тому +1

    This is great, thank you! Easy to understand, not very complicated, but each step very thoroughly explained. Great show, good stuff!

    • @1upIndie
      @1upIndie  Рік тому +1

      Neat! Glad to hear it helped you out.

    • @digusbickus
      @digusbickus Рік тому

      @@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.

  • @ryangudger91
    @ryangudger91 4 роки тому +1

    This is spot on. Easy to use.

  • @cleancrevice2100
    @cleancrevice2100 Рік тому +1

    thanks!

    • @1upIndie
      @1upIndie  Рік тому

      You are more then welcome mate!

  • @coronagalvez19
    @coronagalvez19 4 роки тому

    Wow, didn't think you would actually do it, thank you so very much !!!

    • @1upIndie
      @1upIndie  4 роки тому

      Would some random guy from the internet lie to you?... Actually, most would do :DDD

  • @streetfighte6
    @streetfighte6 4 роки тому +1

    your tutorial has everything I need

  • @professionalquestion5415
    @professionalquestion5415 4 роки тому

    1up Indie... Making great content like always.

  • @bombardier1588
    @bombardier1588 4 місяці тому +1

    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

    • @1upIndie
      @1upIndie  4 місяці тому

      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!

  • @OldJobobo
    @OldJobobo 4 місяці тому +1

    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

    • @1upIndie
      @1upIndie  4 місяці тому

      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.

    • @OldJobobo
      @OldJobobo 4 місяці тому

      @@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.

  • @dimusikus
    @dimusikus 2 роки тому +2

    отлично, показательно.

  • @user-zr1gg2yp5o
    @user-zr1gg2yp5o Рік тому +1

    Благодарю!!!!:)

  • @lixoyt8879
    @lixoyt8879 4 роки тому

    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?

    • @1upIndie
      @1upIndie  4 роки тому

      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

  • @posseslayer280
    @posseslayer280 3 роки тому

    Great work! What about limiting the field of view if you have a wall?

    • @1upIndie
      @1upIndie  3 роки тому

      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.

  • @WyMustIGo
    @WyMustIGo 3 роки тому +1

    what is that music?

    • @1upIndie
      @1upIndie  3 роки тому

      This is called "Complicate ya" and it a youtube internal music file.

  • @skyrimhunton
    @skyrimhunton 2 роки тому +1

    Great lesson thank you! But how
    can I add alpha ( 0.7 for example) to the surface?

    • @1upIndie
      @1upIndie  2 роки тому +1

      You sandwich the drawing of the sprite between ->
      draw_set_alpha(0.7);
      draw_sprite_....
      draw_set_alpha(1);
      hope that helps

    • @skyrimhunton
      @skyrimhunton 2 роки тому

      @@1upIndie Should it be a sprite of the surface itself?

    • @skyrimhunton
      @skyrimhunton 2 роки тому

      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

    • @1upIndie
      @1upIndie  2 роки тому +1

      @@skyrimhunton Nah, 8:12, sandwich the draw_set_alpha there.

    • @1upIndie
      @1upIndie  2 роки тому +1

      @@skyrimhunton If you have questions or issues, maybe drop by in my discord help section where other developers actually help out.

  • @survival_man7746
    @survival_man7746 3 роки тому +1

    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 ?

    • @1upIndie
      @1upIndie  3 роки тому

      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.