K
krisstastic
Guest
I'm using a simple "light" effect with surfaces. It all works great, but when I walk, the light surface moves in parallax to the character. For example, if I walk to the right, you can see the light surface move to the left slightly and then follow the view accordingly. The character has code that moves the view in a way that slows down the view so it isn't so jumpy. This code moves the light surface, but it shouldn't.
The Light Creation code:
CREATE EVENT-
globalvar light;
light=surface_create(view_wview,view_hview)
brightness=200
col=make_color_hsv(80,0,brightness)
STEP EVENT-
col=make_color_hsv(80,0,brightness)
surface_set_target(light);
draw_set_color(col);
draw_rectangle(0,0,room_width,room_height,false);
surface_reset_target();
DRAW EVENT-
draw_set_blend_mode(bm_subtract);
draw_surface(light,view_xview,view_yview);
draw_set_blend_mode(bm_normal);
Light source code:
END STEP EVENT-
size=sprite_get_height(sprite_index)-16;
draw_set_blend_mode(bm_subtract);
surface_set_target(light);
draw_ellipse_color(x-size/2-view_xview,y-size/2-view_yview,x+size/2-view_xview,y+size/2-view_yview,c_white,c_black,false);
surface_reset_target();
draw_set_blend_mode(bm_normal);
Character camera code:
STEP EVENT-
view_xview[0]+=((x-(view_wview[0]/2))-view_xview[0])*0.1
view_yview[0]+=((y-(view_hview[0]/2))-view_yview[0])*0.1
Removing the camera code fixes it, but I've gotten it to work before, I just don't remember how. Any help is appreciated.
The Light Creation code:
CREATE EVENT-
globalvar light;
light=surface_create(view_wview,view_hview)
brightness=200
col=make_color_hsv(80,0,brightness)
STEP EVENT-
col=make_color_hsv(80,0,brightness)
surface_set_target(light);
draw_set_color(col);
draw_rectangle(0,0,room_width,room_height,false);
surface_reset_target();
DRAW EVENT-
draw_set_blend_mode(bm_subtract);
draw_surface(light,view_xview,view_yview);
draw_set_blend_mode(bm_normal);
Light source code:
END STEP EVENT-
size=sprite_get_height(sprite_index)-16;
draw_set_blend_mode(bm_subtract);
surface_set_target(light);
draw_ellipse_color(x-size/2-view_xview,y-size/2-view_yview,x+size/2-view_xview,y+size/2-view_yview,c_white,c_black,false);
surface_reset_target();
draw_set_blend_mode(bm_normal);
Character camera code:
STEP EVENT-
view_xview[0]+=((x-(view_wview[0]/2))-view_xview[0])*0.1
view_yview[0]+=((y-(view_hview[0]/2))-view_yview[0])*0.1
Removing the camera code fixes it, but I've gotten it to work before, I just don't remember how. Any help is appreciated.