Snipfin: Customization Guide

Step-by-step changes for people who do not program. Everything works with a free text editor.

1. Before you start

  1. Make a copy of the whole download. If something goes wrong, you can go back to it.
  2. Install a free code editor such as Visual Studio Code (or Notepad++ on Windows). For pictures, the free GIMP or Krita open and export WebP files. For sounds, the free Audacity exports MP3.
  3. Work inside source/. To see your changes, open a terminal in that folder and run npm run dev, then open http://localhost:5180/. The game does not run by double-clicking index.html, because browsers block JavaScript modules on file://.
  4. No terminal? Edit the files of game/ directly, upload them to your host and reload the page.

2. Your brand: name, logo and icon

Title screen with the logo
  1. The name in the browser tab is the <title> line of index.html.
  2. The logo is assets/img/logo.webp (1100 x 305 pixels, transparent background). To use your own, save it at the same size with a transparent background.
  3. The logo has a small plaque under the name, and the words on it come from live text: the subtitle key of each language file. With your own logo, either leave a plaque in the same place or hide the words by adding display: none; to the .logo-sub rule in style.css.
  4. The page icon is assets/icon-192.png (192 x 192 pixels).

3. Colors and the look

Almost every piece of the interface (buttons, panels, bubbles, stars) is a picture in assets/ui/, so you change the look by editing those pictures (see table 4). The few colors of the text are at the top of style.css, inside :root:

--ink: #fff; /* text color */
--orb: 64px; /* size of the round buttons */
--txt: 0 2px 3px rgba(20, 12, 80, 0.55), 0 0 10px rgba(40, 30, 130, 0.3); /* text shadow */

The color of the water that wraps the koi in each world is water in WORLDS in src/config.js, as red, green and blue numbers from 0 to 255:

{ id: 2, key: 'w2', need: 10, music: 'world2', water: '18,160,158' },

4. Replace pictures (reskin)

Replace a file with another of the same name and a similar size. Nothing else needs to change.

On screen File
Backgrounds of the 4 worlds assets/img/bg-portrait.webp and bg-landscape.webp (Moon Pond); the same with bg2 (Bamboo Falls), bg3 (Lantern Harbor) and bg4 (Frost Lake)
Blurred background of the menus assets/ui/soft1-portrait.webp and soft1-landscape.webp; the same with soft2, soft3 and soft4
World bubbles of the map assets/ui/w1.webp to w4.webp
The dumpling and the stars assets/img/dumpling.webp and assets/img/star.webp
Urchin, peg and rail assets/img/burr.webp, peg.webp and rail.webp
Lotus flower, lily pad and moon assets/img/lotus.webp, pad.webp and moon.webp
Whirlpools assets/img/portal.webp and portal2.webp
Sparkles, water drops and wind assets/img/sparkle.webp, drop.webp and wind.webp
The bubble of the "New!" notice (in a level the bubble is drawn in code) assets/img/bubble.webp
Ropes: normal and elastic assets/fx/rope-gold.webp and rope-pink.webp
The koi assets/fx/koi-body.webp, fin.webp and tail.webp
Petals, leaves, embers, snow, mist and lanterns of the worlds, and the other effects The other files of assets/fx/
Buttons, panels, rows, switches, sliders, stars and level bubbles The files of assets/ui/, one per piece, named by its job (pause.webp, restart.webp, panel.webp, toggle-on.webp...)

5. The koi

A level with the koi waiting for the dumpling

The koi is painted (assets/fx/koi-body.webp, fin.webp and tail.webp) and animated by code: the mouth, eyes, whiskers and cheeks are drawn in src/koi.js. To recolor the koi, edit the three pictures.

To use the older koi, drawn entirely in code, set koiArt: false in FEEL in src/config.js. Its colors are the # colors in src/koi.js.

6. Levels

A level with a bubble and an urchin

The levels are in data/levels.json, one per line. The world is 720 wide and 960 high. The top left corner is 0, 0 and y grows downward. The mouth of the koi is around y = 800. This is level 1-6:

