S
Samus
Guest
Hi! So lately I've been working on a (I think) cool game that's like a Metroid fan game. It's been a great learning experience for me as I've figured out all kinds of stuff about how to make a stable platformer, aiming guns, using particles, and drawing sprites at different angles in order to make realistic animations that would normally require skeletal animation. However, recently I've hit a road bump: Surfaces.
I'm trying to add some basic lighting to my game. (Metroid is kind of a scary game, so having some darkness would really add to that atmosphere.) I want to have the whole room to have a transparent gray overlay, with light coming out of Samus' visor illuminating some of the stuff in front of her. I downloaded the Shader Tutorial for game maker 1.4, and thought that I had it down, so I took what I learned and applied it to my game. Surprisingly, nothing happened. The game looked exactly the same as it did before, the surfaces weren't effecting my view at all.
It looks like garbage, I know.
After some meddling, I decided to cut my losses and try another tutorial I found on YouTube. I followed it to the letter, but the same thing happened: Nothing! I then realized the similarities between both tutorials: Neither of them used views and neither of them were side-scrollers! The surface probably wasn't drawing where I needed it to because it wasn't drawing onto the view. So I came up with this bit of code I placed inside an object called obj_lighting (I decided to first do the gray overlay, then add lights later.)
Now for some bizzare reason, this code produces a black screen with nothing on it except the stuff I had another object draw to the GUI layer.
But if I remove "view_surface_id[view_current] = dark" it doesn't draw the gray overlay, and nothing happens as before. I think that when I use this code it is drawing on an area of the room that doesn't have the view, but I don't know why or how to fix it. Any help would be greatly appreciated. Thank you!
I'm trying to add some basic lighting to my game. (Metroid is kind of a scary game, so having some darkness would really add to that atmosphere.) I want to have the whole room to have a transparent gray overlay, with light coming out of Samus' visor illuminating some of the stuff in front of her. I downloaded the Shader Tutorial for game maker 1.4, and thought that I had it down, so I took what I learned and applied it to my game. Surprisingly, nothing happened. The game looked exactly the same as it did before, the surfaces weren't effecting my view at all.
It looks like garbage, I know.
After some meddling, I decided to cut my losses and try another tutorial I found on YouTube. I followed it to the letter, but the same thing happened: Nothing! I then realized the similarities between both tutorials: Neither of them used views and neither of them were side-scrollers! The surface probably wasn't drawing where I needed it to because it wasn't drawing onto the view. So I came up with this bit of code I placed inside an object called obj_lighting (I decided to first do the gray overlay, then add lights later.)
Code:
///In the Create Event
globalvar dark; //Create a global variable to hold my surface.
dark = surface_create(view_wview,view_hview); //Create a surface and store it in said global variable.
Code:
///In the Step Event
if(surface_exists(dark)) //Check to see if the surface exists. (We don't want memory leaks!)
{
surface_set_target(dark); //Set the drawing target to the surface.
//view_surface_id[view_current] = dark; //Draw the current view onto the surface.
draw_clear_alpha(c_ltgray,0.85); //Clear the surface and put a gray overlay on it.
surface_reset_target(); //Reset the drawing target so that the computer doesn't freak out on me.
}
else dark = surface_create(view_wview,view_hview); //If the surface (dark) doesn't exist, make it.
Code:
///In the Draw Event
draw_surface(dark,view_xview[view_current],view_yview[view_current]); //Draw the surface.
Now for some bizzare reason, this code produces a black screen with nothing on it except the stuff I had another object draw to the GUI layer.
But if I remove "view_surface_id[view_current] = dark" it doesn't draw the gray overlay, and nothing happens as before. I think that when I use this code it is drawing on an area of the room that doesn't have the view, but I don't know why or how to fix it. Any help would be greatly appreciated. Thank you!