Setting up black sidebars

Hi guys. Hope the title is a bit informative but in case more info is needed, here is the longer version of what I'm trying to do. Now I have set up a camera for my game and now I'm trying to implement a new feature to it.
Specifically what I'm trying to do is have a black outline on both the left and right edges of the screen. Having the actual room displayed between theese two outlines. Problem is I don't have the slightest clue how to do this.
Help is always appreciated. Until then I'm gonna try to fix it myself. Emphasis on try.
 

eimie

Member
Hi. Do I understand you right that you don't want the game to stretch in fullscreen? Just go to Game Options -> [your desired platform] -> Graphics and select "Keep aspect ratio".
 

jobjorgos

Member
Here is the simple code (that only works with 1920x1080):

Draw GUI:
GML:
draw_set_color(c_black);
draw_rectangle(0,0,200,1080, false);
draw_rectangle(1720,0,1920,1080, false);


Here is the advaced code:

Create:
GML:
edgeWidth = (oCamera.viewW * 0.1);

Draw GUI:
GML:
draw_set_color(c_black);
draw_rectangle(0,0,edgeWidth,oCamera.viewH,false);
draw_rectangle(oCamera.viewW,0,oCamera.viewW-edgeWidth,oCamera.viewH,false);
 
Last edited:
Here is the simple code (that only works with 1920x1080):

Draw GUI:
GML:
draw_set_color(c_black);
draw_rectangle(0,0,200,1080, false);
draw_rectangle(1720,0,1920,1080, false);


Here is the advaced code:

Create:
GML:
edgeWidth = (oCamera.viewW * 0.1);

Draw GUI:
GML:
draw_set_color(c_black);
draw_rectangle(0,0,edgeWidth,oCamera.viewH,false);
draw_rectangle(oCamera.viewW,0,oCamera.viewW-edgeWidth,oCamera.viewH,false);
Hi and thanks for the help but now I've got another problem. I input the code as instructed and sometimes it works.
Key word being sometimes. Other times the bars are drawn in the middle of the screen.
 

jobjorgos

Member
Did you use the following code?
GML:
draw_set_color(c_black);
draw_rectangle(0,0,200,1080, false);
draw_rectangle(1720,0,1920,1080, false);


if so, then the reason it changes it because your game window size, or camera view size changed. If you want the black bars work flexible with all scenarios u should use the advaced code:
Code:
draw_set_color(c_black);
draw_rectangle(0,0,edgeWidth,oCamera.viewH,false);
draw_rectangle(oCamera.viewW,0,oCamera.viewW-edgeWidth,oCamera.viewH,false);


if you already used the advanced code and you still get this problem lemme know
 
Did you use the following code?
GML:
draw_set_color(c_black);
draw_rectangle(0,0,200,1080, false);
draw_rectangle(1720,0,1920,1080, false);


if so, then the reason it changes it because your game window size, or camera view size changed. If you want the black bars work flexible with all scenarios u should use the advaced code:
Code:
draw_set_color(c_black);
draw_rectangle(0,0,edgeWidth,oCamera.viewH,false);
draw_rectangle(oCamera.viewW,0,oCamera.viewW-edgeWidth,oCamera.viewH,false);


if you already used the advanced code and you still get this problem lemme know
Below follows the code as put in

GML:
draw_set_color(c_black)
draw_rectangle(0,0,edgeWidth,obj_aspect_manager.view_height,false)
draw_rectangle(obj_aspect_manager.view_width,0,obj_aspect_manager.view_width-edgeWidth,obj_aspect_manager.view_height,false)
 
Last edited:

jobjorgos

Member
is obj_aspect_manager your camera? if so, then do something like this in its room start event (or create event if persistent object):
camera_set_view_size(view_camera[0],view_width,view_height);

and to what did you set view_width and view_height inside obj_aspect_manager?
do something like this in its room start event (or create event if persistent object):
GML:
aspect_ratio = display_get_width()/display_get_height();
   
view_height=540;
view_width=round(view_height*aspect_ratio);

if(view_width & 1) view_width++;
if(view_height & 1) view_height++;

max_window_scale = min(floor(display_get_width()/view_width),floor(display_get_height()/view_height));
if(view_height * max_window_scale == display_get_height())
    max_window_scale--;
   
window_scale = max_window_scale;

camera_set_view_size(view_camera[0],view_width,view_height);
surface_resize(application_surface,display_get_width(),display_get_height());
display_set_gui_size(view_width,view_height);
 
Top