{"id":"1-6","world":1,"candy":[234,362],"ropes":[{"a":[189,136],"slack":0.03}],"bubbles":[[246,504,54]],"stars":[[187,427],[185,275],[185,620]],"mouth":[185,800],"sol":[{"f":14,"rope":0},{"f":150,"pop":true}]}
Field What it is
id Unique name: the world and the number (1-6). Solved levels are remembered by it.
world The world (1 to 4) the level belongs to.
candy Where the dumpling hangs: [x, y].
ropes The ropes. a is where a rope is tied, slack is extra length (0 to 0.06), elastic: true makes it stretchy and rail: [amplitude, period, phase] makes the peg slide sideways (the period is in frames).
stars The 3 stars: [[x, y], [x, y], [x, y]].
mouth Where the koi waits: [x, y]. The mouth catches the dumpling near this point.
bubbles, spikes, puffs, portals, pads, moons Optional obstacles and helpers. bubbles and spikes (urchins) are [x, y, radius], puffs (lotus flowers) are [x, y, angle in degrees], portals are [x1, y1, x2, y2] (a pair of whirlpools), pads are [x1, y1, x2, y2] (the two ends of a lily pad) and moons are [x, y].
sol The stored solution (see below).

sol lists the actions that win the level. f is the frame (60 per second), { "f": 14, "rope": 0 } cuts rope 0, { "f": 150, "pop": true } taps the bubble, puff taps a lotus flower and moon taps a moon (the number is its place in the list). npm test replays it, and the hint ring shows it to players who get stuck.

After moving things, run npm test. If a level fails, change the cut times (f) until it wins with 3 stars again. Small moves of the stars and of the mouth are the safest edits.

To add a level, copy a line, give it a new id and set its world. The levels of a world appear in the order of the lines. The tests of this package expect 4 worlds of 15 levels: if you add or remove levels, change the first test in tests/levels.test.mjs.

7. Difficulty and game feel

Level select with the stars of each level

Open src/config.js. The most useful numbers:

Setting What it does
PHYS.koiReach How far the koi swims sideways to catch a dumpling that falls close. Raise it for an easier game, lower it for a harder one.
PHYS.mouthR The size of the circle in which the mouth catches the dumpling.
PHYS.cutNear How much a swipe that just misses a rope still cuts it.
PHYS.g Gravity. Changing it changes the stored solutions, so run npm test.
FEEL.hintAfter and FEEL.coachAfter Seconds before the hand shows the swipe to a new player, and how many failed attempts before the hint ring appears.
WORLDS[].need The stars needed to open each world (0, 10, 45 and 90). The world names are the keys w1 to w4 in each language file.
FEEL Every other animation number: hit pause, shake, particles, the koi jump, the bubble transition and the retry rewind.

8. Texts and languages

Settings panel with the language list

9. Sounds and music

Every effect is an MP3 in assets/sfx/. Replace a file and keep its name.

Files When they play
cut-*, swipe-* Cutting a rope and moving the finger across the screen.
star-*, star-stamp-* Collecting a star and the stars stamping on the result panel.
bite-*, splash-*, victory-* The koi eating the dumpling, the splash and the victory jingle.
fell-in-water-*, sigh-*, defeat-* A lost level.
bubble-enter-*, bubble-pop-*, unlock-* Entering a level or a world through a bubble, popping it, and unlocking something new.
burr-*, lotus-*, portal-*, pad-*, moon-*, elastic-* The elements: urchin, lotus flower, whirlpool, lily pad, moon and elastic rope.
button-*, panel-* Buttons and the sound and settings panels.
lake-night-1 The pond ambience that loops under the music.
assets/music/menu.mp3, world1.mp3 to world4.mp3 The music: one track for the menus and one for each world.

The number at the end is the version: the game alternates them. To add a version, put the file in the folder and raise its number in SFX_FILES in src/audio/sfx-files.js. The volume of each sound is in AUDIO.gains in src/config.js.

export const SFX_FILES = { cut: 2, swipe: 2, star: 2, 'star-stamp': 2, bite: 2 /* ... */ };

10. Save keys and starting over

The progress stays in the browser of each player, under the key snipfin.template.save.v1, and the language under snipfin.template.lang.v1. If you host two copies on the same domain, change these names in src/config.js and src/lib/i18n.js. To start over, clear the site data in the browser.

11. Publish your version

  1. In source/, run npm test and npm run build. This writes source/dist/.
  2. Back up the game on your website, then upload the contents of dist/ in place of the old files.
  3. Keep the folders as they are. If you added a new file or folder next to index.html, add its name to PARTS in source/tools/build.mjs.
  4. Clear the browser cache to see the new version (see the buyer guide).

Support: willian@polargames.com.br