#How can I improve my current flashlight prototype?

1 messages · Page 1 of 1 (latest)

shadow pasture
#

Hi!! :3 I'm working on a prototype for a flashlight mechanic by drawing a surface and drawing a sprite that subtracts from that surface, but when rotating it it looks very blocky. Any way I could improve the visuals of it? I've attached the sprite and a video showing it off :3 Here's the draw event code as well! Create code is just surface = -1;

if (!surface_exists(surface)) {
    surface = surface_create(room_width, room_height);
    //view_surface_id[0] = surface;
}

surface_set_target(surface);
draw_clear(c_black);
//
gpu_set_blendmode(bm_subtract);
var _i = point_direction(obj_player.x, obj_player.y, mouse_x, mouse_y);
draw_sprite_ext(spr_flashlight_light, 0, obj_player.x, obj_player.y - 4, 1, 1, _i, c_white, 1);
gpu_set_blendmode(bm_normal);
//
surface_reset_target();
draw_surface(surface, 0, 0);

Ty!! :3

dense parcel
#

lagtrain????

shadow pasture
#

Yeah I have taste 😌

dense parcel
#

ive also had taste

#

until i listened to lagtrain soooooo many times i got sick of it

#

so now my taste is lost and unrecoverable

frigid yew
#

when you draw the final surface into the world, if you enable texture filtering, it will be smoother and might help a bit

#

like gpu_set_texfilter(true) before and then false afterwards

shadow pasture
#

Oh yeah that really helped, ty! :3

frigid yew
#

how does it look now?

#

you could also increase the resolution of the surface if it isn't good enough

shadow pasture
#

It looks perfectly smooth! Let me record some real quick.

#

One additional question though: how would I go about making it so the sprite wouldn't draw over a specific object (like a collision square) or beyond it? Like a line-of-sight thing?

frigid yew
#

well the usual method to have shadows like that is to use a shader to sort of extrude the walls away from the light
juju has a library called Bulb that may be useful for that

sharp lynx
#

there is also an old gamemaker blog post about that.. let met see if i can find it

shadow pasture