title Puzzles
author Stephen Lavelle
homepage www.puzzlescript.net

(
Unfortunately, just the first level - trying to emulate the later ones proved too complex :[

You can play the original game here:
http://www.increpare.com/2012/06/puzzles/
)

background_color white
text_color blue

run_rules_on_level_start


========
OBJECTS
========

DyingPlayer
Black

Void
White

OBackground
Orange

GBackground
LightGrey

BlueWall
Blue


GreyWall
Grey

RedCrate
Red
.....
.000.
.000.
.000.
.....
GreyCrate
DarkGrey
.....
.000.
.000.
.000.
.....

RedWhale
Red White
00100
00000
10001
00000
00100

GreyWhale
DarkGrey White
00100
00000
10001
00000
00100

RedEndPoint
DarkRed
.....
.000.
.0.0.
.000.
.....

GreyEndPoint
Darkgrey
.....
.....
.....
.....
.....

RedStartPoint
darkRed
.....
.....
.....
.....
.....

GreyStartPoint
darkRed
.....
.000.
.0.0.
.000.
.....

YellowPlayer
yellow
.....
.000.
.000.
.000.
.....

GreyPlayer
DarkGrey
.....
.000.
.000.
.000.
.....

LeftBeam
white
.....
.....
00000
.....
.....

RightBeam
white
.....
.....
00000
.....
.....

UpBeam
white
..0..
..0..
..0..
..0..
..0..

DownBeam
white
..0..
..0..
..0..
..0..
..0..

=======
LEGEND
=======

Background = Void or OBackground or GBackground
Player = YellowPlayer or GreyPlayer or DyingPlayer
Wall = BlueWall or GreyWall
Crate = RedCrate or GreyCrate
Whale = RedWhale or GreyWhale
StartPoint = RedStartPoint or GreyStartPoint
EndPoint = RedEndPoint or GreyEndPoint
. = OBackground
, = Void
# = BlueWall
W = RedWhale
C = RedCrate
S = RedStartPoint and YellowPlayer
E = RedEndPoint
Obstacle = Player or Whale or Crate or Wall
Beam = UPBeam or DownBeam or LeftBeam or RightBeam
VBeam = UPBeam or DownBeam
HBeam = LeftBeam or RightBeam
HBeamSource = HBeam or Whale
VBeamSource = VBeam or Whale
Pushable = Player or Whale or Crate
RedPushable = YellowPlayer or RedWhale or RedCrate
GreyPushable = GreyPlayer or GreyWhale or GreyCrate

=======
SOUNDS
=======

================
COLLISIONLAYERS
================

Background
StartPoint, EndPoint
Player, Wall, Crate, Whale
UpBeam, DownBeam
LeftBeam, RightBeam

======
RULES
======


left [ LeftBeam | < Player ] -> [ LeftBeam | Player ]
right [ RightBeam | < Player ] -> [ RightBeam | Player ]
up [ UpBeam | < Player ] -> [ UpBeam | Player ]
down [ DownBeam | < Player ] -> [ DownBeam | Player ]

right [ RightBeam | stationary Pushable ] -> [ RightBeam | > Pushable ]
left [ LeftBeam | stationary Pushable ] -> [ LeftBeam | > Pushable ]
up [ UpBeam | stationary Pushable ] -> [ UpBeam | > Pushable ]
down [ DownBeam | stationary Pushable ] -> [ DownBeam | > Pushable ]

[ Whale | stationary Pushable ] -> [ Whale | > Pushable ]


[ Beam ] -> []


[ >  Player | Crate ] -> [  >  Player | > Crate  ]
[ > Crate | stationary Crate ] -> [ > Crate | > Crate ]

( using red/greypushable is an optimization - cuts down on unecessary rules by quite a lot, beause red and grey things never coexist)
[ > RedPushable | v RedPushable ] -> [ RedPushable | v RedPushable ]
[ > RedPushable | ^ RedPushable ] -> [ RedPushable | ^ RedPushable ]
[ > RedPushable | < RedPushable ] -> [ RedPushable | < RedPushable ]

[ > GreyPushable | v GreyPushable ] -> [ GreyPushable | v GreyPushable ]
[ > GreyPushable | ^ GreyPushable ] -> [ GreyPushable | ^ GreyPushable ]
[ > GreyPushable | < GreyPushable ] -> [ GreyPushable | < GreyPushable ]

late Up [ Whale | no Obstacle ] -> [ Whale | UpBeam ]
late Down [ Whale | no Obstacle ] -> [ Whale | DownBeam ]
late Left [ Whale | no Obstacle ] -> [ Whale | LeftBeam ]
late Right [ Whale | no Obstacle ] -> [ Whale | RightBeam ]

late horizontal [ HBeam | no obstacle ] -> [ HBeam | HBeam ]
late vertical [ VBeam | no obstacle ] -> [ VBeam | VBeam ]


(DEATH TRANSITION)
late Horizontal [ HBeamSource | YellowPlayer ]  -> [ HBeamSource | DyingPlayer ]
late Vertical [ VBeamSource | YellowPlayer ]  -> [ VBeamSource | DyingPlayer ]

late [ DyingPlayer ] [ BlueWall ] -> [ DyingPlayer ] [ GreyWall ]
late [ DyingPlayer ] [ RedWhale ] -> [ DyingPlayer ] [ GreyWhale ]
late [ DyingPlayer ] [ RedCrate ] -> [ DyingPlayer ] [ GreyCrate ]
late [ DyingPlayer ] [ RedStartPoint ] -> [ DyingPlayer ] [ GreyStartPoint ]
late [ DyingPlayer ] [ RedEndPoint ] -> [ DyingPlayer ] [ GreyEndPoint ]
late [ DyingPlayer ] [ OBackground ] -> [ DyingPlayer ] [ GBackground ]
late [ DyingPlayer ] -> [ GreyPlayer ]

late [DyingPlayer] -> [GreyPlayer]

(LIFE TRANSITION)
late [ GreyPlayer GreyStartPoint ] [ GreyWall ] -> [ GreyPlayer GreyStartPoint ] [ BlueWall ]
late [ GreyPlayer GreyStartPoint ] [ GreyCrate ] -> [ GreyPlayer GreyStartPoint ] [ RedCrate ]
late [ GreyPlayer GreyStartPoint ] [ GreyWhale ] -> [ GreyPlayer GreyStartPoint ] [ RedWhale ]
late [ GreyPlayer GreyStartPoint ] [ GreyEndPoint ] -> [ GreyPlayer GreyStartPoint ] [ RedEndPoint ]
late [ GreyPlayer GreyStartPoint ] [ GBackground ] -> [ GreyPlayer GreyStartPoint ] [ OBackground ]

late [ GreyPlayer GreyStartPoint ] -> [ YellowPlayer RedStartPoint ]

late [player]->again

==============
WINCONDITIONS
==============

All Player on RedEndPoint

=======
LEVELS
=======


#########
#......E#
#..CC..##
#.....##,
#.....W#,
##.#####,
#......#,
#..CC..#,
#..CC..#,
##.....#,
#W.....#,
######.#,
#......#,
#......#,
##S#####,
########,

