Tails1000
Member
I'm creating a top down RPG and am planning on having water sources such as lakes reflect the sky above.
This is easy to achieve during the day, I just make a transparent water tile and change my background to be clouds or something.
But it's when day turns to night is where it becomes tricky. I currently have a surface that automatically adjusts it's color depending on the time of day, and when it's night it darkens everything.
I use an additive blend mode to create lights around lanterns and such, but now I want to illuminate the moon being reflected in the water.
I so far made three attempts with no results, and have been unable to find anybody online who has solved a similar problem.
Here is a pic of the results of all 3 attempts and I'll explain my code for each one...
(assets not mine obviously)
So in attempt number 1 I simply tried to add a blend mode my background. I created an object called "obj_back" and added it to my room (underneath the tile layer). The code read...
This did literally nothing, so I moved on to attempt #2.
I gave "obj_back" a simple white circle for a sprite and placed it in the lake (Underneath the tile layer of course) and gave it this code...
It drew the circle, and underneath the tile layer... but it provided no illumination. So I moved onto my 3rd attempt.
I went into my lighting object. It controls the surface and is drawing that light around my player. I kept "obj_back" in the same spot but tried to draw the sprite from this object. My lighting object is above my tiles, because that's how I darken them.
I added this code...
That got me result #3, which is almost what I want... but since I drew it at a depth of 0 it goes on top of the tiles which is exactly what I'm trying to avoid. But when I drew it at a lower depth it didn't illuminate...
Basically I hit a brick wall, I'm not entire sure how to solve this since I'm still pretty inexperienced.
If anyone could offer advice it would be much appreciated. Or if this problem has been solved before I'd love to get pointed in the right direction. Thanks in advance!
This is easy to achieve during the day, I just make a transparent water tile and change my background to be clouds or something.
But it's when day turns to night is where it becomes tricky. I currently have a surface that automatically adjusts it's color depending on the time of day, and when it's night it darkens everything.
I use an additive blend mode to create lights around lanterns and such, but now I want to illuminate the moon being reflected in the water.
I so far made three attempts with no results, and have been unable to find anybody online who has solved a similar problem.
Here is a pic of the results of all 3 attempts and I'll explain my code for each one...
(assets not mine obviously)
So in attempt number 1 I simply tried to add a blend mode my background. I created an object called "obj_back" and added it to my room (underneath the tile layer). The code read...
Code:
---Draw Event---
var lay_id = layer_get_id("Background");
var back_id = layer_background_get_id(lay_id);
gpu_set_blendmode(bm_add);
layer_background_sprite(back_id, spr_moon);
gpu_set_blendmode(bm_normal);
I gave "obj_back" a simple white circle for a sprite and placed it in the lake (Underneath the tile layer of course) and gave it this code...
Code:
----draw event----
gpu_set_blendmode(bm_add);
draw_self();
gpu_set_blendmode(bm_normal);
I went into my lighting object. It controls the surface and is drawing that light around my player. I kept "obj_back" in the same spot but tried to draw the sprite from this object. My lighting object is above my tiles, because that's how I darken them.
I added this code...
Code:
----Draw event----
gpu_set_blendmode(bm_add);
if instance_exists(obj_back){
with (obj_back) {
draw_self();
}
}
gpu_set_blendmode(bm_normal)
Basically I hit a brick wall, I'm not entire sure how to solve this since I'm still pretty inexperienced.
If anyone could offer advice it would be much appreciated. Or if this problem has been solved before I'd love to get pointed in the right direction. Thanks in advance!