- Title: Fake light
- Description: Create simple, fake light
- GM Version: Studio and 8.1
- Registered: 8.1 yes, studio? Probably, need confirmation please.
- File Type: GMZ & GM81
- File Size: 1.3mo
- File Link: tuto_fake_light_studio.zip (Studio)
- File Link:tuto_fake_light.gm8.zip (8.1)
- Required Extension: None
- Required DLL: None
You may be interested by my asset on Marketplace: Fake light II
First: this tutorial is a basic one and it DOES NOT HANDLE SHADOWS!!!
I often see people(beginner) requesting light tutorial...like me when I first start with GM.
Game Maker looks like : "Hey, that's look easy to make a game with that!".
And yeah, thats right. Everyone with basics computer knowledges can actually make a 'game' with GM.
And newcomers want classic feature like lights!
There is a lot of light tutorial but many of them are complicated because they are made to create a 'realistic' light.
They are good! Some damn good! But let's keep it simple for the newcomers.
Sometimes, advanced users seems to forget what it is for a newbie to gather informations about something completely unknown.
Every day I read new topics about:
How can I: inventory, healthbar, move, bounce and lights. (and many other things, I know!)
You cannot throw hundreds of lines to a newbie and tel him: "That's easy!".
So, here is a very simple way to do a FAKE light. Really easy to copy/paste and understand.
What I wanted (back in 2011) is to put all my screen black (well not pitch black, but really dark) and
simply substract a hole in it where the player stand. Like on NES' Dragon Warrior or SNES's famous Zelda:
Ok. How it work? With a surface. We will create a surface, paint it in black, draw a hole in it and then
draw that surface.
My downloadable example has 5 rooms. I'll show you 5 simple way to make fake lights.
I've got 2 objects.
obj_player_0 stand still. No code (except for moving).
Easy huh!? No? Maybe some functions look unfamiliar...but the important line is the draw_circle part. You can draw a square, rectangle, triangle...sprites! (on room2...)
Easy huh?...Yeah more complex if you're not familiar with 'for loops'. The thing here is that we draw many circles (bbb): A large one then a smaller, and a smaller and a smaller and a smaller, etc.... Each circle apply a small alpha value on each other.
Let's change the value of bbb to 5:
You can see the 5 circles!
Now let's draw(well, substract!) a sprite instead of a circle. We use draw_sprite_ext and ajust the angle to follow the player's image_angle.
Looks like a flashlight:
Thats it! This is how I understood how surface works for that simple light....I mean fake light.
Edit January 07-2014.
2 more rooms.
Room3: If you are using views. (Same picture as room0)
Room4: Multiple lights.
2 objects create light here. Normal player and a static player. Both objects substract a circle on the surface.
Edited by NazGhuL, 11 November 2014 - 01:18 PM.