• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Side Scrolling Surfaces.

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.
upload_2017-12-22_16-7-35.png
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.
upload_2017-12-22_16-5-38.png

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!
 
S

Samus

Guest
All right, now I've got really big problems: I watched this tutorial by RealTuts GML
, and used its lighting system instead. Initially the program still didn't work, as before everything looked the same. Then I gave my obj_lighting object a sprite and made it visible, now whenever I try to start the program, Windows says:

"Game Maker Studio 1.4 has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."

I'm starting to think that its not anything I'm doing, but I have stumbled on a Software issue.
 
Top