The Land Of Light and Shadows (Part 3)

2

Index

Attached Files

The following files have been attached to this tutorial:

.capx

part-3-simple-with-layers.capx

Download now 192.27 KB
.capx

part-3-simple.capx

Download now 179.41 KB
.capx

part-3-very-simple.capx

Download now 179.75 KB
.capx

ball-shadow.capx

Download now 428.71 KB
.capx

line-of-site-full-grid.capx

Download now 310.91 KB
.capx

line-of-site-cone.capx

Download now 243.97 KB
.capx

cast-light-arc-01.capx

Download now 248.66 KB
.capx

cast-light-arc-reducing-length.capx

Download now 248.68 KB
.capx

cast-forwards-3.capx

Download now 318 KB
.capx

fog-test-01.capx

Download now 532.27 KB
.capx

cut-up-light-length.capx

Download now 318.01 KB

Stats

6,741 visits, 15,798 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Method 2 - line of sight behavior

Construct 2 has a built in line of sight behavior - if we use this on our shadow layer ...

The line of site (note spelling) allows you to attach a behavior to your (player) - this behavior (see manual entry

allows you pick what is in the players field of view taking into account any obstacles and a maximum distance to see (which we could use for torch power for example).

In my example "line of site full grid.capx" I have filled the shadow layer (layer 1 !) with a grid of "lights".

The game loops through my vast list of events doing:

event 1 turns the player towards the mouse and turns all the light to zero opacity - (which, in this case, means they have no effect on the layer below).

event two any light in the players cone of view (not hidden by the rocks) is chosen. These chosen lights have thier opacity turned right up to 100% - these light can now "cut" through my shadow layer to reveal the layer below.

Things to try :

Select the player (spPlayer) either by clicking on him in the layout view or selecting him from the object list on the right hand side of the screen.

Now in his properties find "Line of site" in the behavior section.

Try changing cone of view from 120 to other values and run the game again (I suggest trying 30, 60, 180, and 360)

Also try changing the range value.

See the difference these values make ?

Another thing to try (and this one is quite important) is the size of the lights. Select "spLineOfSiteLight" from the objects list and in its properties change the size (under common) make is smaller and you get a grid type effect (which I quite like) and bigger (64,64) gets all the light to overlap and give a different effect.

Another thing we could do is alter the strength of the opacity depending on the distance from the player - this could give the effect of the light fading away. (just disable the 100% opacity and enable the distance one in event 2 to see this - you might also want to reset distance and cone back to 300 and 120).

Rather a lot of lights ?

Ok using a grid of lights all across the layer is rather wasteful - in the next example I have made the worlds most perfect (possibly ?) cone of lights which I have then pinned (position and angle) to the player - so as the player turns/moves these lights stay in their relative position to the player.

Method of controlling this character in this example is questionable - but that is not the lesson here :)

Load "line of site cone.capx" and gaze upon the beauty of the light cone...and no laughing !

I think this method has probably the most potential.

The problem of the light cone is you are limited by the cone you create (angle of cone/view and distance to see) - but that is not to say that one could not be created on the fly as needed with the correct maths...

Again try changing the range/cone on the line of site - but remember if you go too wide/long then there will be no lights to glow.

Also try changing the event sheets - especially the global variable gvLightFadeRate.

Ok Time for a coffee.

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!