Skip to content

Instantly share code, notes, and snippets.

@m-ender
Created June 4, 2025 07:12
Show Gist options
  • Save m-ender/55e79bd1a2a9b874a85efdc126d9c001 to your computer and use it in GitHub Desktop.
Save m-ender/55e79bd1a2a9b874a85efdc126d9c001 to your computer and use it in GitHub Desktop.
Sokoyote (Puzzlescript Next Script)
Play this game by pasting the script into https://david-pfx.github.io/PuzzleScriptNext/src/editor.html
title Sokoyote
author Menderbug
homepage https://brokensign.com/
run_rules_on_level_start
realtime_interval 0.1
again_interval 0.1
// enable comments
=====
TAGS
=====
Tick = 0 1 2 3 4 5 6 7 8 9 10
directions2 = directions
=========
MAPPINGS
=========
Tick => TickDown
0 1 2 3 4 5 6 7 8 9 10 -> 0 0 1 2 3 4 5 6 7 8 9
========
OBJECTS
========
Background
lightgrey grey
00010
11111
01000
11111
00010
Target
darkblue
.000.
0...0
0.0.0
0...0
.000.
Wall
brown darkbrown
00010
11111
01000
11111
00010
PlayerStanding
black orange white blue
.000.
.111.
22222
.333.
.3.3.
PlayerJumping
black orange white blue
.000.
21112
.222.
.333.
3...3
Snail; transparent
SnailSprite:directions:directions2; red
SnailSprite:down:right
yellow orange brown
.111.
12211
21201
21110
.2000
SnailSprite:right:up
yellow orange brown
copy: SnailSprite:down:right
rot: down:right
SnailSprite:up:left
yellow orange brown
copy: SnailSprite:down:right
rot: down:up
SnailSprite:left:down
yellow orange brown
copy: SnailSprite:down:right
rot: down:left
SnailSprite:down:left
yellow orange brown
copy: SnailSprite:down:right
flip:right
SnailSprite:right:down
yellow orange brown
copy: SnailSprite:down:left
rot: down:right
SnailSprite:up:right
yellow orange brown
copy: SnailSprite:down:left
rot: down:up
SnailSprite:left:up
yellow orange brown
copy: SnailSprite:down:left
rot: down:left
SnailAntenna:directions
yellow
.....
.....
0....
.....
.....
rot:right:>
CornerBG:directions
brown
....0
.....
.....
.....
.....
rot:right:>
CornerWall:directions
lightgrey
....0
.....
.....
.....
.....
rot:right:>
Temp:directions; pink
Temp; pink
Timer:Tick; transparent
Falling; transparent
Jumping; transparent
Flailing; transparent
PlayerTurn; pink
RealTimeTurn; pink
Setup; pink
=======
LEGEND
=======
. = Background
# = Wall
! = Wall and Setup
P = PlayerStanding
* = Snail
@ = Snail and Target
O = Target
CornerBG = CornerBG:directions
CornerWall = CornerWall:directions
AirState = Jumping or Falling or Flailing
SupportPlayer = Snail or Wall
Player = PlayerStanding or PlayerJumping
SnailSprite = SnailSprite:directions:directions2
TurnMarker = RealTimeTurn or PlayerTurn
Timer = Timer:Tick
SnailAntenna = SnailAntenna:directions
=======
SOUNDS
=======
sfx0 36765102 // snail pushed
sfx1 40983506:8// 64809106 // flailing 1
sfx2 72961706:8 // flailing 2
sfx3 56468105 // jump
sfx4 46067704 // landing
endlevel 70532303
================
COLLISIONLAYERS
================
Background
directions -> CornerBG:directions
Target
Player
Wall
Snail
SnailSprite
directions -> CornerWall:directions
directions -> SnailAntenna:directions
Timer:Tick
AirState
directions -> Temp:directions
Temp
TurnMarker
Setup
======
RULES
======
[ Setup ] -> [ ] gosub Set up decorations
random [ ] -> [ Temp ]
[ ] [ Temp ] [ moving Player ] -> [ PlayerTurn ] [ ] [ moving Player ]
[ ] [ Temp ] -> [ RealTimeTurn ] [ ]
[ RealTimeTurn ] -> gosub Real-time turn
[ PlayerTurn ] -> gosub Player turn
late [ RealTimeTurn ] -> gosub Late real-time turn
late [ PlayerTurn ] -> gosub Late player turn
late [ TurnMarker ] -> [ ]
subroutine Real-time turn
[ Player Falling no Timer | no SupportPlayer ] -> [ down PlayerStanding down Falling | ]
subroutine Player turn
[ moving Player Falling ] -> [ Player Falling ]
[ up Player Jumping ] -> [ Player Jumping ]
[ horizontal Player Flailing ] -> [ Player Flailing ]
[ > Player | Wall ] -> [ Player | Wall ]
[ > Player | Snail ] -> gosub Push snail
up [ > Player | no Wall ] -> [ > PlayerJumping > Jumping | ] sfx3
horizontal [ > Player Jumping | no Wall ] -> [ > PlayerStanding > Falling > Timer:1 | ]
down [ > Player Flailing ] -> [ > PlayerStanding > Falling ]
down [ > Player Jumping ] -> [ > PlayerStanding > Falling ]
subroutine Late real-time turn
late down [ Player Falling | SupportPlayer ] -> [ PlayerStanding | SupportPlayer ] sfx4
late [ PlayerStanding Flailing ] -> [ PlayerJumping Flailing Temp ] sfx1
late [ PlayerJumping Flailing no Temp ] -> [ PlayerStanding Flailing ] sfx2
late [ Temp ] -> [ ]
late [ Player Flailing Timer:0 ] -> [ PlayerStanding Falling ]
late [ Player Falling Timer:0 ] -> [ Player Falling ]
late down [ Player no AirState | no SupportPlayer ] -> [ PlayerJumping Flailing Timer:6 | ]
late [ AirState no Player ] -> [ ]
late Tick once [ Timer:Tick ] -> [ Timer:TickDown ]
subroutine Late player turn
late down [ Player Falling | SupportPlayer ] -> [ PlayerStanding | SupportPlayer ] sfx4
late down [ Player no AirState | no SupportPlayer ] -> [ PlayerJumping Flailing Timer:6 | ]
late [ AirState no Player ] -> [ ]
subroutine Push snail
// This code assumes that there won't be any 1-wide corridors to push snails through
[ > Player | Snail ] -> [ > Player | > Snail ]
[ > Snail | Wall ] -> [ > Snail Temp | Wall ]
[ Wall | v Snail SnailSprite Temp ] -> [ Wall | > Snail SnailSprite:v:> ] // redirect movement away from wall
[ Wall | ^ Snail SnailSprite Temp ] -> [ Wall | > Snail SnailSprite:^:> ] // redirect movement away from wall
[ > Snail Temp ] -> [ Snail ] // snail was not pushed along wall
[ > Snail | Snail ] -> [ Snail | Snail ]
[ Wall | perpendicular Snail ] -> [ perpendicular Temp Wall | perpendicular Snail ]
[ > Temp | Snail ] [ moving Snail ] -> [ | Snail ] [ Snail ]
[ > Temp | Wall ] -> [ | Wall ]
[ > Player | stationary Snail ] -> [ Player | Snail ]
// Actually move the snail
[ > Temp | ] [ > Snail SnailSprite:v:directions ] -> [ | Snail SnailSprite:<:v ] [ ] sfx0
[ > Temp | ] [ > Snail SnailSprite:^:directions ] -> [ | Snail SnailSprite:<:^ ] [ ] sfx0
[ > Snail SnailSprite:v:directions | ] -> [ | Snail SnailSprite:v:> ] sfx0
[ > Snail SnailSprite:^:directions | ] -> [ | Snail SnailSprite:^:> ] sfx0
[ SnailAntenna ] -> [ ]
[ SnailSprite:directions:> | ] -> [ SnailSprite:directions:> | SnailAntenna:> ]
subroutine Set up decorations
[ no Wall | Wall ] -> [ CornerBG:> Temp:> | Wall ]
[ CornerBG:v Temp:v | Wall ] -> [ CornerBG:v | Wall ]
[ CornerBG:> Temp:> ] -> [ ]
[ Temp ] -> [ ]
[ CornerBG:> | no Wall ] -> [ | ]
[ CornerBG:v | no Wall ] -> [ | ]
[ Wall ] -> [ Wall CornerWall:< CornerWall:v CornerWall:> CornerWall:^ ]
[ CornerWall:> | Wall ] -> [ | Wall ]
[ CornerWall:v | Wall ] -> [ | Wall ]
horizontal [ Snail | Wall ] -> [ Snail SnailSprite:>:up | Wall ]
vertical [ Snail | Wall ] -> [ Snail SnailSprite:>:^ | Wall ]
[ SnailSprite:directions:> | ] -> [ SnailSprite:directions:> | SnailAntenna:> ]
==============
WINCONDITIONS
==============
all Target on Snail
=======
LEVELS
=======
!###..
#.O#..
#..###
#@P..#
#..*.#
#..###
####..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment