M
maxta12
Guest
Hey guys I'm having a really hard time figuring this out, I need suggestions on how I could proceed.. I'm making a TDS that has different office areas, and corridors (for example), but I don't want anything inside these rooms/areas to be visible until the door has been opened. So far what I have is drawing a surface that covers the entire game room (view_surface) and a code that reveals a room pretty much exactly how I want it, but its so dang cpu intensive its not even funny, here's my code (which is in my door's draw event) (also this is tailored right now for a sliding door that is facing up/down):
and in the create event what is also relevant:
I'm really looking for suggestions on either how to improve this code to be much less cpu intensive or a better way to reveal only certain rooms within the game room. Any help thoughts or questions are appreciated!
Code:
draw_self()
//set temp vars
var xleftscan = false;
var xrightscan = false;
var yupscan = false;
var ydownscan = false;
var xleftscan2 = false;
var xrightscan2 = false;
if first_open = false
{
//upscan
//start by dealing with the width of the line
//left x stretch
for (i=0;i<500;i+=1)//i can be considered the max the line will extend
{
if !collision_line(x,y+line1_y,x-i,y+line1_y,wall,1,1)
{
xleftscan = true
surface_set_target(obj_view_region.view_surface)
draw_set_blend_mode(bm_subtract)
draw_line(x,y+line1_y,x-i,y+line1_y)
draw_set_blend_mode(bm_normal)
surface_reset_target()
}
else
{
xleftscan = false
}
//right x stretch
if !collision_line(x,y+line1_y,x+i,y+line1_y,wall,1,1)
{
xrightscan = true
surface_set_target(obj_view_region.view_surface)
draw_set_blend_mode(bm_subtract)
draw_line(x,y+line1_y,x+i,y+line1_y)
draw_set_blend_mode(bm_normal)
surface_reset_target()
}
else
{
xrightscan = false
}
}
//1.check that both sides have been maxed out on the x axis
//2.move up on the y axis
if xleftscan = false
{
if xrightscan = false
{
if !collision_line(x,y,x,y+line1_y+1,wall_horizontal,1,1)
{
yupscan = true
line1_y += 1
}
else
{
yupscan = false
}
}
}
//downscan
//start by dealing with the width of the line
//left x stretch
for (ii=0;ii<500;ii+=1)//i can be considered the max the line will extend
{
if !collision_line(x,y+line2_y,x-ii,y+line2_y,wall,1,1)
{
xleftscan2 = true
surface_set_target(obj_view_region.view_surface)
draw_set_blend_mode(bm_subtract)
draw_line(x,y+line2_y,x-ii,y+line2_y)
draw_set_blend_mode(bm_normal)
surface_reset_target()
}
else
{
xleftscan2 = false
}
//right x stretch
if !collision_line(x,y+line2_y,x+ii,y+line2_y,wall,1,1)
{
xrightscan2 = true
surface_set_target(obj_view_region.view_surface)
draw_set_blend_mode(bm_subtract)
draw_line(x,y+line2_y,x+ii,y+line2_y)
draw_set_blend_mode(bm_normal)
surface_reset_target()
}
else
{
xrightscan2 = false
}
}
//1.check that both sides have been maxed out on the x axis
//2.move down on the y axis
if xleftscan2 = false
{
if xrightscan2 = false
{
if !collision_line(x,y,x,y+line2_y-1,wall_horizontal,1,1)
{
ydownscan = true
line2_y -= 1
}
else
{
ydownscan = false
}
}
}
}
Code:
line1_y = 0
line2_y = 0
first_open = true