- Documentation
- Bird's-eye View
- Prelude
Bird's-eye view of a PuzzleScript file
A puzzlescript file is divided into 8 sections:
Prelude
Before any of the "official" sections are declared, you can give details about your project in this section, and also set some editor options.
title 2D Whale World
author increpare
homepage www.increpare.com
require_player_movement
key_repeat_interval 0.12
Here are the possible options:
- author increpare
- Your name goes here. This will appear in the title screen of the game.
- color_palette mastersystem
- By default, when you use colour names, they are pulled from a variation of Arne's 16-Colour palette. However, there are other palettes to choose from:
- 1 - mastersystem
- 2 - gameboycolour
- 3 - amiga
- 4 - arnecolors
- 5 - famicom
- 6 - atari
- 7 - pastel
- 8 - ega
- 9 - amstrad
- 10 - proteus_mellow
- 11 - proteus_rich
- 12 - proteus_night
- 13 - c64
- 14 - whitingjp
(you can also refer to them by their numerical index)
- again_interval 0.1
- The amount of time it takes an 'again' event to trigger.
- background_color blue
- Can accept a color name or hex code (in the form #412bbc). Controls the background color of title/message screens, as well as the background color of the website. Text_color is its sibling.
- debug
- This outputs the compiled instructions whenever you build your file. For instance, the line
[ > Player | Crate ] -> [ > Player | > Crate ]
is compiled into four instructions, as the output from debug shows:
Rule Assembly : (4 rules )
===========
(52) UP [ up player | crate ] -> [ up player | up crate ]
(52) DOWN [ down player | crate ] -> [ down player | down crate ]
(52) LEFT [ left player | crate ] -> [ left player | left crate ]
(52) RIGHT [ right player | crate ] -> [ right player | right crate ]
===========
the number on the far left is the group number of the disassembled - based on the line-number of the rules. The compilation step removes all relative directions ( ^, v, <, and >), and replaces them with UP, DOWN, LEFT, and RIGHT.
- flickscreen WxH
-
Setting flickscreen divides each level into WxH grids, and zooms the camera in so that the player can only see one at a time - the camera does not follow the player around on a move-to-move basis, but if the player moves from one part of this grid to another, the camera flicks to the new position.
- homepage www.mypage.com
-
The homepage of the author. This doesn't appear directly in the game itself, but is included in the exported HTML build.
- key_repeat_interval 0.1
-
When you hold down a key, how long is the delay between repeated presses getting sent to the game (in seconds)?
- noaction
- Hides the action key (X) instruction from the title screen, and does not respond when the player pressed it (outside of menus and cutscenes and the like).
- norepeat_action
- For many games, you don't want holding action down to retrigger it - games where you're toggling a switch, say. For these games, set norepeat_action, and the action button will only respond to individual presses.
- noundo
- Disables the undo key (Z)
- norestart
- Disables the restart key (R)
- realtime_interval
- The number indicates how long each realtime frame should be. In the above case, twice a second the game engine will tick, but with no input. Player input is processed as regular. See this documentation for more info on making realtime games.
- require_player_movement
-
This is a common requirement in games - if the player doesn't move, cancel the whole move. This is equivalent, where there's only one player character, to the following:
[Player]->[Player Temp]
late [ Player Temp ] -> CANCEL
late [ Temp ] -> [ ]
- run_rules_on_level_start
-
For some games, you will want, before the player sees the level, for the rules to be applied once.
- scanline
- Applies a scanline visual effect - only draws every other line
- text_color blue
- Can accept a color name or hex code (in the form #412bbc). Controls the font color of title/message screens, as well as the font color in the website. Background_color is its sibling.
- title My Amazing Puzzle Game
- The name of your game. Appears on the title screen.
- throttle_movement
- For use in conjunction with realtime_interval - this stops you from moving crazy fast - repeated keypresses of the same movement direction will not increase your speed. This doesn't apply to the action button. If you can think of an example that requires action be throttled, just let me know and I'll try accommodate you.
- verbose_logging
- As you play the game, spits out information about all rules applied as you play, and also allows visual inspection of what exactly the rules do with the visual debugger.
- youtube 5MJLi5_dyn0
- If you write the youtube tag followed by the ID of a youtube video, it will play in the background. Exported builds using this, obviously enough, will no longer be fully self-contained, but some might like it :) You'll only hear the music in the exported or shared versions, not in the editor.
- zoomscreen WxH
- Zooms the camera in to a WxH section of the map around the player, centered on the player.
New in PS+
- There are many new prelude flags in PuzzleScript Plus, allowing you to enable mouse controls, level select, text settings, camera/tweening options, and much more.
Mouse controls (ThatScar)
- mouse_left object
- If the player clicks on a specific tile of the screen, then this object will be created there before any other rules are done. If you don't specify an object name, it will look for an object called "lmb". Once you add this flag, various things (like the title screen) will change to reflect that the game is mainly mouse-controlled.
- mouse_drag object
- If the player has clicked and is moving their mouse, it will place this object & start a turn when the cursor moves into a different cell. If you don't specify an object name, it will look for an object called "drag"
- mouse_up object
- If the player has clicked and is releasing their mouse button, it will place this object then do a turn.
- mouse_right, mouse_rdrag, mouse_rup object
- Similar to the above three, but for the right mouse button. Note that you can also Ctrl + Left Click to get the right mouse button behaviour in-game.
Level Select (Dario)
- level_select
- Adding this will add a level select to your game. By default, this will allow the player to play all levels in any order. In order to add entries to the level select, add a section in-between your levels.
- continue_is_level_select
- Don't show an extra option for the Level Select on the main menu. Instead, the "continue" button will open it, instead of continuing the game.
- level_select_lock
- Will lock any levels that haven't been solved yet or are next to be solved.
- level_select_unlocked_ahead
- How many levels to unlock ahead after the last solved level when level_select_lock is on, 1 by default.
If you set it to 3, then section 1, 2, and 3 will be available. If you solve section 2, then you'll unlock 4 and 5. (So there will always be three levels unlocked AFTER the last solved level at max.)
- level_select_unlocked_rollover
- Alternative to LEVEL_SELECT_UNLOCKED_AHEAD that more strictly limits the number of unsolved levels at any time.
If you set this to 3, then section 1, 2, and 3 will be available at the start. If you solve section 2, then only section 4 will unlock. (So there will only ever be three "unsolved" levels at most.)
- level_select_solve_symbol
- Which symbol to display for levels that have been solved in the level select. It's a checkmark by default, but you can change it in case you're using a custom_font that doesn't have a checkmark glyph.
Text settings (Dario & PS+)
- custom_font data:font/otf;base64,
- Allows you to load in a custom font file via a data stream. This works best with monospace fonts & font files with very small sizes (under 20KB). If you have a font file and you want to convert it into base64, use a tool like File to Base64 with the "Data URI" output format, then paste it into the editor.
- font_size size
- Font size is in em, meaning 1 is the default and is treated as a percentage (e.g. 0.5 is half font size & 2 is double the normal font size). Can only be used with custom_font.
- message_text_align left/center/right
- How to align text for messages: 'left', 'center' (default), or 'right'. If you need more control over the text layout, you can also use \n to manually add a newline.
Smoothscreen (sftrabbit)
- smoothscreen flick WxH IxJ S
- Zooms the camera in to a WxH section of the map around the playerand smoothly scrolls to follow the player. The optional argument IxJ (default: 1x1) specifies a boundary in which the player can move without moving the camera. The optional S argument (default: 0.125) specifies how far the camera will move towards the player each frame as a fraction of the distance to the player. Additionally, the optional flick keyword makes the camera move like flickscreen, where the camera always moves the full boundary width/height. To get a smooth version of flick screen, provide the flick keyword and make WxH and IxJ the same dimensions.
- smoothscreen_debug
- Render debug information about the smoothscreen camera. The red circle and box represent the camera's position and the boundary around it. The blue circle and box are at the position the camera is moving towards. The green circle marks the location of the player that is being followed by the camera.
Runtime Metadata Twiddling (PS+)
- runtime_metadata_twiddling
- Allows you to change some prelude properties while the game is running using commands. More info here.
- runtime_metadata_twiddling_debug
- DEPRECATED: Instead, you can now use verbose logging to see when metadata is changed.
Local Radius (Jack Lance)
- local_radius radius
- If you set the local_radius flag to a whole number, then the game will only check rules that are in that amount of tiles (a square radius) around the player (or one of the players if you have multiple players in the level). If you still want to have rules to be checked anywhere on the level, preface them with the global keyword like this:
(Rows of global crates can push each other, even outside of the player radius)
global [> GCrate | GCrate] -> [> GCrate | > GCrate ]
You generally don't need to use this unless you have a really big level, a ton of rules, and your game would otherwise run slowly.
Tweening (PS+)
Although you can animate your game using again, PS+ offers a more generalized method of inbetweening movement you can use instead!
Note that it has a number of limitations. It should work for simple games, but might not be powerful enough for complex games.
- tween_length 0.05
- Enables tweens for LEFT, RIGHT, UP, and DOWN object movement, and for ACTION (will fade in that object). Tweens will take the duration you specify in seconds An object must execute its movement for this animation to play, currently there is no way to play an animation without moving.
Note that if the next turn starts before this tween is completed, the previous tween instantly completes. For this reason, we recommend setting the tween_length very low, somewhere between 0.05 and 0.075 seconds, but at least lower than the AGAIN_INTERVAL and KEY_REPEAT_INTERVAL, and to avoid using it in games that use REALTIME_INTERVAL.
Additionally, late rules can tamped with this system, so it's not recommended to use these rules in games that use LATE rules.
- tween_easing easeInQuad
- When using TWEEN_LENGTH, you can use these to indicate how the movement should lerp. Just like with COLOR_PALETTE you can use either the name or the number.
The following options are valid. (To view these in action, see easings.net).
- 1: linear (default)
- 2: easeInQuad
- 3: easeOutQuad
- 4: easeInOutQuad
- 5: easeInCubic
- 6: easeOutCubic
- 7: easeInOutCubic
- 8: easeInQuart
- 9: easeOutQuart
- 10: easeInOutQuart
- 11: easeInQuint
- 12: easeOutQuint
- 13: easeInOutQuint
- tween_snap 5
- By default, the tween will snap to the SPRITE_SIZE to conform to the pixel grid. However, with this prelude you can overwrite this if you want the transition to happen more granually when the canvas is drawn on a large scale. You can even put it to a very high number (like 1000) to make the snapping essentially smoothless.
Misc. (Dario)
- case_sensitive
- Will force the engine to be case sensitive, to see "a" and "A" or "moved" and "moveD" as different objects.
- sprite_size size
- Instead of 5x5, this option allows you to pick other square resolutions for your sprites. Do note that all sprites MUST be of this size for the game to display correctly. If you need help with upscaling your sprites, there's a helpful tool available here.
Misc. (PS+)
- skip_title_screen
- Will skip the title screen when the game initializes. Instead, it will act like the "continue" button has been pressed, opening either the level, message, or level select based on game progress and other prelude flags.
- text_controls
- Will overwrite the default keyboard/mouse control text in the title screen with the text you specify here! It can display up to three lines of text at once, and supports using \n to add a newline.
- text_message_continue
- Override the text below MESSAGEs that normally says 'X to continue' or 'Click to continue'.
- sitelock_origin_whitelist
- Causes your game to only be able to run on websites with the listed origins, separated by whitespaces. An origin is for example https://auroriax.github.io:1234.
- sitelock_hostname_whitelist
- Causes your game to only be able to run on websites with the listed hostnames, separated by whitespaces. A hostname is for example auroriax.github.io.