O
Outseidr
Guest
Hey guys, so I'm trying to draw a few surface codes at the same time that seem to be clashing together. So the first one is to fit to screen without scaling, and the other is for drawing lighting around objects that need lighting drawn around them. So the problem is that the screen resolution surface will be the only surface being drawn while the lighting surface draw shows absolutely nothing, however when i deactivate the resolution surface the lighting works perfectly
object resolution and lighting:
create event for resolution:
window_set_rectangle(0, 0, display_get_width(), display_get_height());
window_w = window_get_width();
window_h = window_get_height();
window_x = window_get_x();
window_y = window_get_y();
var _w = window_get_width();
var _h = window_get_height();
var _x = window_get_x();
var _y = window_get_y();
if (_w != window_w) or (_h != window_h)
{
view_wview[0] = _w;
view_hview[0] = _h;
view_wport[0] = _w;
view_hport[0] = _h;
view_xview[0] += _x - window_x;
view_yview[0] += _y - window_y;
surface_resize(application_surface,_w,_h);
display_reset(0,0);
window_w = _w;
window_h = _h;
}
window_x = _x;
window_y = _y;
create event for Lighting:
///lighting
alpha = .01
tt = -1 //either 1 or -1 as the number is multiplied to create result
alarm[0] = 2000
surf = surface_create(room_width,room_height)
surface_set_target(surf);
draw_clear_alpha(c_black, 0);
surface_reset_target();
step event resolution:
var _w = window_get_width();
var _h = window_get_height();
var _x = window_get_x();
var _y = window_get_y();
view_wview[0] = _w;
view_hview[0] = _h;
view_wport[0] = _w;
view_hport[0] = _h;
view_xview[0] += _x - window_x;
view_yview[0] += _y - window_y;
surface_resize(application_surface,_w,_h);
display_reset(0,0);
window_w = _w;
window_h = _h;
window_x = _x;
window_y = _y;
step event lighting:
///lighting
if (surface_exists(surf))
{
surface_set_target(surf)
//draw dark overlay
draw_set_colour(c_black)
draw_set_alpha(alpha)
draw_rectangle(0,0,room_width, room_height, false)
//set light circles
draw_set_blend_mode(bm_subtract)
draw_set_colour(c_black)
draw_set_alpha(.2)
//draw light circles
with (obj_c01)
{
draw_circle(x + random_range(-1,1), y + random_range(-1,1), 240 + random_range(-1,1),false)
}
draw_set_colour(c_white)
draw_set_alpha(1)
with (obj_c01)
{
draw_circle(x + random_range(-1,1), y + random_range(-1,1), 160 + random_range(-1,1),false)
}
//reset all draws
draw_set_blend_mode(bm_normal)
draw_set_alpha(1)
surface_reset_target()
}
else
{
surf = surface_create(room_width,room_height)
surface_set_target(surf)
draw_clear_alpha(c_black,0)
surface_reset_target()
}
draw event for lighting:
if !surface_exists(surf)
{
surf = surface_create(room_width,room_height)
}
else
{
if (view_current == 0)
{
draw_surface(surf,0,0)
}
}
any ideas? Would appreciate some help on this
object resolution and lighting:
create event for resolution:
window_set_rectangle(0, 0, display_get_width(), display_get_height());
window_w = window_get_width();
window_h = window_get_height();
window_x = window_get_x();
window_y = window_get_y();
var _w = window_get_width();
var _h = window_get_height();
var _x = window_get_x();
var _y = window_get_y();
if (_w != window_w) or (_h != window_h)
{
view_wview[0] = _w;
view_hview[0] = _h;
view_wport[0] = _w;
view_hport[0] = _h;
view_xview[0] += _x - window_x;
view_yview[0] += _y - window_y;
surface_resize(application_surface,_w,_h);
display_reset(0,0);
window_w = _w;
window_h = _h;
}
window_x = _x;
window_y = _y;
create event for Lighting:
///lighting
alpha = .01
tt = -1 //either 1 or -1 as the number is multiplied to create result
alarm[0] = 2000
surf = surface_create(room_width,room_height)
surface_set_target(surf);
draw_clear_alpha(c_black, 0);
surface_reset_target();
step event resolution:
var _w = window_get_width();
var _h = window_get_height();
var _x = window_get_x();
var _y = window_get_y();
view_wview[0] = _w;
view_hview[0] = _h;
view_wport[0] = _w;
view_hport[0] = _h;
view_xview[0] += _x - window_x;
view_yview[0] += _y - window_y;
surface_resize(application_surface,_w,_h);
display_reset(0,0);
window_w = _w;
window_h = _h;
window_x = _x;
window_y = _y;
step event lighting:
///lighting
if (surface_exists(surf))
{
surface_set_target(surf)
//draw dark overlay
draw_set_colour(c_black)
draw_set_alpha(alpha)
draw_rectangle(0,0,room_width, room_height, false)
//set light circles
draw_set_blend_mode(bm_subtract)
draw_set_colour(c_black)
draw_set_alpha(.2)
//draw light circles
with (obj_c01)
{
draw_circle(x + random_range(-1,1), y + random_range(-1,1), 240 + random_range(-1,1),false)
}
draw_set_colour(c_white)
draw_set_alpha(1)
with (obj_c01)
{
draw_circle(x + random_range(-1,1), y + random_range(-1,1), 160 + random_range(-1,1),false)
}
//reset all draws
draw_set_blend_mode(bm_normal)
draw_set_alpha(1)
surface_reset_target()
}
else
{
surf = surface_create(room_width,room_height)
surface_set_target(surf)
draw_clear_alpha(c_black,0)
surface_reset_target()
}
draw event for lighting:
if !surface_exists(surf)
{
surf = surface_create(room_width,room_height)
}
else
{
if (view_current == 0)
{
draw_surface(surf,0,0)
}
}
any ideas? Would appreciate some help on this
Last edited by a moderator: