OblivionSkull21
Member
I just incorporated a shadow surface for when it is night time in my game. Right now, I have it so the player's brightness is constant, as in it isn't affected by the darkness, or any light sources. A silhouette also appears on the player if they walk behind something.
(Not relevant to the question at hand, but are these good choices, or should the darkness change the player's brightness? The game gets REAL dark at night... what are some examples of games that use these features?)
Anyway, I use bm_subtract to get the job done.
This works very well in the game. The player is subtracted from the darkness alright regardless whether I move up, down, left, or right. But, if I move diagonally at any point, it permanently throws the subtraction off by a hair of where it needs to be, like so:
It's also doing it for the purple portal just above, though I'm not sure why as that isn't moving. Any help?
EDIT: I didn't notice it before, but upon testing it in a different project, the whole surface seems to lag behind the player while they are moving and then catches up when the player stops. It looks like a “fade trail”. How do I fix this as well?
(Not relevant to the question at hand, but are these good choices, or should the darkness change the player's brightness? The game gets REAL dark at night... what are some examples of games that use these features?)
Anyway, I use bm_subtract to get the job done.
Code:
//create the surface
if !surface_exists(lightSurface){
lightSurface = surface_create(room_width,room_height);
}
surface_set_target(lightSurface);
//draw the darkness
gpu_set_blendmode(bm_normal);
draw_set_alpha(.88);
draw_rectangle(0,0,room_width,room_height,false);
draw_set_alpha(1);
//subtract player from the darkness
gpu_set_blendmode(bm_subtract);
draw_sprite(obj_player_parent.sprite_index,obj_player_parent.image_index,obj_player_parent.phy_position_x,obj_player_parent.phy_position_y);
gpu_set_blendmode(bm_normal);
//draw the surface
surface_reset_target();
draw_surface(lightSurface,0,0);
It's also doing it for the purple portal just above, though I'm not sure why as that isn't moving. Any help?
EDIT: I didn't notice it before, but upon testing it in a different project, the whole surface seems to lag behind the player while they are moving and then catches up when the player stops. It looks like a “fade trail”. How do I fix this as well?
Last edited: