Lantern Knight
của MusicBar, thanh tiến trình
Game tự chơi, bạn chỉ việc mở nhạc. Hiệp sĩ đội mũ tai mèo chạy theo bài hát: đầu bài xuất phát ở mép trái, hết bài là cán đích bên phải. Dọc đường nhảy qua chông, nhảy đôi lộn vòng hái ngọc, leo bục cao băng qua bãi chông, chém slime với dơi tan thành nốt nhạc, lướt qua bụi gai, đập rương cho xu bay rào rào. Chạy tới đâu đèn lồng sáng tới đó, hoa nở theo chân; phía trước còn ngủ say dưới trăng, quái chỉ lộ hai con mắt. Tạm dừng nhạc là hiệp sĩ đứng thở chờ.
Cần MusicBar 2.0.2 trở lên: skin này dùng thứ bản cũ chưa có (vẽ tràn lên trên taskbar, hình động đi kèm). Bản cũ hơn không thấy nó trong kho, cập nhật app là có.
Cách cài, mã SHA-256 và mã nguồn
Bấm Áp dụng: MusicBar tự tải về, kiểm tra mã SHA-256 rồi mặc lên taskbar; có rồi thì mặc luôn. Cần MusicBar 1.8 trở lên.
SHA-256 ab52fbf7e27f83b18d45ad7d278bfc86bce5d49912e9e4fd4828cf14d22b9bd6
//! name: Lantern Knight
//! author: MusicBar
//! kind: progress
//! headroom: 96
//! layer: sprites.png back
//! bloom: 0.4 0.8
//! description: A little knight in a cat-eared hood runs the song through a sleeping night land: jumps spikes, takes the high ledges over wide gaps, double-jumps for gems, slashes slimes and bats, drops through planks, dashes over thorns. Behind them the lanterns are lit and the flowers open. Needs Direct3D 11.
// Lantern Knight, a platformer level that plays itself along the song.
//
// The hero runs at the song's place on the taskbar (left end at its start, right end at its end) while the world
// scrolls past. Everything the hero has gone by is lit: lanterns burn, flowers open, the thorns bloom, the earth's
// crystals glow with the music; ahead the land still sleeps under the moon and the monsters' eyes shine in the dark.
//
// How it is drawn: the sprites (hero, monsters, coins, lanterns, flowers) are one picture, sprites.png, laid as a
// back layer inside the bar, where this skin always paints solid ground and sky, so the sheet itself never shows.
// The skin reads frames out of it with layerBack() and draws them wherever it wants, flipped, turned, squashed or
// tinted. The level is a loop of 24 encounters of 3.4 s (spikes, high ledges over a gap, a slime, a gem up high, a
// plank to drop through, thorns to dash over, a chest...). Each was simulated beforehand (gravity, landings, hits); the
// tables below hold the hero's path through it and where and when everything in it happens, so the shader needs no
// memory: the time says which encounter is on and how far into it the hero is.
//
// Art and code: MusicBar, drawn for this skin.
#define AW 1542.32
#define PROBE float2(771.37, 18.54)
static const float4 HC[18] = {
float4(544.84, 66.52, 577.02, 96.5), float4(612.37, 66.05, 643, 96.5), float4(679.42, 64.68, 710.82, 96.5), float4(745.09, 64.13, 774.87, 96.5),
float4(810.22, 65.41, 840.21, 96.5), float4(876.63, 65.37, 908.73, 96.5), float4(478.56, 65.28, 501.06, 96.5), float4(1006.4, 68.38, 1021.24, 86.47),
float4(943, 62.4, 967.88, 96.5), float4(410.63, 66.93, 441.63, 96.5), float4(273.09, 84.97, 298.47, 96.23), float4(209.62, 62.47, 250.17, 96.5),
float4(75.51, 75.34, 97.75, 96.5), float4(151.84, 56.77, 173.66, 96.5), float4(1, 73.51, 21.29, 96.5), float4(359.05, 50.58, 382.35, 96.5),
float4(1439.04, 50.58, 1462.34, 96.5), float4(1490.62, 49.7, 1516.28, 96.5)
};
static const float4 HK[18] = {
float4(573.18, 58.33, 580.12, 69.51), float4(639.96, 55.21, 646.51, 66.62), float4(706.19, 54.94, 713.52, 65.87), float4(771.03, 60.14, 777.97, 71.32),
float4(837.17, 57.25, 843.72, 68.67), float4(904.1, 56.51, 911.43, 67.44), float4(492.95, 55.38, 501.9, 65.03), float4(1028.16, 50.94, 1029.27, 64.05),
float4(957.55, 57.35, 967.46, 66.01), float4(438.99, 59.91, 445.33, 71.44), float4(302.26, 55.95, 305.18, 68.78), float4(237.74, 59.81, 248.5, 67.39),
float4(94.31, 57.73, 101.06, 69.03), float4(167.85, 57.29, 175.74, 67.82), float4(16.27, 55.46, 23.79, 66.26), float4(373.49, 55.93, 382.77, 65.26),
float4(1453.48, 55.74, 1462.76, 65.07), float4(1505.24, 58.21, 1515.44, 66.52)
};
static const float4 SC[15] = {
float4(1075.79, 0, 62.76, 37.66), float4(1075.79, 50.5, 71.2, 30.86), float4(1147.98, 0, 73.1, 33.65), float4(1147.98, 50.5, 72.59, 35.85),
float4(1222.08, 0, 33.19, 33.19), float4(1222.08, 50.5, 30.17, 38.59), float4(1256.27, 0, 32.6, 29.94), float4(1256.27, 50.5, 50.45, 41.25),
float4(1307.72, 0, 50.06, 45.27), float4(1307.72, 50.5, 23.34, 36.89), float4(1358.78, 0, 23.34, 36.89), float4(1358.78, 50.5, 24.3, 36.09),
float4(1384.08, 0, 25.98, 37.79), float4(1384.08, 50.5, 25.98, 37.79), float4(1411.06, 0, 25.98, 37.79)
};
static const float2 SA[15] = {
float2(1107.17, 31.43), float2(1111.38, 75.27), float2(1184.53, 19.46), float2(1184.28, 69.96), float2(1238.67, 16.59), float2(1237.17, 70.12),
float2(1272.57, 14.1), float2(1281.49, 86.65), float2(1332.75, 40.17), float2(1319.39, 57.29), float2(1370.45, 6.79), float2(1370.88, 80.6),
float2(1396.47, 31.79), float2(1396.47, 82.29), float2(1423.45, 31.79)
};
static const float4 SE[15] = {
float4(1111.85, 20.35, 1121.73, 20.35), float4(1116.06, 66.41, 1125.94, 66.41), float4(1181.15, 18.68, 1188.17, 18.68), float4(1180.9, 69.18, 1187.92, 69.18),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0)
};
#define NT 13
#define NS 35
#define RATE 10.0
#define NLOOP 24
#define CYC 199.023
#define GRAV 5.85
#define VS 0.65
static const float4 PATH[455] = {
float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000),
float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000),
float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, 1.000),
float4(3.000, 0.000, 0.0, 1.000), float4(3.250, 0.000, 0.0, 1.000), float4(3.500, 0.000, 0.0, 1.000), float4(3.750, 0.000, 0.0, 1.000),
float4(4.000, 0.000, 0.0, 1.000), float4(4.250, 0.000, 0.0, 1.000), float4(4.500, 0.000, 0.0, 1.000), float4(4.750, 0.000, 0.0, 1.000),
float4(5.000, 0.000, 0.0, 1.000), float4(5.250, 0.000, 0.0, 1.000), float4(5.500, 0.000, 0.0, 1.000), float4(5.750, 0.000, 0.0, 1.000),
float4(6.000, 0.000, 0.0, 1.000), float4(6.250, 0.000, 0.0, 1.000), float4(6.500, 0.000, 0.0, 1.000), float4(6.750, 0.000, 0.0, 1.000),
float4(7.000, 0.000, 0.0, 1.000), float4(7.250, 0.000, 0.0, 1.000), float4(7.500, 0.000, 0.0, 1.000), float4(7.750, 0.000, 0.0, 1.000),
float4(8.000, 0.000, 0.0, 1.000), float4(8.250, 0.000, 0.0, 1.000), float4(8.500, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000),
float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000),
float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000),
float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, 1.000), float4(3.000, 0.163, 0.0, -0.982),
float4(3.250, 0.387, 0.0, -1.000), float4(3.500, 0.553, 0.0, -1.000), float4(3.750, 0.660, 0.0, -1.000), float4(4.000, 0.709, 0.0, -1.000),
float4(4.250, 0.700, 0.0, -1.000), float4(4.500, 0.632, 0.0, -1.000), float4(4.750, 0.505, 0.0, -1.000), float4(5.000, 0.320, 0.0, -0.994),
float4(5.250, 0.076, 0.0, -0.976), float4(5.500, 0.000, 0.0, 0.971), float4(5.750, 0.000, 0.0, 1.005), float4(6.000, 0.000, 0.0, 1.000),
float4(6.250, 0.000, 0.0, 1.000), float4(6.500, 0.000, 0.0, 1.000), float4(6.750, 0.000, 0.0, 1.000), float4(7.000, 0.000, 0.0, 1.000),
float4(7.250, 0.000, 0.0, 1.000), float4(7.500, 0.000, 0.0, 1.000), float4(7.750, 0.000, 0.0, 1.000), float4(8.000, 0.000, 0.0, 1.000),
float4(8.250, 0.000, 0.0, 1.000), float4(8.500, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000),
float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000),
float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000),
float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, 1.000), float4(3.000, 0.000, 0.0, 1.000), float4(3.250, 0.000, 0.0, 1.000),
float4(3.500, 0.000, 0.0, 1.000), float4(3.750, 0.000, 0.0, 1.000), float4(4.000, 0.000, 0.0, 1.000), float4(4.250, 0.000, 0.0, 1.000),
float4(4.454, 0.000, 0.0, 1.000), float4(4.524, 0.000, 0.0, 1.000), float4(4.593, 0.000, 0.0, 1.000), float4(4.663, 0.000, 0.0, 1.000),
float4(4.834, 0.000, 0.0, 1.000), float4(5.084, 0.000, 0.0, 1.000), float4(5.334, 0.000, 0.0, 1.000), float4(5.584, 0.000, 0.0, 1.000),
float4(5.834, 0.000, 0.0, 1.000), float4(6.084, 0.000, 0.0, 1.000), float4(6.334, 0.000, 0.0, 1.000), float4(6.584, 0.000, 0.0, 1.000),
float4(6.834, 0.000, 0.0, 1.000), float4(7.084, 0.000, 0.0, 1.000), float4(7.334, 0.000, 0.0, 1.000), float4(7.584, 0.000, 0.0, 1.000),
float4(7.834, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000),
float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000),
float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.184, 0.0, -0.996),
float4(2.750, 0.362, 0.0, -1.000), float4(3.000, 0.481, 0.0, -1.000), float4(3.250, 0.542, 0.0, -1.000), float4(3.500, 0.663, 11.5, -1.000),
float4(3.750, 0.872, 99.1, -1.000), float4(4.000, 1.022, 224.6, -1.000), float4(4.250, 1.113, 329.7, -1.000), float4(4.500, 1.146, 0.0, -1.000),
float4(4.750, 1.121, 0.0, -1.000), float4(5.000, 1.036, 0.0, -1.000), float4(5.250, 0.894, 0.0, -1.000), float4(5.500, 0.693, 0.0, -0.989),
float4(5.750, 0.433, 0.0, -0.971), float4(6.000, 0.115, 0.0, -0.953), float4(6.250, 0.000, 0.0, 0.975), float4(6.500, 0.000, 0.0, 1.004),
float4(6.750, 0.000, 0.0, 1.000), float4(7.000, 0.000, 0.0, 1.000), float4(7.250, 0.000, 0.0, 1.000), float4(7.500, 0.000, 0.0, 1.000),
float4(7.750, 0.000, 0.0, 1.000), float4(8.000, 0.000, 0.0, 1.000), float4(8.250, 0.000, 0.0, 1.000), float4(8.500, 0.000, 0.0, 1.000),
float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000),
float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000),
float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, 1.000),
float4(3.000, 0.000, 0.0, 1.000), float4(3.250, 0.055, 0.0, -0.977), float4(3.500, 0.296, 0.0, -0.995), float4(3.750, 0.479, 0.0, -1.000),
float4(4.000, 0.603, 0.0, -1.000), float4(4.250, 0.669, 0.0, -1.000), float4(4.500, 0.676, 0.0, -1.000), float4(4.750, 0.625, 0.0, -1.000),
float4(5.000, 0.515, 0.0, -1.000), float4(5.250, 0.346, 0.0, -0.999), float4(5.500, 0.119, 0.0, -0.981), float4(5.750, 0.000, 0.0, 0.992),
float4(6.000, 0.000, 0.0, 1.000), float4(6.250, 0.000, 0.0, 1.000), float4(6.500, 0.000, 0.0, 1.000), float4(6.750, 0.000, 0.0, 1.000),
float4(7.000, 0.000, 0.0, 1.000), float4(7.250, 0.000, 0.0, 1.000), float4(7.500, 0.000, 0.0, 1.000), float4(7.750, 0.000, 0.0, 1.000),
float4(8.000, 0.000, 0.0, 1.000), float4(8.250, 0.000, 0.0, 1.000), float4(8.500, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000),
float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000),
float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.183, 0.0, -0.968), float4(1.750, 0.452, 0.0, -0.986), float4(2.000, 0.661, 0.0, -1.000),
float4(2.250, 0.813, 0.0, -1.000), float4(2.500, 0.905, 0.0, -1.000), float4(2.750, 0.940, 0.0, -1.000), float4(3.000, 0.915, 0.0, -1.000),
float4(3.250, 0.832, 0.0, -1.000), float4(3.500, 0.691, 0.0, -1.000), float4(3.750, 0.491, 0.0, -0.990), float4(4.000, 0.450, 0.0, 0.966),
float4(4.250, 0.450, 0.0, 1.006), float4(4.500, 0.450, 0.0, 1.000), float4(4.750, 0.450, 0.0, 1.000), float4(5.000, 0.450, 0.0, 1.000),
float4(5.120, 0.450, 0.0, 1.000), float4(5.272, 0.453, 0.0, -1.000), float4(5.522, 0.421, 0.0, -1.000), float4(5.772, 0.330, 0.0, -1.000),
float4(6.022, 0.181, 0.0, -1.000), float4(6.272, 0.000, 0.0, 1.125), float4(6.522, 0.000, 0.0, 0.974), float4(6.772, 0.000, 0.0, 1.005),
float4(7.022, 0.000, 0.0, 1.000), float4(7.272, 0.000, 0.0, 1.000), float4(7.522, 0.000, 0.0, 1.000), float4(7.772, 0.000, 0.0, 1.000),
float4(8.023, 0.000, 0.0, 1.000), float4(8.273, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000),
float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000),
float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000),
float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, -0.984), float4(3.000, 0.217, 0.0, -1.000), float4(3.250, 0.375, 0.0, -1.000),
float4(3.500, 0.475, 0.0, -1.000), float4(3.750, 0.517, 0.0, -1.000), float4(4.473, 0.518, 0.0, -1.000), float4(5.523, 0.518, 0.0, -1.000),
float4(6.180, 0.516, 0.0, -1.000), float4(6.430, 0.471, 0.0, -1.000), float4(6.680, 0.369, 0.0, -1.000), float4(6.930, 0.207, 0.0, -1.000),
float4(7.180, 0.000, 0.0, 1.141), float4(7.430, 0.000, 0.0, 0.971), float4(7.680, 0.000, 0.0, 1.006), float4(7.930, 0.000, 0.0, 1.000),
float4(8.180, 0.000, 0.0, 1.000), float4(8.430, 0.000, 0.0, 1.000), float4(8.680, 0.000, 0.0, 1.000), float4(8.930, 0.000, 0.0, 1.000),
float4(9.180, 0.000, 0.0, 1.000), float4(9.430, 0.000, 0.0, 1.000), float4(9.680, 0.000, 0.0, 1.000), float4(9.930, 0.000, 0.0, 1.000),
float4(10.180, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000),
float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000),
float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.000, 0.0, 1.000),
float4(2.750, 0.000, 0.0, 1.000), float4(3.000, 0.000, 0.0, 1.000), float4(3.250, 0.000, 0.0, 1.000), float4(3.500, 0.000, 0.0, 1.000),
float4(3.750, 0.000, 0.0, 1.000), float4(4.000, 0.000, 0.0, 1.000), float4(4.250, 0.000, 0.0, 1.000), float4(4.500, 0.000, 0.0, 1.000),
float4(4.579, 0.000, 0.0, 1.000), float4(4.599, 0.000, 0.0, 1.000), float4(4.619, 0.000, 0.0, 1.000), float4(4.639, 0.000, 0.0, 1.000),
float4(4.659, 0.000, 0.0, 1.000), float4(4.679, 0.000, 0.0, 1.000), float4(4.699, 0.000, 0.0, 1.000), float4(4.890, 0.000, 0.0, 1.000),
float4(5.140, 0.000, 0.0, 1.000), float4(5.390, 0.000, 0.0, 1.000), float4(5.640, 0.000, 0.0, 1.000), float4(5.890, 0.000, 0.0, 1.000),
float4(6.140, 0.000, 0.0, 1.000), float4(6.390, 0.000, 0.0, 1.000), float4(6.640, 0.000, 0.0, 1.000), float4(6.890, 0.000, 0.0, 1.000),
float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000),
float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000),
float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, 1.000),
float4(3.000, 0.000, 0.0, -0.975), float4(3.250, 0.246, 0.0, -0.993), float4(3.500, 0.434, 0.0, -1.000), float4(3.750, 0.563, 0.0, -1.000),
float4(4.000, 0.633, 0.0, -1.000), float4(4.250, 0.645, 0.0, -1.000), float4(4.500, 0.599, 0.0, -1.000), float4(4.750, 0.494, 0.0, -1.000),
float4(5.000, 0.405, 1.2, -1.108), float4(5.250, 0.668, 49.6, -0.977), float4(5.500, 0.873, 144.2, -1.005), float4(5.750, 1.020, 250.3, -1.000),
float4(6.000, 1.108, 333.3, -1.000), float4(6.250, 1.137, 0.0, -1.000), float4(6.500, 1.109, 0.0, -1.000), float4(6.750, 1.021, 0.0, -1.000),
float4(7.000, 0.875, 0.0, -1.000), float4(7.250, 0.671, 0.0, -0.988), float4(7.500, 0.408, 0.0, -0.970), float4(7.750, 0.086, 0.0, -0.952),
float4(8.000, 0.000, 0.0, 0.969), float4(8.250, 0.000, 0.0, 1.005), float4(8.500, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000),
float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.218, 0.0, -0.983), float4(0.750, 0.438, 0.0, -1.000), float4(1.000, 0.599, 0.0, -1.000),
float4(1.250, 0.701, 0.0, -1.000), float4(1.500, 0.746, 0.0, -1.000), float4(1.750, 0.731, 0.0, -1.000), float4(2.000, 0.658, 0.0, -1.000),
float4(2.250, 0.527, 0.0, -1.000), float4(2.500, 0.450, 0.0, 0.992), float4(2.750, 0.450, 0.0, 1.000), float4(3.000, 0.450, 0.0, 1.000),
float4(3.250, 0.450, 0.0, -0.998), float4(3.500, 0.623, 0.0, -1.000), float4(3.750, 0.737, 0.0, -1.000), float4(4.000, 0.792, 0.0, -1.000),
float4(4.250, 0.905, 15.9, -1.000), float4(4.500, 1.060, 108.9, -1.000), float4(4.750, 1.157, 234.9, -1.000), float4(5.000, 1.196, 335.7, -1.000),
float4(5.250, 1.176, 0.0, -1.000), float4(5.500, 1.097, 0.0, -1.000), float4(5.750, 0.960, 0.0, -1.000), float4(6.000, 0.764, 0.0, -0.991),
float4(6.250, 0.510, 0.0, -0.973), float4(6.500, 0.450, 0.0, 0.967), float4(6.750, 0.450, 0.0, 1.006), float4(7.000, 0.449, 0.0, -1.000),
float4(7.250, 0.408, 0.0, -1.000), float4(7.500, 0.309, 0.0, -1.000), float4(7.750, 0.152, 0.0, -1.000), float4(8.000, 0.000, 0.0, 1.067),
float4(8.250, 0.000, 0.0, 0.984), float4(8.500, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000),
float4(0.500, 0.000, 0.0, 1.000), float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000),
float4(1.500, 0.000, 0.0, 1.000), float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000),
float4(2.500, 0.000, 0.0, 1.000), float4(2.750, 0.000, 0.0, 1.000), float4(2.881, 0.000, 0.0, 1.000), float4(2.951, 0.000, 0.0, 1.000),
float4(3.022, 0.000, 0.0, 1.000), float4(3.097, 0.000, 0.0, 1.000), float4(3.334, 0.000, 0.0, 1.000), float4(3.584, 0.000, 0.0, 1.000),
float4(3.834, 0.000, 0.0, 1.000), float4(4.084, 0.000, 0.0, 1.000), float4(4.334, 0.000, 0.0, 1.000), float4(4.584, 0.000, 0.0, 1.000),
float4(4.834, 0.000, 0.0, 1.000), float4(5.084, 0.000, 0.0, 1.000), float4(5.191, 0.000, 0.0, 1.000), float4(5.261, 0.000, 0.0, 1.000),
float4(5.332, 0.000, 0.0, 1.000), float4(5.420, 0.000, 0.0, 1.000), float4(5.668, 0.000, 0.0, 1.000), float4(5.918, 0.000, 0.0, 1.000),
float4(6.168, 0.000, 0.0, 1.000), float4(6.418, 0.000, 0.0, 1.000), float4(6.668, 0.000, 0.0, 1.000), float4(6.918, 0.000, 0.0, 1.000),
float4(7.168, 0.000, 0.0, 1.000), float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.000, 0.0, 1.000),
float4(0.750, 0.000, 0.0, 1.000), float4(1.000, 0.000, 0.0, 1.000), float4(1.250, 0.000, 0.0, 1.000), float4(1.500, 0.000, 0.0, 1.000),
float4(1.750, 0.000, 0.0, 1.000), float4(2.000, 0.000, 0.0, 1.000), float4(2.250, 0.000, 0.0, 1.000), float4(2.500, 0.000, 0.0, 1.000),
float4(2.750, 0.000, 0.0, 1.000), float4(3.000, 0.000, 0.0, 1.000), float4(3.250, 0.000, 0.0, 1.000), float4(3.500, 0.000, 0.0, 1.000),
float4(3.750, 0.000, 0.0, 1.000), float4(4.000, 0.000, 0.0, 1.000), float4(4.250, 0.000, 0.0, 1.000), float4(4.402, 0.000, 0.0, 1.000),
float4(4.473, 0.000, 0.0, 1.000), float4(4.543, 0.000, 0.0, 1.000), float4(4.613, 0.000, 0.0, 1.000), float4(4.834, 0.000, 0.0, 1.000),
float4(5.084, 0.000, 0.0, 1.000), float4(5.334, 0.000, 0.0, 1.000), float4(5.584, 0.000, 0.0, 1.000), float4(5.834, 0.000, 0.0, 1.000),
float4(6.084, 0.000, 0.0, 1.000), float4(6.334, 0.000, 0.0, 1.000), float4(6.584, 0.000, 0.0, 1.000), float4(6.834, 0.000, 0.0, 1.000),
float4(7.084, 0.000, 0.0, 1.000), float4(7.334, 0.000, 0.0, 1.000), float4(7.584, 0.000, 0.0, 1.000), float4(7.834, 0.000, 0.0, 1.000),
float4(0.000, 0.000, 0.0, 1.000), float4(0.250, 0.000, 0.0, 1.000), float4(0.500, 0.109, 0.0, -0.976), float4(0.750, 0.353, 0.0, -0.994),
float4(1.000, 0.539, 0.0, -1.000), float4(1.250, 0.666, 0.0, -1.000), float4(1.500, 0.734, 0.0, -1.000), float4(1.750, 0.744, 0.0, -1.000),
float4(2.000, 0.696, 0.0, -1.000), float4(2.250, 0.589, 0.0, -1.000), float4(2.500, 0.450, 0.0, 1.113), float4(2.750, 0.450, 0.0, 0.976),
float4(3.000, 0.450, 0.0, 1.005), float4(3.250, 0.450, 0.0, 1.000), float4(3.500, 0.450, 0.0, 1.000), float4(3.704, 0.450, 0.0, 1.000),
float4(3.773, 0.450, 0.0, 1.000), float4(3.844, 0.450, 0.0, 1.000), float4(3.913, 0.450, 0.0, 1.000), float4(4.084, 0.450, 0.0, 1.000),
float4(4.334, 0.450, 0.0, 1.000), float4(4.584, 0.450, 0.0, 1.000), float4(4.834, 0.450, 0.0, 1.000), float4(5.084, 0.450, 0.0, 1.000),
float4(5.334, 0.450, 0.0, 1.000), float4(5.584, 0.450, 0.0, 1.000), float4(5.834, 0.450, 0.0, 1.000), float4(6.084, 0.449, 0.0, -1.000),
float4(6.334, 0.412, 0.0, -1.000), float4(6.584, 0.316, 0.0, -1.000), float4(6.834, 0.161, 0.0, -1.000), float4(7.084, 0.000, 0.0, 1.084),
float4(7.334, 0.000, 0.0, 0.981), float4(7.584, 0.000, 0.0, 1.000), float4(7.834, 0.000, 0.0, 1.000)
};
static const float4 PE[78] = {
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(1.7483, 11, 1.8483, 0), float4(1.8483, 12, 1.9383, 0), float4(1.9383, 13, 2.0683, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(1.7033, 14, 1.9033, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(2, 9, 2.16, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(1.8, 11, 1.94, 0), float4(1.94, 12, 2.04, 0), float4(2.04, 13, 2.2, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(1.1083, 11, 1.2083, 0), float4(1.2083, 12, 1.2983, 0), float4(1.2983, 13, 1.4283, 0),
float4(2.295, 11, 2.395, 0), float4(2.3967, 12, 2.4867, 0), float4(2.4867, 13, 2.6167, 0),
float4(1.72, 11, 1.82, 0), float4(1.82, 12, 1.91, 0), float4(1.91, 13, 2.04, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0),
float4(1.4483, 11, 1.5483, 0), float4(1.5483, 12, 1.6383, 0), float4(1.6383, 13, 1.7683, 0),
float4(-1, 0, -1, 0), float4(-1, 0, -1, 0), float4(-1, 0, -1, 0)
};
static const float4 OA[104] = {
float4(1, 2.6, 0.48, 0.8283), float4(1, 3.25, 0.48, 1.0883), float4(1, 3.9, 0.48, 1.3483),
float4(1, 4.55, 0.48, 1.6083), float4(7, 6.4, 0, 2.5617), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(9, 3.6, 0, 0),
float4(1, 3.468, 0.9563, 1.1767), float4(1, 4.086, 1.135, 1.4233), float4(1, 4.704, 0.9563, 1.67),
float4(7, 7.4, 0, 2.9617), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(4, 5.5, 0, 1.8483), float4(7, 1.4, 0, 0.5617),
float4(13, 5.5, 0.3, 1.8483), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(2, 4.5169, 1.6205, 1.595), float4(1, 2.9519, 0.8896, 0.97), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(5, 5.2576, 1.0825, 1.7533),
float4(7, 7.6, 0, 3.0417), float4(13, 5.2576, 1.3825, 1.7533), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(8, 2.6, 0.45, 0), float4(1, 4, 0.93, 1.3883),
float4(1, 4.6, 0.93, 1.6283), float4(1, 6.35, 0.48, 2.42), float4(1, 6.95, 0.48, 2.66),
float4(1, 7.55, 0.48, 2.9), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(10, 3.7, 0, 0), float4(1, 4.4, 0.94, 1.5383), float4(1, 5.2, 0.94, 1.62),
float4(1, 6, 0.94, 1.695), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(6, 5.7, 0, 1.94),
float4(7, 1.2, 0, 0.4817), float4(12, 5.7, 0.5, 1.94), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(11, 4.95, 0, 1.9833), float4(1, 5.72, 1.423, 2.0767),
float4(1, 6.52, 1.5286, 2.3967), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(8, 1.3, 0.45, 0), float4(8, 5.9, 0.45, 0), float4(9, 3.6, 0, 0),
float4(1, 2.75, 0.93, 0.8883), float4(1, 3.15, 0.93, 1.0483), float4(1, 3.7256, 1.15, 1.2783),
float4(2, 5.0393, 1.67, 1.805), float4(0, 0, 0, 0), float4(4, 3.9, 0, 1.2083),
float4(4, 6.2, 0, 2.3967), float4(7, 1.4, 0, 0.5617), float4(13, 3.9, 0.3, 1.2083),
float4(13, 6.2, 0.3, 2.3967), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(5, 5.4, 0.78, 1.82), float4(1, 2.4, 0.48, 0.7483),
float4(1, 3, 0.48, 0.9883), float4(13, 5.4, 1.08, 1.82), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(8, 1.4, 0.45, 0), float4(1, 2.9, 0.93, 0.9483), float4(1, 3.3, 0.93, 1.1083),
float4(4, 4.75, 0.45, 1.5483), float4(7, 5.55, 0.45, 2.4867), float4(13, 4.75, 0.75, 1.5483),
float4(0, 0, 0, 0), float4(0, 0, 0, 0)
};
static const float4 OB[104] = {
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(1.2, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 3, 0, 0), float4(0, 0, 0, 0),
float4(3, 1.1, 2.21, 2.5517), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 2, 0, 0),
float4(0, 0, 0, 0), float4(2, 2.3, 0.65, 2.4767), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(4.2, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(2.8, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(7, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(2, 0, 0, 0), float4(0.9, 0, 0, 0), float4(2, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 1, 0, 0),
float4(1, 1, 0, 0), float4(0, 0, 0, 0), float4(1, 1.1, 2.21, 1.9117),
float4(1, 1.1, 2.21, 3.0983), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(1, 1, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(1, 1.1, 2.21, 2.6033), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(4.5, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 1, 0, 0), float4(0, 0, 0, 0), float4(1, 1.1, 2.21, 2.2517),
float4(0, 0, 0, 0), float4(0, 0, 0, 0)
};
static const float4 FX[52] = {
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(3, 2.1267, 5.3208, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(1, 1.8483, 4.4873, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(2, 1.355, 3.3875, 0.5504), float4(3, 2.4317, 6.0833, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(5, 1.7533, 4.3833, 0.6799), float4(3, 2.2433, 5.6125, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(3, 1.5167, 3.7958, 0.45),
float4(3, 2.5883, 6.2475, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(4, 1.515, 3.7875, 0.5178), float4(3, 2.1933, 7.1675, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(1, 1.94, 4.5874, 0), float4(0, 0, 0, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(3, 1.9833, 4.9625, 0.36),
float4(6, 1.9833, 4.9625, 0.36), float4(3, 3.1233, 7.8125, 0), float4(0, 0, 0, 0),
float4(3, 0.9433, 2.3625, 0.45), float4(2, 1.6467, 4.1167, 0.7983), float4(3, 2.52, 6.3042, 0.45),
float4(3, 3.1717, 7.9333, 0), float4(1, 1.2083, 2.8873, 0), float4(1, 2.3967, 5.1892, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(1, 1.82, 4.4165, 0),
float4(0, 0, 0, 0), float4(0, 0, 0, 0), float4(0, 0, 0, 0),
float4(3, 0.985, 2.4667, 0.45), float4(1, 1.5483, 3.7373, 0.45), float4(3, 3.0767, 7.0298, 0),
float4(0, 0, 0, 0)
};
static const int ORD[24] = {
0, 1, 2, 3, 4, 5, 0, 6, 8, 1, 7, 12, 9, 4, 10, 3, 6, 5, 12, 11, 8, 2, 9, 7
};
static const float PRE[25] = {
0, 8.5, 17, 24.834, 33.334, 41.834, 50.1065, 58.6065, 68.7865, 77.2865, 85.7865, 92.6765, 100.5105,
109.0105, 117.5105, 124.6785, 133.1785, 143.3585, 151.631, 159.465, 167.299, 175.799, 183.633, 192.133, 199.023
};
#define TSHIFT 0.0
#define T_ENC 3.4
#define V_RUN 2.5
#define REACH 0.95
// Where the ground is: this far down from the bar's top edge (in bar heights), so the land sits in the taskbar and
// only the hero, the trees' tops and the jumps rise over the desktop.
#define GOFF 0.55
// The far land (hills, towers, trees) is drawn this much smaller than it was first laid out.
#define TS 0.7
#define F_TUCK 7
#define F_DASH 10
#define F_RISE 6
#define F_FALL 8
#define F_CROUCH 9
#define F_IDLE0 15
#define F_IDLE1 16
#define S_SLIME0 0
#define S_SLIME1 1
#define S_BAT0 2
#define S_BAT1 3
#define S_COIN 4
#define S_GEM 5
#define S_HEART 6
#define S_CHEST 7
#define S_CHESTOPEN 8
#define S_LAMPOFF 9
#define S_LAMPON 10
#define S_BUD 11
#define S_CORAL 12
#define S_GOLD 13
#define K_COIN 1
#define K_GEM 2
#define K_HEART 3
#define K_SLIME 4
#define K_BAT 5
#define K_CHEST 6
#define K_LAMP 7
#define K_PLANK 8
#define K_SPIKES 9
#define K_THORNS 10
#define K_STOMP 11
#define K_BURST 12
#define K_DROP 13
#define E_SLASH 1
#define E_RING 2
#define E_DUST 3
#define E_DASH 4
#define E_AIR 5
#define E_HIT 6
#define HX(c) (float3(((c) >> 16) & 255, ((c) >> 8) & 255, (c) & 255) / 255.0)
// ---------------------------------------------------------------- basics
uint pcg(uint v)
{
uint s = v * 747796405u + 2891336453u;
uint w = ((s >> ((s >> 28u) + 4u)) ^ s) * 277803737u;
return (w >> 22u) ^ w;
}
float h1(int n) { return pcg(asuint(n)) * (1.0 / 4294967295.0); }
float h2(int a, int b) { return pcg(asuint(a) + pcg(asuint(b) + 0x9e3779b9u)) * (1.0 / 4294967295.0); }
float vnoise(float x, int seed)
{
float i = floor(x), f = x - i;
f = f * f * (3.0 - 2.0 * f);
return lerp(h2((int)i, seed), h2((int)i + 1, seed), f);
}
// Value noise that repeats every `period` cells (the far layers wrap with the level's long loop).
float pnoise(float x, int period, int seed)
{
float i = floor(x), f = x - i;
f = f * f * (3.0 - 2.0 * f);
int a = (int)i;
a = ((a % period) + period) % period;
return lerp(h2(a, seed), h2((a + 1) % period, seed), f);
}
float vnoise2(float2 p, int seed)
{
float2 i = floor(p), f = p - i;
f = f * f * (3.0 - 2.0 * f);
int x = (int)i.x, y = (int)i.y;
float a = h2(x, y * 131 + seed), b = h2(x + 1, y * 131 + seed);
float c = h2(x, y * 131 + 131 + seed), d = h2(x + 1, y * 131 + 131 + seed);
return lerp(lerp(a, b, f.x), lerp(c, d, f.x), f.y);
}
float4 over(float4 top, float4 under) { return top + under * (1.0 - top.a); }
float4 pm(float3 c, float a) { return float4(c * a, a); }
float cover(float d, float w) { return saturate(0.5 - d / w); }
float lum(float3 c) { return dot(c, float3(0.299, 0.587, 0.114)); }
float2 turn(float2 v, float deg) { float r = radians(deg), s = sin(r), c = cos(r); return float2(c * v.x - s * v.y, s * v.x + c * v.y); }
float fadeOut(float a, float b, float x) { return 1.0 - smoothstep(a, b, x); }
// ---------------------------------------------------------------- the sprite sheet
// A point of the sheet (units: 100 = the bar's height), read from the layer laid in the bar.
float4 sheet(float2 a)
{
return layerBack(float2(0.5 + (a.x - AW * 0.5) * size.y / (100.0 * size.x), a.y * 0.01));
}
// A frame at q (bar heights from its anchor, y up); nothing outside its cell (each cell has a clear margin, so a read
// at its edge doesn't pick up the next one).
float4 frameAt(float2 q, float4 cell, float2 anchor)
{
float2 a = anchor + float2(q.x, -q.y) * 100.0;
if (a.x < cell.x || a.y < cell.y || a.x > cell.x + cell.z || a.y > cell.y + cell.w) return float4(0, 0, 0, 0);
return sheet(a);
}
// How much of the sheet this bar can read (set in main): all of it on a taskbar; only its middle on a short, wide bar
// (a skin preview in the settings), since the sheet lies centred in the bar; none of it where the skin runs without
// its files (a preview in the gallery). A frame that can't be read is swapped for one that can, or drawn plainly.
static float g_half = 1e4; // half the sheet's width that lies in the bar, in sheet units
static bool g_sheet = true; // the sheet is there at all
bool cellShown(float x0, float w) { return g_sheet && x0 >= AW * 0.5 - g_half && x0 + w <= AW * 0.5 + g_half; }
bool heroShown(int f) { return cellShown(HC[f].x, HC[f].y); }
float4 heroFrame(int f, float2 q) { return frameAt(q, float4(HC[f].x, 0, HC[f].y, 100), HC[f].zw); }
// ---------------------------------------------------------------- the same things in plain shapes
float sdSeg(float2 p, float2 a, float2 b) { float2 pa = p - a, ba = b - a; return length(pa - ba * saturate(dot(pa, ba) / dot(ba, ba))); }
float sdBox(float2 p, float2 b) { float2 d = abs(p) - b; return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); }
// Lays a shape over what is there: its ink edge first, then its colour.
float4 shape(float4 acc, float d, float3 col, float px)
{
acc = over(pm(HX(0x1d1830), cover(d - 0.022, px)), acc);
return over(pm(col, cover(d, px)), acc);
}
// The hero without the sheet: hood with cat ears, face, tunic, legs and sword (q from the feet, bar heights, y up).
float4 heroDrawn(float2 q, int f, float px)
{
if (abs(q.x) > 0.7 || q.y < -0.12 || q.y > 1.05) return float4(0, 0, 0, 0);
bool air = f == F_RISE || f == F_FALL || f == F_TUCK || f == F_DASH;
bool slash = f >= 11 && f <= 14;
float sw = (f <= 5) ? sin(f / 6.0 * 6.2832) * 0.6 : 0.0;
float2 hip = float2(0.0, 0.27);
float2 footA = air ? hip + float2(0.12, -0.15) : hip + 0.25 * float2(sin(sw), -cos(sw));
float2 footB = air ? hip + float2(-0.13, -0.11) : hip + 0.25 * float2(sin(-sw), -cos(-sw));
float2 hand = slash ? float2(0.16, 0.44) : float2(0.06, 0.33);
float2 tip = slash ? float2(0.58, 0.52) : (f >= 15 ? float2(0.22, 0.0) : float2(-0.44, 0.22));
float4 acc = float4(0, 0, 0, 0);
acc = shape(acc, sdSeg(q, hand, tip) - 0.016, HX(0xdfe6f5), px);
acc = shape(acc, sdSeg(q, hip, footB) - 0.042, HX(0x232842), px);
acc = shape(acc, length(q - footB - float2(0.03, 0.0)) - 0.05, HX(0x5e3a26), px);
acc = shape(acc, sdBox(q - float2(0.0, 0.37), float2(0.09, 0.1)) - 0.035, HX(0x2e8c84), px);
acc = over(pm(HX(0x6b4a2a), cover(max(abs(q.y - 0.29) - 0.022, sdBox(q - float2(0.0, 0.37), float2(0.09, 0.1)) - 0.035), px)), acc);
acc = shape(acc, sdSeg(q, hip, footA) - 0.042, HX(0x2b3150), px);
acc = shape(acc, length(q - footA - float2(0.03, 0.0)) - 0.05, HX(0x7a4a2c), px);
// The hood and its ears.
float ears = 9.0;
[unroll] for (int s = -1; s <= 1; s += 2)
ears = min(ears, max(0.72 - q.y, abs(q.x - s * 0.11) * 2.0 + (q.y - 0.95)) * 0.45);
float hood = min(length(q - float2(0.0, 0.64)) - 0.2, ears);
acc = shape(acc, hood, lerp(HX(0xf1eef8), HX(0xc9c3dc), smoothstep(0.0, -0.12, q.x)), px);
acc = over(pm(HX(0xf3a6c0), cover(ears + 0.03, px)), acc);
// The face, the fringe, the eyes.
float face = length(q - float2(0.07, 0.6)) - 0.12;
acc = shape(acc, face, HX(0xffdcc4), px);
acc = over(pm(HX(0x7a4a32), cover(max(face, 0.665 - q.y + 0.03 * sin(q.x * 60.0)), px)), acc);
float eyes = min(length(q - float2(0.05, 0.6)), length(q - float2(0.13, 0.6))) - 0.019;
acc = over(pm(HX(0x2a2038), cover(eyes, px)), acc);
acc = over(pm(HX(0xff9fb0), cover(length(q - float2(0.15, 0.55)) - 0.02, px) * 0.8), acc);
return acc;
}
// A small thing without the sheet, from the same anchor as its sprite (bottom, middle, or a lamp's hook).
float4 smallDrawn(int s, float2 q, float px)
{
if (abs(q.x) > 0.45 || abs(q.y - 0.1) > 0.55) return float4(0, 0, 0, 0);
float4 acc = float4(0, 0, 0, 0);
[branch] if (s <= S_SLIME1)
{
float2 b = (q - float2(0.0, 0.16)) / float2(0.29, 0.18 - 0.03 * s);
float d = max((length(b) - 1.0) * 0.17, -q.y);
acc = shape(acc, d, lerp(HX(0x2c2f86), HX(0x5559cc), saturate(q.y * 3.0)), px);
acc = over(pm(HX(0xffd75e), cover(min(length(q - float2(-0.08, 0.18)), length(q - float2(0.06, 0.18))) - 0.026, px)), acc);
}
else if (s <= S_BAT1)
{
float flap = s == S_BAT0 ? 0.12 : -0.08;
float wings = 9.0;
[unroll] for (int k = -1; k <= 1; k += 2)
wings = min(wings, sdSeg(q, float2(0.0, 0.0), float2(k * 0.3, flap)) - 0.045);
acc = shape(acc, min(wings, length(q / float2(1.0, 1.25)) - 0.1), HX(0x3a2f6e), px);
acc = over(pm(HX(0xffd75e), cover(min(length(q - float2(-0.04, 0.02)), length(q - float2(0.04, 0.02))) - 0.02, px)), acc);
}
else if (s == S_COIN)
{
acc = shape(acc, length(q) - 0.14, HX(0xc98a1a), px);
acc = over(pm(HX(0xffcf4a), cover(length(q) - 0.105, px)), acc);
}
else if (s == S_GEM)
acc = shape(acc, (abs(q.x) / 0.13 + abs(q.y) / 0.18 - 1.0) * 0.1, lerp(HX(0x3cc8c8), HX(0xa8fff4), saturate(q.y * 4.0 + 0.5)), px);
else if (s == S_HEART)
{
// Two round lobes on a square stood on its corner.
float d = min(min(length(q - float2(-0.05, 0.03)), length(q - float2(0.05, 0.03))) - 0.07,
sdBox(turn(q - float2(0.0, -0.025), 45.0), float2(0.07, 0.07)));
acc = shape(acc, d, HX(0xff6f91), px);
}
else if (s <= S_CHESTOPEN)
{
float d = sdBox(q - float2(0.0, 0.15), float2(0.23, 0.15));
if (s == S_CHESTOPEN) d = min(d, sdBox(turn(q - float2(-0.2, 0.32), -55.0) - float2(0.12, 0.0), float2(0.13, 0.04)));
acc = shape(acc, d, HX(0x8c5b3a), px);
acc = over(pm(HX(0xe9b84a), cover(max(d, abs(q.x) - 0.035), px)), acc);
}
else if (s <= S_LAMPON)
{
float d = sdBox(q - float2(0.0, -0.17), float2(0.07, 0.1)) - 0.02;
acc = shape(acc, min(d, sdSeg(q, float2(0, 0), float2(0, -0.06)) - 0.012), s == S_LAMPON ? HX(0xffd27a) : HX(0x5c6080), px);
}
else
{
float3 head = s == S_BUD ? HX(0x8a7fd0) : s == S_CORAL ? HX(0xff8f80) : s == S_GOLD ? HX(0xffd25a) : HX(0xc59cff);
acc = shape(acc, sdSeg(q, float2(0, 0), float2(0, 0.2)) - 0.014, HX(0x3f8050), px);
acc = shape(acc, length(q - float2(0.0, 0.24)) - (s == S_BUD ? 0.045 : 0.07), head, px);
}
return acc;
}
float4 smallFrame(int s, float2 q, float px)
{
[branch] if (cellShown(SC[s].x, SC[s].z)) return frameAt(q, SC[s], SA[s]);
return smallDrawn(s, q, px);
}
// ---------------------------------------------------------------- the level
struct Ctx
{
float t, tau, xs, xbig, heroX, W, px, k, room;
float top; // the bar's top edge in the world's height (the ground is 0)
int i, cyc, type;
float4 hp; // the hero: x in the encounter, feet height, frame, turn
float2 sq; // squash
float vy; // rising (+) or falling
float dashAge; // seconds since a dash began (large when none)
bool compact;
};
// The hero's path in an encounter: (x, feet height, rising speed, turn). Samples are (x, height, turn, squash across,
// negative in the air); the squash up and down follows from the one across.
float4 pathAt(int type, float tau, out float2 sq, out bool air)
{
float f = clamp(tau, 0.0, T_ENC) * RATE;
int k = min((int)f, NS - 2);
float u = f - k;
int b = type * NS + k;
float4 a0 = PATH[b], a1 = PATH[b + 1];
air = (u < 0.5 ? a0.w : a1.w) < 0.0;
float sx = lerp(abs(a0.w), abs(a1.w), u);
sq = float2(sx, 1.0 - (sx - 1.0) * 1.15);
float r = a1.z < a0.z - 180.0 ? a0.z : lerp(a0.z, a1.z, u);
return float4(lerp(a0.xy, a1.xy, u), (a1.y - a0.y) * RATE, r);
}
// Which frame the hero shows: a pose of the encounter (windup, strike, crouch...), else what the motion says.
float heroPose(int type, float tau, float4 path, bool air, float2 sq, float dashAge)
{
float f = -1.0;
[unroll] for (int n = 0; n < 6; n++)
{
float4 e = PE[type * 6 + n];
if (tau >= e.x && tau < e.z) f = e.y;
}
if (f >= 0.0) return f;
if (air)
{
if (path.w > 0.5) return F_TUCK;
if (dashAge < 0.3) return F_DASH;
return path.z > 0.6 * VS ? F_RISE : F_FALL;
}
return sq.x > 1.07 ? F_CROUCH : -1.0;
}
// Which encounter a place of the loop (w, in the hero's loop's coordinates) is in: k loops on, the j-th, lx into it.
void locate(float w, out int k, out int j, out float lx)
{
k = (int)floor(w / CYC);
float win = w - k * CYC;
j = 0;
[unroll] for (int n = 1; n < NLOOP; n++) j = PRE[n] <= win ? n : j;
lx = win - PRE[j];
}
// ---------------------------------------------------------------- little drawings
// A four-pointed sparkle.
float sparkle(float2 q, float r)
{
q = abs(q) / max(r, 1e-4);
return saturate(exp(-q.x * 9.0 - q.y * 1.3) + exp(-q.y * 9.0 - q.x * 1.3) + exp(-dot(q, q) * 6.0) * 0.6);
}
// An eighth note, its head at the origin, about 0.2 tall.
float noteSd(float2 q)
{
float head = length(turn(q, 25.0) * float2(1.0, 1.45)) - 0.042;
float2 s = q - float2(0.038, 0.0);
float stem = max(abs(s.x) - 0.009, abs(s.y - 0.085) - 0.085);
float2 g = q - float2(0.05, 0.15);
float flag = max(abs(g.x - g.y * 0.4) - 0.012, abs(g.y + 0.02) - 0.035);
flag = min(flag, length(g - float2(0.03, -0.04)) - 0.012);
return min(head, min(stem, flag));
}
// A monster going up in smoke that turns to light: dark puffs, gold sparks, two notes rising.
void poof(float2 q, float age, float seed, float px, inout float4 front, inout float3 glow)
{
if (age < 0.0 || age > 1.6 || abs(q.x) > 0.9 || q.y < -0.4 || q.y > 1.5) return;
float grow = 1.0 - exp(-age * 7.0);
[loop] for (int m = 0; m < 6; m++)
{
float a = m * 1.047 + seed * 6.0;
float2 c = float2(cos(a), sin(a) * 0.7 + 0.35) * (0.06 + 0.3 * grow) + float2(0, 0.2);
float r = 0.07 + 0.11 * grow;
float al = cover(length(q - c) - r, px) * fadeOut(0.18, 0.6, age) * 0.9;
float3 col = lerp(HX(0x6c5cc4), HX(0x2a2252), saturate(age * 2.5));
front = over(pm(col, al), front);
}
[loop] for (int s = 0; s < 7; s++)
{
float a = s * 0.9 + seed * 3.0;
float2 c = float2(cos(a), sin(a) * 0.8 + 0.5) * (0.5 * grow) + float2(0, 0.2);
glow += HX(0xffd46a) * sparkle(q - c, 0.05) * fadeOut(0.25, 0.7, age) * 1.3;
}
[loop] for (int n = 0; n < 2; n++)
{
float2 c = float2((n ? 0.18 : -0.14) + 0.06 * sin(age * 7.0 + n * 2.0), 0.3 + age * (0.55 + 0.15 * n));
float d = noteSd(q - c);
float al = smoothstep(0.1, 0.25, age) * fadeOut(0.9, 1.5, age);
front = over(pm(HX(0xffe9a8), cover(d, px) * al), front);
glow += HX(0xffc45a) * exp(-max(d, 0.0) / 0.04) * al * 0.5;
}
}
/// ---------------------------------------------------------------- the world's things
struct Props
{
float4 back, front;
float3 glow, light;
float bed, onThorns; // bed: over a row of spikes (no grass or flowers there)
};
int pickupSprite(float kind) { return kind < 1.5 ? S_COIN : kind < 2.5 ? S_GEM : S_HEART; }
// Where a coin, gem or heart is read from its sprite: coins spin, the others bob.
float2 pickupAt(int s, float2 q, float t, float seed)
{
if (s == S_COIN) q.x /= max(abs(cos(t * 3.2 + seed * 6.0)), 0.18);
else q.y -= 0.035 * sin(t * 2.6 + seed * 6.0);
return q;
}
// Each thing of an encounter says what it shows at this pixel (a sprite and where in it, a smoke puff, a catch); the
// sprite is read once at the end, so the long list of kinds stays light to compile.
void encounterThings(Ctx c, float2 p, float w, int k, int j, float past, inout Props o)
{
int type = ORD[j];
float start = k * CYC + PRE[j];
float dn = (float)(k * NLOOP + j - c.i);
float x = w - start; // the pixel, in this encounter's coordinates
float seed = h2(j, c.cyc + k);
float t = c.t;
float px = c.px;
float3 ambient = lerp(float3(0.62, 0.66, 0.95), float3(1.0, 0.95, 0.9), past);
[loop] for (int m = 0; m < 8; m++)
{
float4 A = OA[type * 8 + m];
if (A.x < 0.5) break;
float4 B = OB[type * 8 + m];
int kind = (int)(A.x + 0.5);
float2 q = float2(x - A.y, p.y - A.z);
float age = c.tau - dn * T_ENC - A.w;
float ms = seed + m * 0.137;
int spr = -1;
float2 sq = float2(0, 0);
float3 tint = float3(1, 1, 1);
bool white = false, inFront = false;
float poofAge = -1.0, caughtAge = -1.0;
float2 poofAt = float2(0, 0), caughtAt = float2(0, 0);
int caughtSpr = S_COIN;
[branch] if (kind == K_SPIKES)
{
// Iron spikes standing in a rail sunk in the ground: moonlit steel ahead, lantern-warm behind.
float len = B.x;
if (q.x > -0.12 && q.x < len + 0.12 && q.y > -0.08 && q.y < 0.34)
{
if (q.x > 0.0 && q.x < len) o.bed = 1.0;
float cw = 0.2;
float nn = floor(len / cw);
float x0 = (len - nn * cw) * 0.5 + cw * 0.5;
float n = clamp(floor((q.x - x0) / cw + 0.5), 0.0, nn - 1.0);
float sx = q.x - (x0 + n * cw);
float hs = 0.25 + 0.05 * h1((int)n + j * 13);
float hw = 0.078;
float slope = hs / hw;
float d = max((abs(sx) * slope + q.y - hs) / sqrt(1.0 + slope * slope), -q.y);
float3 ink = HX(0x120e1c);
float3 steel = lerp(HX(0x4a5478), HX(0x6a5a6a), past);
float3 lit = lerp(HX(0xb4c2ea), HX(0xffc890), past);
// One face catches the light, the other is in shade; the tip shines.
float3 sc = lerp(steel * 0.62, steel, step(sx, 0.0));
sc = lerp(sc, lit, smoothstep(hs * 0.45, hs * 0.95, q.y) * (sx < 0.0 ? 0.85 : 0.35));
sc = lerp(sc, lit, cover(abs(sx + 0.008) - 0.006, px) * smoothstep(0.02, hs * 0.7, q.y) * 0.5);
float4 col = pm(ink, cover(d - 0.018, px));
col = over(pm(sc, cover(d, px)), col);
// The rail, with a rivet under each spike.
float rail = max(abs(q.x - len * 0.5) - len * 0.5 - 0.05, abs(q.y - 0.02) - 0.04);
col = over(pm(ink, cover(rail - 0.014, px)), col);
float3 rc = lerp(HX(0x2a2a40), HX(0x3e2c34), past) * (0.85 + 0.3 * smoothstep(0.0, 0.035, q.y));
col = over(pm(rc, cover(rail, px)), col);
float rv = length(float2(sx, q.y - 0.02)) - 0.016;
col = over(pm(lerp(rc, lit, 0.45), cover(rv, px)), col);
o.back = over(col, o.back);
// Now and then a glint runs along the tips.
float2 tip = float2(sx, q.y - hs);
float run = frac(t * 0.35 + seed) * (len + 1.5) - 0.75;
float g = exp(-abs(x0 + n * cw - run) / 0.12);
o.glow += lerp(HX(0xcfe0ff), HX(0xffd9a0), past) * sparkle(tip, 0.06) * (0.05 + 0.9 * g);
}
}
else if (kind == K_COIN || kind == K_GEM || kind == K_HEART)
{
int s = kind == K_COIN ? S_COIN : kind == K_GEM ? S_GEM : S_HEART;
if (abs(q.x) < 0.5 && abs(q.y) < 0.6)
{
if (age < 0.0)
{
spr = s;
sq = pickupAt(s, q, t, ms);
tint = lerp(0.8, 1.05, past);
o.glow += (s == S_GEM ? HX(0x7af0e8) : HX(0xffd65a)) * exp(-dot(q, q) / 0.02) * 0.18;
}
caughtAge = age;
caughtSpr = s;
caughtAt = q;
}
}
else if (kind == K_SLIME || kind == K_STOMP || kind == K_BAT)
{
if (abs(q.x) < 1.0 && q.y > -0.4 && q.y < 1.6)
{
bool bat = kind == K_BAT;
float2 r = q;
if (bat) r.y -= age < 0.0 ? 0.07 * sin(t * 3.1 + ms * 9.0) : 0.0;
float ph = frac(t * 1.7 + ms * 7.0);
if (!bat && age < 0.0) r.y -= 0.11 * max(0.0, sin(ph * 6.2832));
if (age < 0.09)
{
spr = bat ? (frac(t * 6.5 + ms) < 0.5 ? S_BAT0 : S_BAT1) : ((ph > 0.55 && ph < 0.95) || age >= 0.0 ? S_SLIME1 : S_SLIME0);
float2 squash = age < 0.0 || bat ? float2(1.0, 1.0) : (kind == K_STOMP ? float2(1.35, 0.45) : float2(1.25, 0.7));
sq = r / squash;
sq.x = -sq.x; // facing the hero
white = age >= 0.0;
tint = ambient;
if (age < 0.0)
{
float4 e = SE[spr];
float2 e1 = float2(-(e.x - SA[spr].x), SA[spr].y - e.y) * 0.01;
float2 e2 = float2(-(e.z - SA[spr].x), SA[spr].y - e.w) * 0.01;
o.glow += HX(0xffd75e) * (exp(-dot(r - e1, r - e1) / 0.0011) + exp(-dot(r - e2, r - e2) / 0.0011)) * lerp(0.9, 0.35, past);
}
}
poofAge = age - 0.05;
poofAt = bat ? r + float2(0.0, 0.2) : q;
}
}
else if (kind == K_CHEST)
{
if (abs(q.x) < 0.8 && q.y > -0.1 && q.y < 1.4)
{
spr = age < 0.0 ? S_CHEST : S_CHESTOPEN;
sq = q;
tint = lerp(float3(0.66, 0.7, 0.95), float3(1.0, 0.96, 0.9), past);
white = age >= 0.0 && age < 0.06;
if (age >= 0.0)
{
float beam = exp(-abs(q.x) / 0.09) * smoothstep(0.1, 0.3, q.y) * exp(-(q.y - 0.3) / 0.5) * fadeOut(0.6, 1.8, age);
o.glow += HX(0xffd98a) * beam * 0.9;
}
}
}
else if (kind == K_LAMP)
{
if (abs(q.x - 0.1) < 1.6 && q.y < 2.0)
{
bool lit = age >= 0.0;
// The post: iron, curling over at the top to a hook.
float post = max(abs(q.x) - 0.022, max(-q.y, q.y - 0.97));
float2 arm = q - float2(0.1, 0.94);
float curl = abs(length(arm * float2(1.0, 1.6)) - 0.1) - 0.016;
curl = max(curl, -arm.y - 0.02);
float d = min(post, curl);
o.back = over(pm(lerp(HX(0x1c1828), HX(0x2c2638), past), cover(d, px)), o.back);
o.back = over(pm(HX(0x4a3f5a) * (0.6 + 0.4 * past), cover(max(abs(q.x + 0.01) - 0.006, max(-q.y + 0.05, q.y - 0.9)), px)), o.back);
spr = lit ? S_LAMPON : S_LAMPOFF;
sq = q - float2(0.2, 0.93);
if (!lit) tint = float3(0.7, 0.74, 0.95);
if (lit)
{
float flick = 0.88 + 0.12 * vnoise(t * 9.0 + ms * 50.0, 7) + 0.25 * beat;
float2 lc = q - float2(0.2, 0.83);
float ign = exp(-age * 6.0);
o.glow += HX(0xffc46b) * (exp(-dot(lc, lc) / 0.004) * 1.2 + exp(-length(lc) / 0.28) * 0.35) * flick;
o.glow += HX(0xfff2c8) * sparkle(lc, 0.12 + 0.4 * (1.0 - ign)) * ign * 1.2;
o.light += HX(0xffad5a) * exp(-dot(lc, lc) / 2.2) * 0.85 * flick;
}
}
}
else if (kind == K_PLANK)
{
float len = B.x;
if (q.x > -0.2 && q.x < len + 0.2 && q.y < 0.1 && q.y > -A.z - 0.05)
{
float3 wood = HX(0x8c5b3a), dark = HX(0x4b2d21), hi = HX(0xc68e5c), ink = HX(0x1d1830);
float2 b = q - float2(len * 0.5, -0.065);
float body = max(abs(b.x) - len * 0.5, abs(b.y) - 0.065);
float4 col = float4(0, 0, 0, 0);
// Two posts down to the ground.
[unroll] for (int s = 0; s < 2; s++)
{
float x0 = s == 0 ? 0.28 : len - 0.28;
float pd = max(abs(q.x - x0) - 0.045, max(q.y + 0.12, -q.y - A.z));
col = over(pm(ink, cover(pd - 0.018, px)), col);
col = over(pm(lerp(dark, wood, 0.4) * (0.75 + 0.25 * step(q.x, x0)), cover(pd, px)), col);
}
col = over(pm(ink, cover(body - 0.02, px)), col);
float seam = abs(frac((q.x + 0.06) / 0.46) - 0.5) * 0.46;
float3 wc = lerp(wood, hi, smoothstep(-0.03, -0.006, q.y));
wc = lerp(wc, dark, smoothstep(-0.09, -0.125, q.y) * 0.7);
wc = lerp(wc, dark, 1.0 - smoothstep(0.006, 0.014, seam));
wc *= 0.92 + 0.08 * vnoise(q.x * 30.0 + q.y * 4.0, 3);
float nail = length(float2(seam - 0.035, q.y + 0.065)) - 0.012;
wc = lerp(wc, HX(0x2a2028), cover(nail, px));
col = over(pm(wc * lerp(float3(0.75, 0.78, 0.95), float3(1, 1, 1), past), cover(body, px)), col);
o.back = over(col, o.back);
}
}
else if (kind == K_THORNS)
{
float len = B.x;
if (q.x > -0.15 && q.x < len + 0.15 && q.y < 0.5 && q.y > -0.05)
{
float u = q.x;
float bloom = saturate((c.xs - (start + A.y + u)) * 1.5);
float edge = smoothstep(-0.12, 0.12, u) * smoothstep(-0.12, 0.12, len - u);
float top = (0.16 + 0.11 * vnoise(u * 5.0, 11) + 0.05 * sin(u * 13.0)) * edge;
float4 col = pm(lerp(HX(0x24173a), HX(0x1d3a2a), bloom), cover(q.y - top, px));
[unroll] for (int v = 0; v < 3; v++)
{
float vy = (0.07 + 0.075 * v + 0.045 * sin(u * 7.0 + v * 2.1 + 0.6 * sin(u * 3.0))) * edge;
float dv = abs(q.y - vy) - 0.017;
// Thorns along the vine, pointing up or down.
float tu = frac(u / 0.13 + v * 0.37) - 0.5;
float side = frac(floor(u / 0.13 + v * 0.37) * 0.5) < 0.25 ? 1.0 : -1.0;
float ty = (q.y - vy) * side;
float thorn = max(abs(tu) * 0.13 - (0.045 - ty) * 0.35, max(-ty, ty - 0.05));
float d = min(dv, thorn);
float3 vc = thorn < dv ? lerp(HX(0xc65c9e), HX(0x6fb060), bloom) : lerp(HX(0x4c3570), HX(0x3f8050), bloom);
col = over(pm(HX(0x15101f), cover(d - 0.012, px)), col);
col = over(pm(vc, cover(d, px)), col);
}
// Roses open where the hero went by.
float rc = floor(u / 0.21);
float rh = h2((int)rc, 17 + j);
float2 rp = float2((rc + 0.25 + 0.5 * rh) * 0.21, (0.1 + 0.18 * h1((int)rc * 3 + j)) * edge);
float rr = 0.05 * smoothstep(0.0, 0.35, bloom - rh * 0.3);
if (rr > 0.001)
{
float rd = length(q - rp) - rr;
float spiral = sin(atan2(q.y - rp.y, q.x - rp.x) * 3.0 + length(q - rp) * 90.0);
col = over(pm(HX(0x2a1020), cover(rd - 0.012, px)), col);
col = over(pm(lerp(HX(0xff7fa8), HX(0xd84a7c), 0.5 + 0.5 * spiral), cover(rd, px)), col);
o.glow += HX(0xff9ac0) * exp(-max(rd, 0.0) / 0.05) * 0.12;
}
o.back = over(col, o.back);
if (q.x > 0.0 && q.x < len) o.onThorns = 1.0;
}
}
else if (kind == K_BURST)
{
if (age >= 0.0 && age < 1.1 && abs(q.x) < 4.0)
{
float2 heroAt = float2(c.xs - (start + A.y), c.hp.y + 0.45 - A.z);
// The coins fly out of the chest, then home in on the hero. The nearest one is drawn here.
float best = 9.0;
float2 bestQ = float2(9, 9);
[loop] for (int n = 0; n < 7; n++)
{
float an = radians(lerp(62.0, 122.0, n / 6.0));
float sp = 3.1 + 0.6 * h1(n + j * 7);
float tl = min(age, 0.42);
float2 pos = float2(cos(an) * sp * tl * 0.55, sin(an) * sp * VS * tl - 0.5 * GRAV * tl * tl);
float hu = saturate((age - 0.42) / 0.33);
pos = lerp(pos, heroAt, hu * hu);
float d = dot(q - pos, q - pos);
if (d < best) { best = d; bestQ = q - pos; }
}
if (age < 0.75)
{
spr = S_COIN;
sq = pickupAt(S_COIN, bestQ / 0.85, t, ms);
inFront = true;
}
caughtAge = age - 0.75;
caughtAt = q - heroAt;
}
}
else if (kind == K_DROP)
{
float got = B.w - A.w;
int s = pickupSprite(B.x);
if (age >= 0.0 && age < got + 0.6)
{
float ta = min(age, got);
float2 pos = float2(B.y * min(ta, 0.6), max(B.z * ta - 0.5 * GRAV * ta * ta, 0.32 - A.z));
float2 r = q - pos;
if (abs(r.x) < 0.6 && abs(r.y) < 1.0)
{
if (age < got) { spr = s; sq = pickupAt(s, r, t, ms); inFront = true; }
caughtAge = age - got;
caughtSpr = s;
caughtAt = r;
}
}
}
// The sprite, read once.
if (spr >= 0)
{
float4 sp = smallFrame(spr, sq, px);
sp.rgb = white ? sp.aaa : sp.rgb * tint;
if (inFront) o.front = over(sp, o.front);
else o.back = over(sp, o.back);
}
// Caught: it hops up, shrinks and leaves a sparkle.
if (caughtAge >= 0.0 && caughtAge < 0.5 && abs(caughtAt.x) < 0.6 && abs(caughtAt.y) < 0.9)
{
float u = saturate(caughtAge / 0.28);
float2 lift = float2(0.0, 0.35 * (1.0 - (1.0 - u) * (1.0 - u)));
float kk = 1.0 - 0.6 * u;
o.front = over(smallFrame(caughtSpr, (caughtAt - lift) / kk, px) * fadeOut(0.15, 0.28, caughtAge), o.front);
o.glow += HX(0xfff0b0) * sparkle(caughtAt - lift, 0.18 * (0.5 + u)) * fadeOut(0.1, 0.5, caughtAge) * 1.4;
}
if (poofAge >= 0.0 && poofAge < 1.6) poof(poofAt, poofAge, ms, px, o.front, o.glow);
}
}
// The effects of an encounter: slashes, rings, dust, the light of a hit.
void encounterEffects(Ctx c, float2 p, float w, int k, int j, inout float4 front, inout float3 glow)
{
int type = ORD[j];
float start = k * CYC + PRE[j];
float dn = (float)(k * NLOOP + j - c.i);
float x = w - start;
float px = c.px;
[loop] for (int m = 0; m < 4; m++)
{
float4 E = FX[type * 4 + m];
if (E.x < 0.5) break;
int kind = (int)(E.x + 0.5);
float age = c.tau - dn * T_ENC - E.y;
if (age < 0.0 || age > 0.5) continue;
float2 q = float2(x - E.z, p.y - E.w);
if (abs(q.x) > 2.0 || q.y < -0.5 || q.y > 2.2) continue;
if (kind == E_SLASH || kind == E_AIR)
{
bool air = kind == E_AIR;
float2 d = q - float2(0.16, 0.47);
float r = length(d);
float ang = degrees(atan2(d.y, d.x));
float a0 = air ? 150.0 : 118.0, a1 = air ? -105.0 : -58.0;
float sweep = saturate(age / 0.085);
sweep = 1.0 - (1.0 - sweep) * (1.0 - sweep);
float lead = lerp(a0, a1, sweep);
float along = (a0 - ang) / (a0 - a1);
float behind = (ang - lead) / (a0 - a1);
float trail = step(-0.02, behind) * exp(-max(behind, 0.0) * 2.6) * step(ang, a0) * step(a1 - 4.0, ang);
// A crescent smear: thickest mid-swing, sharp and bright on its outer edge, coral inside.
float outer = 0.9;
float thick = 0.035 + 0.15 * sin(3.14159 * saturate(along)) * saturate(sweep * 1.5);
float band = smoothstep(outer - thick - 0.02, outer - thick + 0.02, r) * fadeOut(outer - 0.01, outer + 0.015, r);
float edge = smoothstep(outer - thick, outer - 0.012, r);
float v = band * trail * fadeOut(0.09, 0.2, age);
glow += lerp(HX(0xff5f6d), HX(0xfff6dc), edge) * v * (0.7 + 0.9 * edge);
front = over(pm(lerp(HX(0xff8a8a), HX(0xffffff), edge), v * (0.25 + 0.45 * edge)), front);
// Where it lands: a burst of light.
float2 hit = q - float2(REACH + 0.05, air ? 0.5 : 0.36);
glow += HX(0xfff0c0) * sparkle(hit, 0.12 + 0.5 * age) * fadeOut(0.03, 0.2, age) * 1.6;
}
else if (kind == E_HIT)
{
glow += HX(0xfff0c0) * sparkle(q - float2(0.0, 0.05), 0.15 + 0.6 * age) * fadeOut(0.02, 0.22, age) * 1.6;
float ring = abs(length(q * float2(1.0, 3.0)) - (0.15 + 1.4 * age)) - 0.02;
glow += HX(0xbff4ff) * cover(ring, px * 2.0) * fadeOut(0.05, 0.3, age);
}
else if (kind == E_RING)
{
float rr = 0.16 + 1.3 * age;
float ring = abs(length((q - float2(0.0, 0.03)) * float2(1.0, 3.2)) - rr) - 0.016 - 0.02 * (1.0 - age * 3.0);
float v = cover(ring, px * 1.5) * fadeOut(0.08, 0.34, age);
glow += HX(0xbff4ff) * v * 1.3;
front = over(pm(HX(0xe8fbff), v * 0.4), front);
}
else if (kind == E_DUST)
{
[unroll] for (int s = -1; s <= 1; s += 2)
{
[unroll] for (int n = 0; n < 2; n++)
{
float2 cpos = float2(s * (0.12 + n * 0.1 + age * (0.7 + n * 0.4)), 0.04 + age * 0.25);
float r = 0.04 + age * 0.22 - n * 0.01;
float al = cover(length(q - cpos) - r, px) * fadeOut(0.05, 0.35, age) * 0.55;
front = over(pm(HX(0xb8b0c8), al), front);
}
}
}
}
}
// ---------------------------------------------------------------- the hero
float4 drawHero(Ctx c, float2 p, float past, inout float3 glow)
{
float2 q = p - float2(c.heroX, c.hp.y);
if (abs(q.x) > 1.6 || q.y < -0.3 || q.y > 1.6) return float4(0, 0, 0, 0);
float px = c.px;
int runF = (int)(frac(c.xbig / (CYC / round(CYC / 1.12))) * 6.0);
int f = c.hp.z < -0.5 ? runF : (int)(c.hp.z + 0.5);
// Paused: the hero catches their breath.
if (playing < 0.5 && c.hp.z < -0.5 && c.hp.y < 0.01) f = frac(c.t * 0.9) < 0.5 ? F_IDLE0 : F_IDLE1;
// A frame this bar can't read gives way to the run cycle (the sheet's middle), else the hero is drawn plainly.
if (!heroShown(f)) f = runF;
bool drawn = !heroShown(f);
float4 cell = HC[f];
float4 kc = HK[f];
float2 center = float2(kc.z - cell.z, cell.w - kc.w) * 0.01;
float rot = c.hp.w;
// Into the frame's own coordinates: undo the squash (about the feet), then the turn (about the middle).
float2 r = q / c.sq;
if (abs(rot) > 0.01) r = center + turn(r - center, rot);
float4 col = float4(0, 0, 0, 0);
// The scarf's tail, behind: from the knot, trailing against the way the hero moves, waving.
float2 knot = float2(kc.x - cell.z, cell.w - kc.y) * 0.01;
knot = center + turn(knot - center, -rot);
knot *= c.sq;
float speed = V_RUN * (c.dashAge < 0.32 ? 3.5 : 1.0);
float2 dir = -normalize(float2(speed, c.vy * 0.8 + 0.6));
float2 nrm = float2(-dir.y, dir.x);
float best = 9.0, bs = 0.0;
float2 prev = knot;
[unroll] for (int s = 1; s <= 6; s++)
{
float u = s / 6.0;
float wave = 0.055 * u * sin(u * 5.0 - c.t * 15.0) * (0.6 + 0.4 * saturate(speed / 4.0));
float2 pt = knot + dir * 0.52 * u + nrm * wave + float2(0.0, 0.05 * u * u);
float2 pa = q - prev, ba = pt - prev;
float hh = saturate(dot(pa, ba) / max(dot(ba, ba), 1e-6));
float d = length(pa - ba * hh);
if (d < best) { best = d; bs = (s - 1 + hh)
// (+19 KB more: download the file to see all of it)