
#Gamemaker studio 2 lighting code#
So if I go to the “draw end” event and run the code draw_surface(surface, obj_player.x, obj_player.y) this is what our view will look like. This might make sense because more than likely your view is set to follow the player. The first thing that you would probably think of is to draw the surface at the player’s current position. The tutorial by Zach Bell Games drew the surface at the position 0,0 and that isn’t going to work for this system because the surface would stay at the top left of the play area. We now need the surface to follow the view because it isn’t going to fill the whole room. To be able to draw the surface to the screen you need to run some code in the “draw end” event however, this is where things get a little bit tricky. Just filling the surface with black, in the step event ,doesn’t draw anything to the screen. Run the create again if the surface isn't detected You should also keep in mind that surfaces are volatile and can be deleted randomly, so always check to make sure the surface still exists. Now that this surface is exactly the size of the view I can fill the surface with a translucent black layer black inside of the step event to give the effect of darkness. Reset target surface back to the application surface Set the surface target to the new surface instead of the application surface My viewport is only 352 by 512 so I created a surface that size inside of my create event. You are able to find the size of your view by going into the room editor and looking at the section “Viewport and Cameras”. The only major difference is that instead of making a surface that is the size of the room, it will only be the size of the view / camera. To start with this process I made a create event that is very similar to the one in the Zach Bell Games tutorial. The tutorial, at Zach Bell Games, didn’t get into making a lighting system that only covers the view (as seen in that code block), so I needed to do it myself. This method doesn’t work with my endless platformer, because if a surface gets too big it will cause my game to crash.

They are making a surface the size of the entire room to create the darkness effect. Surf = surface_create(room_width, room_height) You could also create a surface the size of the current view, but I won't get into that Create a surface the size of the current room The only issue with the Zach Bell Games tutorial is that this is designed for a platformer with a fixed room size, which you can tell from this little section of code. The Zach Bell Games tutorial requires that you know a thing or two about surfaces in Gamemaker Studio 2, and even if you don’t it’s pretty easy to follow along. Keeping in mind that this game is about the player falling further and further down a hole in the ground, I thought that it would make sense that the visibility of the player would get progressively more restrictive the further down the player fell.Īfter some quick googling I found a simple little tutorial done by Zach Bell Games that looked perfect (Also if you don’t follow his work, you really should). Another idea was to have some sort of mechanic that would make my game more difficult the further you went along. The easiest change, that I thought of, was to make my game endless. After I started working on my new platformer, I made some tweaks to it to try to separate it from the game that served as the original inspiration.
#Gamemaker studio 2 lighting plus#
On the runtimes side, there is the texture groups change mentioned already, plus 2022.9 adds touch support in Windows games and raises the SDK version supported on a few console platforms - so please do read the runtime release notes carefully, as you may now need to change your setup.įor all changes/fixes since 2022.8.1 see the IDE notes page and the runtime notes page. It does also have some important changes for creating/loading Game Options, as well as various UI/UX improvements brought about by our recent website change to offer converting your old YoYo/GameMaker Account to a new Opera Account. This release also gives you the ability to control your texture groups more precisely in the texture groups editor, so that you can manage in-game loading times and memory usage. 2022.9 continues the clean-up and stability work ahead of the forthcoming LTS release, plus introduces the Inspector as a part of the default layout for all new projects (as well as a tweak to the Room Editor layout so it now uses the Inspector rather than the old custom panels).
