1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Draw_Shape Functions Incorrect

Discussion in 'Programming' started by Ragster, Dec 1, 2019.

  1. Ragster

    Ragster Member

    Joined:
    Jun 21, 2016
    Posts:
    20
    So I'm having a problem drawing shapes. Some of the positioning is off, looking at the image below and the code corresponding to it. The top 2 bars are being drawn twice as large due to a setting in-game. The bottom 2 bars are being drawn at regular 1:1 size. As you can see the lines in the middle are sometimes 1 pixel off, yet the code draws each line similarly. I'm having a hard time figuring out what is causing this.

    error.png

    The script that draws health bars:
    Code:
    /// interface_bar(x,y,w,h,color,segments,length)
    var seg = argument2/(max(argument5,1));
    var c1 = merge_colour(argument4,0,0.4);
    var c2 = merge_colour(argument4,0,0.8);
    draw_rectangle_colour(argument0,argument1,argument0+argument2-1,argument1+argument3-1,c1,c1,c1,c1,false);
    draw_rectangle_colour(argument0,argument1,argument0+(argument2*clamp(argument6,0,1))-1,argument1+argument3-1,argument4,argument4,argument4,argument4,false);
    draw_rectangle_colour(argument0,argument1,argument0+argument2-1,argument1+argument3-1,c2,c2,c2,c2,true);
    for (var i = 1; i < argument5; i++) draw_line_colour(argument0+(i*seg),argument1-1,argument0+(i*seg),argument1+argument3-1,c2,c2);
    The object that draws the bars, in the Draw GUI event:
    Code:
    interface_bar((global.gui_width*0.5)-225,global.gui_height-8,450,5,interface_color_secondary,8,content.save[?"player.health"]);
    interface_bar((global.gui_width*0.5)-225,global.gui_height-17,450,5,interface_color_primary,8,content.save[?"player.energy"]);
    The object that sets the GUI size from a user setting:
    Code:
    global.gui_scale = content.data[?"config.video.interface_scale"];
    global.gui_width = floor(global.display_width/global.gui_scale);
    global.gui_height = floor(global.display_height/global.gui_scale);
    display_set_gui_maximise(global.gui_scale,global.gui_scale);
     
  2. Ido-f

    Ido-f Member

    Joined:
    Feb 19, 2018
    Posts:
    135
    Maybe you changed the gui scale but didn't adjust the x-offset?
    That would make the hard-coded -225 wrong.
     

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