Jump to content


Photo
- - - - -

LITE Drag and Drop Lighting Tutorial


  • Please log in to reply
7 replies to this topic

#1 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 11 November 2010 - 10:06 PM

  • Title: LITE Drag and Drop Lighting Tutorial
  • Description: Create a simple lighting system in Game Maker 8 Lite using drag and drop only.
  • GM Version: GM 8
  • Registered: No
  • File Type: .gmk
  • File Size: 370 KB
  • File Link: lighting2.gmk
Additional Info

In this tutorial we are going to create a simple lighting system in Game Maker 8 Lite using drag and drop only. When you are finished, you will have a simple game where the player is an explorer in a dark pyramid with only his torch to guide him. You could also just download the link at the bottom if you don't want to follow the tutorial, but I highly recommend you read this!

Note that before we start, you should be in Advanced Mode (click preferences and make sure Advanced mode is ticked.) To start with, we'll need the sprites for this game. Just download the following gmk:
Resources

This game includes all our sprites. These are:
spr_player-a simple sprite of the player with four subimages of four different directions
spr_light-the torch light, with nice alpha effects :)
spr_wall-pretty self-explanatory
spr_mask-a mask of the player for smooth collisions; more on this later

It also has a background entitled bck_sand.

So now we're ready to begin. Let's start by creating an object called obj_player. Set it's sprite to spr_player and it's mask to spr_mask (the mask option can be found underneath the "persistent" check box and the parent option.) Add a create event and put in a change sprite action (found in the main1 tab). The sprite should be spr_player, with a subimage of 0 and a speed of 0. This makes sure that the player's sprite does not spin around insanely. Next, we will make movement. Add a Keyboard, Left action and add a jump to position (move tab) action with an x of -4, a y of 0, and relative checked. Then, add a change sprite action (main1 tab), set the sprite to spr_player, the subimage to 2, and the speed to 0. Let's consideer what this does. First, it jumps to a position 4 pixels to the left. Then, it sets the sprite to the left subimage. Pretty simple, huh? Now, do the same for the up, right, and down events, but they have small differences.

Up should have a x of 0, a y of -4, and a subimage of 1
Down should have a x of 0, a y of 4, and a subimage of 3
Right should have a x of 4, a y of 0, and a subimage of 0

Now that that's all done, we can add a wall object. Give it a sprite of spr_wall and you're done! Yep, that's all you need to do. We can close this up and we won't be using it again throughout the rest of the tutorial.

Next, we need to add collisions. Reopen obj_player and add a collsion event with obj_wall. In it, put the following actions:
jump to position of xprevious and yprevious (move tab)
move to contact with direction: image_index*90 maximum: 4 against: all objects (move tab)

This is a pretty complicated part, but it helps us make smooth collisions. First, when the player collides with the wall, it goes back to it's previous position. Then, it goes in the direction the player is facing until it hits the wall again. This makes sure the player cannot go inside the wall.

Now for the last, and most exciting object: obj_lights. Create it and add a Draw event. Now, we are going to make the lights. The first thing to do is make the torch glow. For this, we will include a draw sprite action. The sprite should be spr_light, the x obj_player.x, and the y obj_player.y. The subimage can be left as -1 or set to 0. Now, we need to make rest of the screen dark.

We will include 4 draw rectangle actions for this. I will not go through these step by step, but here are the values required (they should all have the final property set to filled):

Rectangle 1: 0,0,obj_player.x-64, room_height
Rectangle 2: room_width,0,obj_player.x+64, room_height
Rectangle 3: 0,0,room_width, obj_player.y-64
Rectangle 4: 0,room_height,room_width, room_height, obj_player.x+64

This will draw the darkness around the player. Now, we are done! You can create a test room and put in some walls, obj_player, and IMPORANTLY: obj_light. If you get any errors, feel free to check it against the full version here:
Posted Image

Edited by CaptainLepidus, 16 November 2010 - 02:41 PM.

  • 0

#2 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 16 November 2010 - 04:13 AM

Anybody interested in this?
  • 0

#3 D.P. Darius Productions

D.P. Darius Productions

    GMC Member

  • New Member
  • 38 posts

Posted 16 November 2010 - 09:33 AM

This is Interesting tutorial, though I will not use it, good Job

Note: This is brilliant for new lite users
  • 0

#4 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 17 November 2010 - 12:27 AM

This is Interesting tutorial, though I will not use it, good Job

Note: This is brilliant for new lite users


Thanks. I'm making a lite particle example that doesn't use objects. Any other suggestions?
  • 0

#5 poio

poio

    GMC Member

  • New Member
  • 3 posts

Posted 25 November 2010 - 12:16 PM

Nice tutorial, but i want to set a game with two player,
So, can you make one more tutorial to teach me how to do?
Because i don't know how to make two player also have lighting
thank you, CaptainLepidus
  • 0

#6 Hiddenaces

Hiddenaces

    GMC Member

  • New Member
  • 418 posts

Posted 26 November 2010 - 01:07 PM

this is a great example for those starting out.and im sure the particle example will be just good and usfull as this one.



(you might want to read the rules on double posts and bumping posts) if no one replys dont worry, its not coz no one is looking at your post. replys dont seem to be to fourth coming on here, hang on in and keep up the great work :)

Edited by Hiddenaces, 26 November 2010 - 01:12 PM.

  • 0

#7 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 26 November 2010 - 05:09 PM

Nice tutorial, but i want to set a game with two player,
So, can you make one more tutorial to teach me how to do?
Because i don't know how to make two player also have lighting
thank you, CaptainLepidus

I think my post may have been deleted...anyway, it's more complicated but it's possible. I'll see what I can do, but I have been busy lately.

this is a great example for those starting out.and im sure the particle example will be just good and usfull as this one.



(you might want to read the rules on double posts and bumping posts) if no one replys dont worry, its not coz no one is looking at your post. replys dont seem to be to fourth coming on here, hang on in and keep up the great work :)


Thank you.
  • 0

#8 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 26 November 2011 - 02:46 AM

Awesome dude awesome thank you so much for makin' this.


Your welcome. However, I'm not that active on the GMC anymore, unfortunately.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users