Starting .cap is here.
The duck has a "8 direction" behaviour already.
Run all
Move the Duck with the Arrow Keys.
But, oh man, thats a totally drunk Duck.
Suppose we want its movement aligned with the grid for this maze ?
Huh ?
Lets move the paper roll aligned to the maze's grid in a quick event, to show you.
Give the Paper object a Bullet Behavior.
Be care full to not move the Paper,
if you accidental did, then move it back by giving it x = 480 and y = 400 in its common properties.
Notice the Green Box objects, named h1... h4.
They are placed strategical on points where the Paper will change direction.
There angles are according the direction the Paper will change to.
And look under the Group properties, and deeper the Families properties.
They have been given a family name Yellow.
You can give a group of objects a Family name, to call them by there family in the events.
Go to the Events Editor.
Add a system flow event "always"
Add a sub event to this ..
step1: object = Paper
step2: condition = Is overlapping another object
step3: parameters: Choose Yellow as object.
finish
Yellow is the family name we call all the h1 ...h4 objects with.
Add an action to this.
step1: self = Paper
Step2: action = set angle
Step3: parameters: Yellow.angle
finish
Run All
That paper has a nice move.
And our duck is still drunk.
This is then the limit of the "8 directions" ?
Ahhhhh, not yet. But yes almost.
Go back to the layout Editor.
Edit its grid to 80 by 80.
Click Toggle grid to make objects snap to the grid.
Select the most Bottom layer.
Add a box object. Name it Sensor
Give it height and a width of 80
place it somewhere on the grid, but not on a wall, and not in the middle.
The grid will snap it to a good place.
You can change its color and looks, but the initial values are ok for me
Delete the "8 directions" behavior on the Duck
Give Sensor an "8 directions" behavior.
Go to the Events Editor
Add a system "Always" flow condition.
Add a sub event with a system "always" condition.
Ad an action to this sub event.
Step1: self = duck
step2: action = set position to another object
step3: parameters : choose the object Sensor
finish
Run all.
Nice !
Although, The Duck is still drunk by 1 pixel.
And Because you see the Sensor, it is easy to move the duck, because your eye is using it as a guide.
Go to the layout editor.
Select the Sensor,
Try to find its "set invisible" properties.
Uhh, i dont know myself where it is. But
Go to the Events editor.
Make a new Event from the System "Start of layout" condition
Add a sub event "always"
Add a action to this sub event.
Step1: self = Sensor
Step2: Action = Set visible
Step3: parameter = Invisible
finish
Move the "Start of layout" events on top of the events sheet.
Run all
Move the duck Around a while, and notice that its a little more difficult to push it around the corners.
Also, and this is the end of the "8 directions" behavior.
What if i want the duck to move in the maze but only in one direction ? With no Returns?
What if i want the duck keep moving and let the player only alter its direction?
Its the limit of the "8 directions".
BUT it is the Born of the sensor principle. You just made your first Sensor.
And believe me, once its born, it sticks on you.