1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Black bars not showing correctly

Discussion in 'Programming' started by Megax60, May 6, 2019.

  1. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    85
    i made the game scale pixel perfect, but the black bars on the sides are moved:
    [​IMG]

    i followed this guide. The resolution is 640 x 480. I really dont know what im doing wrong

    obj_system create event:
    Code:
    //Resize
    application_surface_draw_enable(false);
    window_set_fullscreen(true);
    global.MonitorW = display_get_width();
    global.MonitorH = display_get_height();
    global.Xoffset = (global.MonitorW - 640) / 2;
    global.Yoffset = (global.MonitorH - 480) / 2;
    
    if(global.MonitorW >= 1280 && global.MonitorH >= 960){
        surface_resize(application_surface,1280,960)
        global.Xoffset = (global.MonitorW - 1280)/2;
        global.Yoffset = (global.MonitorH - 960)/2;
    }
    
    draw gui end event:
    Code:
    //Resize screen
    draw_surface_ext(application_surface,global.Xoffset,global.Yoffset,1,1,0,c_white,1);
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,974
    Code:
    global.Xoffset = (global.MonitorW / 2) - (surface_get_width(application_surface) / 2);
    global.Yoffset = (global.MonitorH / 2) - (surface_get_height(application_surface) / 2);
    That's what I'd do... :)
     
  3. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    85
  4. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,974
    Add breakpoints to the code and step through it in the debugger to make sure that the values are those that you expect. Also, you are using the DISPLAY width, but drawing in the GUI event... so if the GUI layer is not the same size as the display, then you'll get issues (and I suspect that is where the problem lies here). Check the GUI width/height and resize it as required, or change the display width/height values for GUI width/height values.
     
  5. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    85
    you are right, the draw gui is the problem, i changed it to post draw. thanks ;)
     
    Nocturne likes this.

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