GM:S 1.4 RPG Clouds (Overhead)

Discussion in 'Programming' started by Murr_, Jun 26, 2016.

  1. Murr_

    Murr_ Member

    Joined:
    Jun 26, 2016
    Posts:
    28
    Okay so i was trying to do myself, but i keep getting into some problems. First i'm trying to make this: clouds in the atmosphere effect, from up above.

    Fara & The Eye of Darkness - ZackBellGames
    [​IMG]

    Hyper Light Drifter - HeartMachine
    [​IMG]

    You see those clouds scrolling horizontally across the screen. This is the effect i want to achieve, using SURFACES. I already done some work already but although not much.

    Code:
    ///CREATE: Initialize the surface*************************************************************************
    surf_overworld = surface_create(view_wview[0], view_hview[0]);
    
    hspeed = 2;
    
    scroll_num = 1;
    
    Code:
    ///DRAW: Draw the surf_overworld**********************************************************************
    scroll_num += hspeed
    
    if (!surface_exists(surf_overworld)) {
       surf_overworld = surface_create(room_width, room_height);   
    }
    
    surface_set_target(surf_overworld);
    draw_clear(c_black);
    draw_background_general(bg_overworld_cloud_map, -254, 256, 256, 256, x, y, 4, 4, 0, c_black, c_black, c_black, c_black, 1);
    
    surface_reset_target();
    
    if (surface_exists(surf_overworld)) {
        draw_surface_ext(surf_overworld, x, y, 1, 1, 0, c_white, 0.6);
    }
    The problems with this, is that i only get a huge single rectangle part of the BG and not almost all of it. And also it does not loop continuously.

    bg_overworld_cloud_map (256, 256);
    [​IMG]

    Room Size: 940 x 680

    Any suggestions or ideas?
     
  2. bojack29

    bojack29 Member

    Joined:
    Jun 21, 2016
    Posts:
    407
    What you could do is simply have a cloud object with many different cloud sprites. As they move across the screen, have them draw themselves to a global surface and draw the surface with an alpha around .7. Youll have to clear the surface after every frame tho. This way you can have clouds that dont add in alpha values.
     
  3. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,767
    Okay, first you are creating the surface as the size of the view, but in the check of the draw event you have the room size... which is it? Next, you will want to set the the surface to draw at the view x/y position and scroll the background along that. You are also drawing the background at the x/y position which is wrong as you want to draw it at the (0, 0 + scroll_num) position - all surface drawing is done from (0,0). Finally, you want to use draw_clear_alpha to clear the alpha of the surface to 0 before drawing, and I'd use draw_background_tiled instead of the general function so that you don't have to worry about it repeating incorrectly...
     
  4. Murr_

    Murr_ Member

    Joined:
    Jun 26, 2016
    Posts:
    28
    So what i interpreted from this, and i changed.
    Code:
    ///Draw the surf_overworld**********************************************************************
    scroll_num += hspeed
    
    if (!surface_exists(surf_overworld)) {
       surf_overworld = surface_create(room_width, room_height); 
    }
    
    if (surface_exists(surf_overworld)) {
        surface_set_target(surf_overworld);
            draw_clear_alpha(c_black, 0);
            draw_surface(surf_overworld, 0, 0);
            draw_background_tiled(bg_overworld_cloud_map, 0, 0);
       
        surface_reset_target();
    }
    
    draw_surface_ext(surf_overworld, 0 + scroll_num, 0, 1, 1, 0, c_black, 0.6);
    When i do this, it still doesn't draw the BG. And NOTE: In the create event i changed the created surface to the size of (room_width, room_height).
     
  5. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,767
    Okay, try this:

    Code:
    scroll_num += hspeed
    
    if (!surface_exists(surf_overworld)) {
       surf_overworld = surface_create(room_width, room_height);
    }
    else {
        surface_set_target(surf_overworld);
        draw_clear_alpha(c_black, 0);
        draw_background_tiled(bg_overworld_cloud_map, 0, scroll_num);
        surface_reset_target();
        draw_surface_ext(surf_overworld, 0, 0, 1, 1, 0, c_black, 0.6);
    }
    
     
  6. Murr_

    Murr_ Member

    Joined:
    Jun 26, 2016
    Posts:
    28
    Ah, i see. Thanks i didn't notice that you had to only had to draw the surface at the end, and my scroll_num was supposed to hold a argument. Thanks dood! I can finally start doing some mad, crazy things!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice