Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f697bb244 | ||
|
|
8332bb879e | ||
|
|
b4508b84a7 | ||
|
|
cbdcbdd40e | ||
|
|
6cc71cf7c4 |
No files matched your search
@@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## [0.2.8] - 2026-10-27
|
||||
|
||||
- After the meadow, a new idea arrives every few dozen levels and keeps coming back: squirrels that dash and sit from level 45, hedgehogs that curl into a spiky ball as you come close from 85, keys that open a gate from 101, frogs that hop two tiles from 125, switch stones that open and close a gate from 141, rolling stones from 165 and portal rooms, reached only through a ring, from 181.
|
||||
- Each new idea takes every other board for ten levels. After that, the ideas you have met take turns, with no more than two plain boards in a row.
|
||||
- A gate closes a doorway up to four tiles wide. Its key opens it for good and is worth 2 points; a switch stone flips it each time you arrive on it. Boards with a gate or a portal room score more.
|
||||
- New pictures for the squirrel, hedgehog, frog, rolling stone, key, switch stone and gate.
|
||||
|
||||
## [0.2.7] - 2026-10-27
|
||||
|
||||
- On the desktop, Play starts right away with mouse steering; the keyboard always works, and Pause still switches to the direction pad.
|
||||
- wurm.waozi.xyz opens faster with a much lighter loading picture.
|
||||
|
||||
## [0.2.6] - 2026-10-27
|
||||
|
||||
- Glowing portals arrive from level 61: first on a few boards, then more often, with two pairs late in the mountains. Steer into one ring to come out of its partner, keeping your direction. Each ring stands in open ground, so you can always go around it.
|
||||
|
||||
|
After Width: | Height: | Size: 186 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 104 KiB |
@@ -749,6 +749,19 @@ DrawBoard :: (session: Session, stage: Rectangle) {
|
||||
}
|
||||
DrawGatePosts(session, stage)
|
||||
DrawPortals(session, stage)
|
||||
// A closed gate, the key that opens it or the switch stone that flips it.
|
||||
if game.gate >= 0 && !game.gate_open {
|
||||
for part: 0..game.gate_span - 1 {
|
||||
cell := game.gate + cast(s32)part * game.gate_step
|
||||
Sprite(session, 12110 + cast(u64)part, stage, Point.{(cell % board_columns) * 16 + 8, (cell / board_columns) * 16 + 8},
|
||||
Rectangle.{(ifx game.gate_step == 1 then 11.0 else 12.0) * 16.0, 64.0, 16.0, 16.0}, sprites)
|
||||
}
|
||||
}
|
||||
if game.key.x >= 0 { Sprite(session, 12101, stage, game.key, Rectangle.{8.0 * 16.0, 64.0, 16.0, 16.0}, sprites) }
|
||||
if game.switch_stone.x >= 0 {
|
||||
Sprite(session, 12102, stage, game.switch_stone,
|
||||
Rectangle.{(ifx game.gate_open then 10.0 else 9.0) * 16.0, 64.0, 16.0, 16.0}, sprites)
|
||||
}
|
||||
if game.apples > 0 && game.apple.x >= 0 {
|
||||
Sprite(session, 1400, stage, game.apple, Rectangle.{0.0, 112.0, 16.0, 16.0}, sprites)
|
||||
AppleFlash(session, stage)
|
||||
@@ -776,10 +789,18 @@ DrawBoard :: (session: Session, stage: Rectangle) {
|
||||
Rectangle.{cast(float32)game.direction * 16.0, 48.0, 16.0, 16.0}, sprites, WORM_HEAD_SIZE)
|
||||
}
|
||||
for monster: 0..game.monster_count - 1 {
|
||||
column := game.monsters[monster].kind - 1
|
||||
if game.monsters[monster].kind == 1 { column = 6 + enemy_frame }
|
||||
Sprite(session, 6000 + cast(u64)monster, stage, game.monsters[monster].position,
|
||||
Rectangle.{cast(float32)column * 16.0, 32.0, 16.0, 16.0}, sprites)
|
||||
creature := game.monsters[monster]
|
||||
column := creature.kind - 1
|
||||
row: float32 = 32.0
|
||||
if creature.kind == 1 { column = 6 + enemy_frame }
|
||||
// The animals met after the meadow share row four of every sheet.
|
||||
if creature.animal != ANIMAL_CLASSIC { row = 64.0 }
|
||||
if creature.animal == ANIMAL_SQUIRREL { column = (creature.timer / 4) % 2 }
|
||||
if creature.animal == ANIMAL_HEDGEHOG { column = ifx creature.timer < 0 then 3 else 2 }
|
||||
if creature.animal == ANIMAL_FROG { column = ifx creature.timer >= 14 && creature.timer % 14 < 4 then 5 else 4 }
|
||||
if creature.animal == ANIMAL_STONE { column = 6 + (creature.timer / 3) % 2 }
|
||||
Sprite(session, 6000 + cast(u64)monster, stage, creature.position,
|
||||
Rectangle.{cast(float32)column * 16.0, row, 16.0, 16.0}, sprites)
|
||||
}
|
||||
for particle: 0..99 {
|
||||
life := game.particles[particle].life
|
||||
|
||||
@@ -59,6 +59,13 @@ Load :: () {
|
||||
bytes: [2]u8
|
||||
count := ReadRecord("controls.dat", bytes[:])
|
||||
if count == 1 && bytes[0] <= 1 { mode = cast(s32)bytes[0] }
|
||||
// A desktop always has a keyboard, and a mouse drag steers like a swipe,
|
||||
// so it starts with swipe steering instead of asking. Phones, browsers
|
||||
// and hosted copies still ask.
|
||||
#if #defined(ANDROID_BUILD) || #defined(PLATFORM_WEB) || #defined(WURM_PORTABLE) {
|
||||
} else {
|
||||
if mode < 0 { mode = 0 }
|
||||
}
|
||||
}
|
||||
Chosen :: () -> bool { Load(); return mode >= 0 }
|
||||
Pad :: () -> bool { Load(); return mode == 1 }
|
||||
|
||||
@@ -48,9 +48,10 @@ Point :: struct { x: s32; y: s32; }
|
||||
// Two rings joined: stepping into one comes out of the other.
|
||||
Portal :: struct { a: Point; b: Point; }
|
||||
PORTAL_PAIRS :: 2;
|
||||
// The campaign certificate drives routes that never use a portal.
|
||||
portals_enabled: bool = true;
|
||||
Monster :: struct { position: Point; kind: s32; direction: s32; }
|
||||
// The certificate drives routes on the plain boards; animals stay active.
|
||||
features_enabled: bool = true;
|
||||
// animal: one of ANIMAL_*; timer counts the creature's own ticks.
|
||||
Monster :: struct { position: Point; kind: s32; direction: s32; animal: s32; timer: s32; }
|
||||
Particle :: struct { position: Point; life: s32; }
|
||||
Game :: struct {
|
||||
mode: s32
|
||||
@@ -75,6 +76,17 @@ Game :: struct {
|
||||
portal_count: s32
|
||||
portals: [PORTAL_PAIRS]Portal
|
||||
portal_wait: s32
|
||||
// This board's puzzle idea: a gate (a doorway up to four cells across,
|
||||
// gate_span cells gate_step apart), its key or switch stone.
|
||||
feature: s32
|
||||
gate: s32
|
||||
gate_span: s32
|
||||
gate_step: s32
|
||||
gate_tiles: [4]u8
|
||||
gate_open: bool
|
||||
key: Point
|
||||
switch_stone: Point
|
||||
on_switch: bool
|
||||
monsters: [MONSTER_LIMIT]Monster
|
||||
particles: [100]Particle
|
||||
death_ticks: s32
|
||||
@@ -190,6 +202,11 @@ LoadLevelData :: (game: *Game, level: s32, now: s64, board: []u8, apples: s32, c
|
||||
game.monsters[index].position = Point.{cast(s32)x * 16 + 8, cast(s32)y * 16 + 8}
|
||||
game.monsters[index].kind = kind
|
||||
game.monsters[index].direction = ifx kind == 1 then Random(game, 4) else kind - 2
|
||||
animal: s32 = ANIMAL_CLASSIC
|
||||
if kind == 1 { animal = RoamerAnimal(level, index) }
|
||||
else if kind >= 2 && kind <= 5 { animal = PatrolAnimal(level, index) }
|
||||
game.monsters[index].animal = animal
|
||||
game.monsters[index].timer = 0
|
||||
game.monster_count += 1
|
||||
game.board[Index(x, y)] = tile & 128
|
||||
}
|
||||
@@ -199,25 +216,209 @@ LoadLevelData :: (game: *Game, level: s32, now: s64, board: []u8, apples: s32, c
|
||||
// Carve the entrance before the apple chooses its spot, so it can never
|
||||
// land on a cell the carving turns into wall.
|
||||
Respawn(game)
|
||||
PlacePortals(game)
|
||||
PlaceIdeas(game)
|
||||
SpawnApple(game)
|
||||
game.multiplier = LevelMultiplier(game)
|
||||
}
|
||||
|
||||
// New ideas arrive slowly, one every twenty levels or so. Portals first
|
||||
// appear at level 61 on every third board, grow to every other board from 81
|
||||
// and every board from 161, with a second pair from 181.
|
||||
PORTAL_FIRST :: 60
|
||||
PortalPairsFor :: (level: s32) -> s32 {
|
||||
if level < PORTAL_FIRST { return 0 }
|
||||
if level < 80 { return ifx (level - PORTAL_FIRST) % 3 == 0 then 1 else 0 }
|
||||
if level < 160 { return ifx level % 2 == 0 then 1 else 0 }
|
||||
return ifx level >= 180 then PORTAL_PAIRS else 1
|
||||
// New ideas arrive one at a time, about twenty levels apart, and keep coming
|
||||
// back afterwards in a clean mix: squirrels from level 45, portals from 61,
|
||||
// hedgehogs from 85, keys and gates from 101, frogs from 125, switch stones
|
||||
// from 141, rolling stones from 165 and portal rooms from 181. A board's ideas
|
||||
// follow from its number and layout alone, so every player meets the same.
|
||||
IDEA_SQUIRREL :: 44
|
||||
IDEA_PORTALS :: 60
|
||||
IDEA_HEDGEHOG :: 84
|
||||
IDEA_KEY :: 100
|
||||
IDEA_FROG :: 124
|
||||
IDEA_SWITCH :: 140
|
||||
IDEA_STONE :: 164
|
||||
IDEA_PORTAL_ROOM :: 180
|
||||
// At most one puzzle idea per board.
|
||||
FEATURE_NONE :: 0
|
||||
FEATURE_PORTALS :: 1
|
||||
FEATURE_KEY :: 2
|
||||
FEATURE_SWITCH :: 3
|
||||
FEATURE_PORTAL_ROOM :: 4
|
||||
ANIMAL_CLASSIC :: 0
|
||||
ANIMAL_SQUIRREL :: 1
|
||||
ANIMAL_HEDGEHOG :: 2
|
||||
ANIMAL_FROG :: 3
|
||||
ANIMAL_STONE :: 4
|
||||
HEDGEHOG_CURL :: 60
|
||||
|
||||
// A well-spread number for each value, the same on every platform: no step
|
||||
// overflows 63 bits.
|
||||
Mix :: (value: s64) -> s32 {
|
||||
mixed := (value % 2147483648 + 2147483648) % 2147483648
|
||||
for round: 0..1 {
|
||||
mixed = (mixed * 1103515245 + 12345) % 2147483648
|
||||
mixed = mixed ^ (mixed >> 16)
|
||||
}
|
||||
return cast(s32)(mixed % 1000003)
|
||||
}
|
||||
|
||||
// Each ring stands in the middle of open floor, so the worm comes out safely
|
||||
// in any direction and a player can always go around one. The spots follow
|
||||
// from the board alone, so every player meets the same portals.
|
||||
// A new puzzle idea takes every other board for its first ten levels; then
|
||||
// the ideas so far take turns, with up to two plain boards between them.
|
||||
IdeaIntros: [4]s32 = .[IDEA_PORTALS, IDEA_KEY, IDEA_SWITCH, IDEA_PORTAL_ROOM];
|
||||
IdeasMet :: (level: s32) -> s32 {
|
||||
count: s32 = 0
|
||||
for index: 0..3 { if level >= IdeaIntros[index] { count = cast(s32)index + 1 } }
|
||||
return count
|
||||
}
|
||||
BoardFeature :: (level: s32) -> s32 {
|
||||
count := IdeasMet(level)
|
||||
if count == 0 { return FEATURE_NONE }
|
||||
newest := IdeaIntros[count - 1]
|
||||
if level - newest < 10 { return ifx (level - newest) % 2 == 0 then count else FEATURE_NONE }
|
||||
// Never more than two plain boards in a row.
|
||||
plain := Mix(cast(s64)level) % 10 < 4
|
||||
if plain && !(PlainMix(level - 1) && PlainMix(level - 2)) { return FEATURE_NONE }
|
||||
return 1 + Mix(cast(s64)level * 7 + 3) % count
|
||||
}
|
||||
PlainMix :: (level: s32) -> bool {
|
||||
count := IdeasMet(level)
|
||||
return count == 0 || level - IdeaIntros[count - 1] < 10 || Mix(cast(s64)level) % 10 < 4
|
||||
}
|
||||
|
||||
AnimalIntro :: (animal: s32) -> s32 {
|
||||
if animal == ANIMAL_SQUIRREL { return IDEA_SQUIRREL }
|
||||
if animal == ANIMAL_HEDGEHOG { return IDEA_HEDGEHOG }
|
||||
if animal == ANIMAL_FROG { return IDEA_FROG }
|
||||
if animal == ANIMAL_STONE { return IDEA_STONE }
|
||||
return 0
|
||||
}
|
||||
|
||||
// Wanderers: a landscape's own animal fills its first ten boards, then the
|
||||
// animals met so far mix with the classic flames.
|
||||
RoamerAnimal :: (level: s32, index: s32) -> s32 {
|
||||
available: [3]s32
|
||||
count: s32 = 0
|
||||
if level >= IDEA_SQUIRREL { available[count] = ANIMAL_SQUIRREL; count += 1 }
|
||||
if level >= IDEA_HEDGEHOG { available[count] = ANIMAL_HEDGEHOG; count += 1 }
|
||||
if level >= IDEA_FROG { available[count] = ANIMAL_FROG; count += 1 }
|
||||
if count == 0 { return ANIMAL_CLASSIC }
|
||||
stage := StageOf(level)
|
||||
native: s32 = ifx stage == 1 then ANIMAL_SQUIRREL else ifx stage == 2 then ANIMAL_HEDGEHOG else ifx stage == 3 then ANIMAL_FROG else ANIMAL_CLASSIC
|
||||
ready := native != ANIMAL_CLASSIC && level >= AnimalIntro(native)
|
||||
if ready && level - AnimalIntro(native) < 10 { return native }
|
||||
roll := Mix(cast(s64)level * 131 + cast(s64)index) % 10
|
||||
if roll < 3 { return ANIMAL_CLASSIC }
|
||||
if ready && roll < 7 { return native }
|
||||
return available[Mix(cast(s64)level * 17 + cast(s64)index) % count]
|
||||
}
|
||||
|
||||
// Patrols become rolling stones in the mountains.
|
||||
PatrolAnimal :: (level: s32, index: s32) -> s32 {
|
||||
if level < IDEA_STONE { return ANIMAL_CLASSIC }
|
||||
if level - IDEA_STONE < 10 || Mix(cast(s64)level * 29 + cast(s64)index) % 2 == 0 { return ANIMAL_STONE }
|
||||
return ANIMAL_CLASSIC
|
||||
}
|
||||
|
||||
Passable :: (game: *Game, at: s32) -> bool {
|
||||
tile := game.board[at]
|
||||
return tile < 20 || tile >= 128
|
||||
}
|
||||
|
||||
// Every cell the worm can reach from the entrance with a doorway closed: span
|
||||
// cells from door, step apart.
|
||||
FloodFrom :: (game: *Game, start: s32, door: s32, reached: []bool, span: s32 = 1, step: s32 = 1) -> s32 {
|
||||
closed: [CELLS]bool
|
||||
for at: 0..CELLS - 1 { reached[at] = false; closed[at] = false }
|
||||
if door >= 0 { for cell: 0..span - 1 { closed[door + cast(s32)cell * step] = true } }
|
||||
if !Passable(game, start) || closed[start] { return 0 }
|
||||
queue: [CELLS]s32
|
||||
head: s32 = 0
|
||||
tail: s32 = 1
|
||||
queue[0] = start
|
||||
reached[start] = true
|
||||
while head < tail {
|
||||
at := queue[head]
|
||||
head += 1
|
||||
x := at % board_columns
|
||||
y := at / board_columns
|
||||
neighbours: [4]s32 = .[ifx x > 0 then at - 1 else -1, ifx x < board_columns - 1 then at + 1 else -1,
|
||||
ifx y > 0 then at - board_columns else -1, ifx y < board_rows - 1 then at + board_columns else -1]
|
||||
for next: neighbours {
|
||||
if next < 0 || closed[next] || reached[next] || !Passable(game, next) { continue }
|
||||
reached[next] = true
|
||||
queue[tail] = next
|
||||
tail += 1
|
||||
}
|
||||
}
|
||||
return tail
|
||||
}
|
||||
|
||||
// A doorway: a straight run of one to four floor cells across a corridor,
|
||||
// walled at both ends and open on both sides, that once closed cuts the board
|
||||
// into two sizable halves, the far one holding the exit when the board allows.
|
||||
// reached marks the entrance side.
|
||||
Floor :: (game: *Game, x: s32, y: s32) -> bool { return Inside(x, y) && Passable(game, Index(x, y)) && game.board[Index(x, y)] < 128 }
|
||||
Solid :: (game: *Game, x: s32, y: s32) -> bool { return Inside(x, y) && !Passable(game, Index(x, y)) }
|
||||
DoorwaySpan :: (game: *Game, x: s32, y: s32, dx: s32, dy: s32) -> s32 {
|
||||
half := board_columns / 2
|
||||
if !Solid(game, x - dx, y - dy) { return 0 }
|
||||
for span: 1..4 {
|
||||
cx := x + dx * cast(s32)(span - 1)
|
||||
cy := y + dy * cast(s32)(span - 1)
|
||||
if cy < 2 || cy > board_rows - 4 || (Abs(cx - half) <= 3 && (cy <= 3 || cy >= board_rows - 4)) { return 0 }
|
||||
if !Floor(game, cx, cy) || !Floor(game, cx - dy, cy - dx) || !Floor(game, cx + dy, cy + dx) { return 0 }
|
||||
if Solid(game, cx + dx, cy + dy) { return cast(s32)span }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
FindDoorway :: (game: *Game, reached: []bool, span: *s32, step: *s32, feature: s32) -> s32 {
|
||||
half := board_columns / 2
|
||||
start := Index(half, board_rows - 2)
|
||||
exit := Index(half, 1)
|
||||
firsts: [2 * CELLS]s32
|
||||
spans: [2 * CELLS]s32
|
||||
steps: [2 * CELLS]s32
|
||||
count: s32 = 0
|
||||
for y: 2..board_rows - 4 {
|
||||
for x: 1..board_columns - 2 {
|
||||
across := DoorwaySpan(game, cast(s32)x, cast(s32)y, 1, 0)
|
||||
if across > 0 { firsts[count] = Index(x, y); spans[count] = across; steps[count] = 1; count += 1 }
|
||||
down := DoorwaySpan(game, cast(s32)x, cast(s32)y, 0, 1)
|
||||
if down > 0 { firsts[count] = Index(x, y); spans[count] = down; steps[count] = board_columns; count += 1 }
|
||||
}
|
||||
}
|
||||
if count == 0 { return -1 }
|
||||
total: s32 = 0
|
||||
for at: 0..CELLS - 1 { if Passable(game, cast(s32)at) { total += 1 } }
|
||||
fallback: s32 = -1
|
||||
offset := Mix(cast(s64)game.level) % count
|
||||
for attempt: 0..count - 1 {
|
||||
pick := (offset + cast(s32)attempt) % count
|
||||
near := FloodFrom(game, start, firsts[pick], reached, spans[pick], steps[pick])
|
||||
far := total - near - spans[pick]
|
||||
if near < 24 || far < 24 { continue }
|
||||
exit_beyond := Passable(game, exit) && !reached[exit]
|
||||
if !exit_beyond && fallback >= 0 { continue }
|
||||
if !IdeaFits(game, reached, firsts[pick], feature) { continue }
|
||||
if exit_beyond { span.* = spans[pick]; step.* = steps[pick]; return firsts[pick] }
|
||||
fallback = pick
|
||||
}
|
||||
if fallback < 0 { return -1 }
|
||||
unused FloodFrom(game, start, firsts[fallback], reached, spans[fallback], steps[fallback])
|
||||
span.* = spans[fallback]
|
||||
step.* = steps[fallback]
|
||||
return firsts[fallback]
|
||||
}
|
||||
|
||||
// Whether this board's idea has its spots once the doorway closes: a key or
|
||||
// switch stone before it, a portal on each side of a portal room.
|
||||
IdeaFits :: (game: *Game, reached: []bool, door: s32, feature: s32) -> bool {
|
||||
if feature == FEATURE_PORTAL_ROOM {
|
||||
spots: [CELLS]s32
|
||||
return OpenSpots(game, reached, 1, spots[:]) > 0 && OpenSpots(game, reached, 0, spots[:]) > 0
|
||||
}
|
||||
return SideSpot(game, reached, door, feature == FEATURE_KEY).x >= 0
|
||||
}
|
||||
|
||||
// Open spots for portals, keys and switch stones: the middle of open floor,
|
||||
// clear of the entrance and exit lanes and of the board's creatures. A key
|
||||
// or switch stone may also lie in a corridor (loose).
|
||||
OpenAround :: (game: *Game, x: s32, y: s32) -> bool {
|
||||
for dy: -1..1 {
|
||||
for dx: -1..1 {
|
||||
@@ -226,49 +427,65 @@ OpenAround :: (game: *Game, x: s32, y: s32) -> bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
OpenFloor :: (game: *Game, x: s32, y: s32) -> bool { return Inside(x, y) && game.board[Index(x, y)] < 20 }
|
||||
InCorridor :: (game: *Game, x: s32, y: s32) -> bool {
|
||||
if !OpenFloor(game, x, y) { return false }
|
||||
open: s32 = 0
|
||||
if OpenFloor(game, x - 1, y) { open += 1 }
|
||||
if OpenFloor(game, x + 1, y) { open += 1 }
|
||||
if OpenFloor(game, x, y - 1) { open += 1 }
|
||||
if OpenFloor(game, x, y + 1) { open += 1 }
|
||||
return open >= 3
|
||||
}
|
||||
// side: 1 only the entrance side, 0 only the far side, -1 anywhere.
|
||||
OpenSpots :: (game: *Game, reached: []bool, side: s32, output: []s32, loose: bool = false) -> s32 {
|
||||
count: s32 = 0
|
||||
half := board_columns / 2
|
||||
for y: 3..board_rows - 4 {
|
||||
for x: 2..board_columns - 3 {
|
||||
if Abs(cast(s32)x - half) <= 2 && (y <= 5 || y >= board_rows - 6) { continue }
|
||||
if !OpenAround(game, cast(s32)x, cast(s32)y) && !(loose && InCorridor(game, cast(s32)x, cast(s32)y)) { continue }
|
||||
at := Index(x, y)
|
||||
if side >= 0 && reached[at] != (side == 1) { continue }
|
||||
centre := Point.{cast(s32)x * 16 + 8, cast(s32)y * 16 + 8}
|
||||
crowded := false
|
||||
for index: 0..game.monster_count - 1 {
|
||||
if Near(centre, game.monsters[index].position, 32) { crowded = true }
|
||||
}
|
||||
if !crowded { output[count] = at; count += 1 }
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
PortalCentre :: (cell: s32) -> Point {
|
||||
return Point.{(cell % board_columns) * 16 + 8, (cell / board_columns) * 16 + 8}
|
||||
}
|
||||
CellsApart :: (first: s32, second: s32) -> s32 {
|
||||
return Abs(first % board_columns - second % board_columns) + Abs(first / board_columns - second / board_columns)
|
||||
}
|
||||
PlacePortals :: (game: *Game) {
|
||||
game.portal_count = 0
|
||||
game.portal_wait = 0
|
||||
pairs := PortalPairsFor(game.level)
|
||||
if !portals_enabled || pairs == 0 { return }
|
||||
candidates: [CELLS]s32
|
||||
count: s32 = 0
|
||||
half := board_columns / 2
|
||||
for y: 3..board_rows - 4 {
|
||||
for x: 2..board_columns - 3 {
|
||||
// Clear of the entrance and the exit lanes.
|
||||
if Abs(cast(s32)x - half) <= 2 && (y <= 5 || y >= board_rows - 6) { continue }
|
||||
if !OpenAround(game, cast(s32)x, cast(s32)y) { continue }
|
||||
centre := Point.{cast(s32)x * 16 + 8, cast(s32)y * 16 + 8}
|
||||
crowded := false
|
||||
for index: 0..game.monster_count - 1 {
|
||||
if Near(centre, game.monsters[index].position, 48) { crowded = true }
|
||||
}
|
||||
if !crowded { candidates[count] = Index(x, y); count += 1 }
|
||||
}
|
||||
}
|
||||
if count < 2 { return }
|
||||
// Pairs far apart in the open; a portal room joins one spot on each side.
|
||||
PlacePortals :: (game: *Game, pairs: s32, reached: []bool, room: bool) -> bool {
|
||||
near_spots: [CELLS]s32
|
||||
far_spots: [CELLS]s32
|
||||
near := OpenSpots(game, reached, ifx room then 1 else -1, near_spots[:])
|
||||
far := ifx room then OpenSpots(game, reached, 0, far_spots[:]) else 0
|
||||
if !room { far_spots = near_spots; far = near }
|
||||
if near < 1 || far < 1 { return false }
|
||||
taken: [4]s32
|
||||
taken_count: s32 = 0
|
||||
for pair: 0..pairs - 1 {
|
||||
first: s32 = -1
|
||||
for attempt: 0..count - 1 {
|
||||
cell := candidates[(cast(s64)game.level * 7919 + cast(s64)attempt * 104729 + cast(s64)pair * 31) % cast(s64)count]
|
||||
for attempt: 0..near - 1 {
|
||||
cell := near_spots[(Mix(cast(s64)game.level * 7919 + cast(s64)pair * 31) + cast(s32)attempt) % near]
|
||||
free := true
|
||||
for index: 0..taken_count - 1 { if CellsApart(cell, taken[index]) < 6 { free = false } }
|
||||
if free { first = cell; break }
|
||||
}
|
||||
if first < 0 { break }
|
||||
second: s32 = -1
|
||||
farthest: s32 = 13
|
||||
for index: 0..count - 1 {
|
||||
cell := candidates[index]
|
||||
farthest: s32 = ifx room then 0 else 13
|
||||
for index: 0..far - 1 {
|
||||
cell := far_spots[index]
|
||||
apart := CellsApart(cell, first)
|
||||
if apart <= farthest { continue }
|
||||
free := true
|
||||
@@ -282,12 +499,120 @@ PlacePortals :: (game: *Game) {
|
||||
taken_count += 2
|
||||
game.portal_count += 1
|
||||
}
|
||||
return game.portal_count > 0
|
||||
}
|
||||
// The spot on the entrance side farthest from the entrance, for a key; a
|
||||
// switch stone takes a spot partway there.
|
||||
SideSpot :: (game: *Game, reached: []bool, door: s32, farthest: bool) -> Point {
|
||||
spots: [CELLS]s32
|
||||
count := OpenSpots(game, reached, 1, spots[:], true)
|
||||
start := Index(board_columns / 2, board_rows - 2)
|
||||
best: s32 = -1
|
||||
best_apart: s32 = -1
|
||||
for index: 0..count - 1 {
|
||||
cell := spots[index]
|
||||
if CellsApart(cell, door) < 4 || CellsApart(cell, start) < 6 { continue }
|
||||
apart := CellsApart(cell, start)
|
||||
if !farthest { apart = 100 - Abs(apart - 14) }
|
||||
if apart > best_apart { best = cell; best_apart = apart }
|
||||
}
|
||||
if best < 0 { return Point.{-1, -1} }
|
||||
return PortalCentre(best)
|
||||
}
|
||||
OpenGate :: (game: *Game, open: bool) {
|
||||
if game.gate < 0 { return }
|
||||
for cell: 0..game.gate_span - 1 {
|
||||
game.board[game.gate + cast(s32)cell * game.gate_step] = ifx open then game.gate_tiles[cell] else 20
|
||||
}
|
||||
game.gate_open = open
|
||||
}
|
||||
PlaceIdeas :: (game: *Game) {
|
||||
game.portal_count = 0
|
||||
game.portal_wait = 0
|
||||
game.feature = FEATURE_NONE
|
||||
game.gate = -1
|
||||
game.gate_span = 0
|
||||
game.gate_step = 1
|
||||
game.gate_open = false
|
||||
game.key = Point.{-1, -1}
|
||||
game.switch_stone = Point.{-1, -1}
|
||||
game.on_switch = false
|
||||
if !features_enabled { return }
|
||||
feature := BoardFeature(game.level)
|
||||
reached: [CELLS]bool
|
||||
if feature == FEATURE_PORTALS {
|
||||
pairs: s32 = ifx game.level >= IDEA_PORTAL_ROOM && Mix(cast(s64)game.level * 3) % 2 == 1 then PORTAL_PAIRS else 1
|
||||
if PlacePortals(game, pairs, reached[:], false) { game.feature = feature }
|
||||
return
|
||||
}
|
||||
if feature == FEATURE_NONE {
|
||||
// A new gate idea that found no doorway on the board before moves
|
||||
// on to this one.
|
||||
newest := IdeasMet(game.level)
|
||||
if newest < FEATURE_KEY || game.level - IdeaIntros[newest - 1] >= 10 || HostsIdea(game.level - 1, newest) { return }
|
||||
if PlaceGate(game, newest, reached[:]) { game.feature = newest }
|
||||
return
|
||||
}
|
||||
// A board without a doorway for its idea takes another gate idea met
|
||||
// so far, or else portals.
|
||||
ideas: [3]s32 = .[feature, FEATURE_SWITCH, FEATURE_KEY]
|
||||
intros: [3]s32 = .[0, IDEA_SWITCH, IDEA_KEY]
|
||||
for index: 0..2 {
|
||||
idea := ideas[index]
|
||||
if (index > 0 && idea == feature) || game.level < intros[index] { continue }
|
||||
if PlaceGate(game, idea, reached[:]) { game.feature = idea; return }
|
||||
}
|
||||
if PlacePortals(game, 1, reached[:], false) { game.feature = FEATURE_PORTALS }
|
||||
}
|
||||
// Whether a level's board has a doorway for a gate idea, loaded aside.
|
||||
HostsIdea :: (level: s32, feature: s32) -> bool {
|
||||
columns := board_columns
|
||||
rows := board_rows
|
||||
enabled := features_enabled
|
||||
features_enabled = false
|
||||
aside: Game
|
||||
aside.random = 1
|
||||
LoadLevel(*aside, level, 0)
|
||||
reached: [CELLS]bool
|
||||
span: s32 = 0
|
||||
step: s32 = 1
|
||||
hosts := FindDoorway(*aside, reached[:], *span, *step, feature) >= 0
|
||||
features_enabled = enabled
|
||||
BoardSize(columns, rows)
|
||||
return hosts
|
||||
}
|
||||
PlaceGate :: (game: *Game, feature: s32, reached: []bool) -> bool {
|
||||
span: s32 = 0
|
||||
step: s32 = 1
|
||||
door := FindDoorway(game, reached, *span, *step, feature)
|
||||
if door < 0 { return false }
|
||||
game.gate = door
|
||||
game.gate_span = span
|
||||
game.gate_step = step
|
||||
for cell: 0..span - 1 { game.gate_tiles[cell] = game.board[door + cast(s32)cell * step] }
|
||||
OpenGate(game, false)
|
||||
if feature == FEATURE_KEY { game.key = SideSpot(game, reached, door, true) }
|
||||
if feature == FEATURE_SWITCH { game.switch_stone = SideSpot(game, reached, door, false) }
|
||||
placed := (feature == FEATURE_KEY && game.key.x >= 0) || (feature == FEATURE_SWITCH && game.switch_stone.x >= 0) ||
|
||||
(feature == FEATURE_PORTAL_ROOM && PlacePortals(game, 1, reached, true))
|
||||
if !placed {
|
||||
OpenGate(game, true)
|
||||
game.gate = -1
|
||||
game.gate_span = 0
|
||||
game.key = Point.{-1, -1}
|
||||
game.switch_stone = Point.{-1, -1}
|
||||
game.portal_count = 0
|
||||
return false
|
||||
}
|
||||
// A portal room's doorway stays a plain hedge for good.
|
||||
if feature == FEATURE_PORTAL_ROOM { game.gate = -1; game.gate_span = 0 }
|
||||
return true
|
||||
}
|
||||
OnPortal :: (game: *Game, position: Point) -> bool {
|
||||
for pair: 0..game.portal_count - 1 {
|
||||
if Near(position, game.portals[pair].a, 12) || Near(position, game.portals[pair].b, 12) { return true }
|
||||
}
|
||||
return false
|
||||
return Near(position, game.key, 12) || Near(position, game.switch_stone, 12)
|
||||
}
|
||||
// The complete playable campaign is designed and certified. The recovered
|
||||
// 99-level archive stays an independent, untouched historical reference.
|
||||
@@ -552,13 +877,65 @@ MoveMonster :: (game: *Game, index: s32) {
|
||||
if !MonsterBlocked(game, index, candidate) { monster.position = candidate }
|
||||
return
|
||||
}
|
||||
monster.timer += 1
|
||||
if monster.animal == ANIMAL_STONE {
|
||||
// A rolling stone keeps its patrol at twice the pace.
|
||||
PatrolStep(game, index)
|
||||
PatrolStep(game, index)
|
||||
return
|
||||
}
|
||||
if monster.kind == 1 && monster.animal == ANIMAL_SQUIRREL {
|
||||
// A squirrel dashes at twice the pace for a moment, then sits still.
|
||||
phase := monster.timer % 16
|
||||
if phase >= 8 { return }
|
||||
if phase == 0 { monster.direction = Random(game, 4) }
|
||||
for step: 0..1 {
|
||||
candidate := MonsterNext(monster.position, monster.direction)
|
||||
if MonsterBlocked(game, index, candidate) || candidate.y < 16 {
|
||||
monster.direction = Random(game, 4)
|
||||
return
|
||||
}
|
||||
monster.position = candidate
|
||||
}
|
||||
return
|
||||
}
|
||||
if monster.kind == 1 && monster.animal == ANIMAL_HEDGEHOG {
|
||||
// A hedgehog ambles at half pace and curls into a still, spiky ball
|
||||
// for a while when the worm's head comes close.
|
||||
if monster.timer < 0 { return }
|
||||
if game.length > 0 && Near(game.worm[0], monster.position, 40) { monster.timer = -HEDGEHOG_CURL; return }
|
||||
if monster.timer % 2 == 1 { return }
|
||||
RoamerStep(game, index)
|
||||
return
|
||||
}
|
||||
if monster.kind == 1 && monster.animal == ANIMAL_FROG {
|
||||
// A frog sits, then hops two tiles at once, even over a hedge.
|
||||
if monster.timer % 14 != 0 { return }
|
||||
direction := Random(game, 4)
|
||||
landing := monster.position
|
||||
for step: 0..31 { landing = MonsterNext(landing, direction) }
|
||||
if landing.y >= 16 && landing.x >= 16 && landing.x < (board_columns - 1) * 16 && landing.y < (board_rows - 1) * 16 &&
|
||||
!MonsterBlocked(game, index, landing) {
|
||||
monster.position = landing
|
||||
monster.direction = direction
|
||||
}
|
||||
return
|
||||
}
|
||||
if monster.kind == 1 { RoamerStep(game, index) }
|
||||
else { PatrolStep(game, index) }
|
||||
}
|
||||
RoamerStep :: (game: *Game, index: s32) {
|
||||
monster := *game.monsters[index]
|
||||
candidate := MonsterNext(monster.position, monster.direction)
|
||||
blocked := MonsterBlocked(game, index, candidate)
|
||||
if monster.kind == 1 {
|
||||
if !blocked { blocked = Random(game, 25) == 0 || candidate.y < 16 }
|
||||
if blocked { monster.direction = Random(game, 4) }
|
||||
else { monster.position = candidate }
|
||||
} else if blocked {
|
||||
if !blocked { blocked = Random(game, 25) == 0 || candidate.y < 16 }
|
||||
if blocked { monster.direction = Random(game, 4) }
|
||||
else { monster.position = candidate }
|
||||
}
|
||||
PatrolStep :: (game: *Game, index: s32) {
|
||||
monster := *game.monsters[index]
|
||||
candidate := MonsterNext(monster.position, monster.direction)
|
||||
if MonsterBlocked(game, index, candidate) {
|
||||
monster.direction = (monster.direction + 2) % 4
|
||||
monster.kind = monster.direction + 2
|
||||
} else { monster.position = candidate }
|
||||
@@ -577,6 +954,7 @@ LevelMultiplier :: (game: *Game) -> s32 {
|
||||
tightness := ifx walls > 300 then (walls - 300) * 10 / 150 else 0
|
||||
difficulty := 10 * game.monster_count + 10 * roamers + 5 * (game.apples - 5) + tightness +
|
||||
5 * (32 - cast(s32)TickInterval(game.level))
|
||||
if game.feature >= FEATURE_KEY { difficulty += 10 }
|
||||
if difficulty < 0 { difficulty = 0 }
|
||||
return 1 + difficulty / 20
|
||||
}
|
||||
@@ -654,6 +1032,22 @@ Tick :: (game: *Game) {
|
||||
break
|
||||
}
|
||||
}
|
||||
// The key opens its gate for good; a switch stone flips it each time the
|
||||
// head arrives on it.
|
||||
if game.key.x >= 0 && Near(next, game.key, 10) {
|
||||
for spark: 0..5 { AddParticle(game, game.key) }
|
||||
game.key = Point.{-1, -1}
|
||||
OpenGate(game, true)
|
||||
AddScore(game, 2)
|
||||
}
|
||||
if game.switch_stone.x >= 0 {
|
||||
over := Near(next, game.switch_stone, 8)
|
||||
if over && !game.on_switch {
|
||||
OpenGate(game, !game.gate_open)
|
||||
for spark: 0..3 { AddParticle(game, game.switch_stone) }
|
||||
}
|
||||
game.on_switch = over
|
||||
}
|
||||
if game.apples == 0 && next.y < 0 {
|
||||
count := game.length
|
||||
if count > 100 { count = 100 }
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
<link rel="canonical" href="https://wurm.waozi.xyz/">
|
||||
<meta property="og:title" content="Apfelwurm — 200 levels, one little worm">
|
||||
<meta property="og:description" content="Meadow, woodland, lake and mountains. A little orange worm. A long apple adventure. Play free online.">
|
||||
<meta property="og:image" content="https://wurm.waozi.xyz/assets/art/title.png">
|
||||
<meta property="og:image" content="https://wurm.waozi.xyz/social.jpg">
|
||||
<meta property="og:url" content="https://wurm.waozi.xyz/">
|
||||
<style>
|
||||
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;background:#202b26;color:#e0e7d9;font:16px system-ui,sans-serif;overscroll-behavior:none}
|
||||
body{overflow:hidden}#canvas-frame{position:fixed;inset:0}canvas{display:block;width:100%;height:100%;touch-action:none;outline:none}
|
||||
#loading{position:absolute;inset:0;display:grid;place-content:center;gap:16px;text-align:center;background:linear-gradient(#303c33e8,#202b26e8),url('assets/art/title.png') center/cover;font-size:18px}#loading strong{font-size:32px}#loading[hidden]{display:none}
|
||||
#loading{position:absolute;inset:0;display:grid;place-content:center;gap:16px;text-align:center;background:linear-gradient(#303c33e8,#202b26e8),url('loading.webp') center/cover;font-size:18px}#loading strong{font-size:32px}#loading[hidden]{display:none}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#import, file "../src/game.zi";
|
||||
// campaign-cases:begin
|
||||
// Generated from campaign_cases.json by tools/design_levels.py.
|
||||
CampaignSeeds: [400]u32 = .[1, 1, 65538, 65538, 131075, 131075, 196612, 196612, 262149, 262149, 327686, 327686, 393223, 401142, 466679, 458760, 532216, 540135, 589834, 597753, 655371, 679128, 728827, 720908, 786445, 786445, 867820, 851982, 917519, 917519, 1014732, 983056, 1064431, 1064431, 1114130, 1114130, 1195505, 1211343, 1245204, 1261042, 1318660, 1326579, 1384197, 1392116, 1441815, 1544762, 1586542, 1546947, 1596646, 1572889, 1638426, 1638426, 1703963, 1703963, 2070422, 1824933, 1898389, 1850875, 1932250, 1900574, 1966111, 1974030, 2039567, 2047486, 2303079, 2105104, 2202317, 2210236, 2252016, 2236178, 2293796, 2301715, 2367252, 2391009, 2440708, 2456546, 4525590, 3155603, 2595539, 2650972, 2637319, 2621481, 2726613, 2900831, 2752555, 2752555, 2857687, 2826011, 2891548, 2891548, 3178817, 2996680, 3014703, 3244354, 3080240, 3088159, 3201210, 3145777, 3401370, 3211314, 3292689, 3276851, 3342388, 3350307, 3439601, 3423763, 3473462, 3631842, 3538999, 3538999, 3612455, 3762916, 3773020, 3677992, 3751448, 3751448, 3848661, 5677950, 3874603, 3866684, 5975323, 4051006, 4005677, 4013596, 4118728, 4205837, 4279293, 4366402, 4194369, 4233964, 6350522, 4378691, 4420471, 4388795, 4390980, 4438494, 4464436, 4496112, 4577487, 4545811, 4619267, 4643024, 4668966, 4661047, 4766179, 4750341, 4879230, 4807959, 5895047, 4857658, 6966297, 6950459, 5004570, 5099598, 5062188, 5101783, 5135644, 5230672, 5391237, 5185343, 5290475, 5290475, 5356012, 5332255, 5389873, 5405711, 5534600, 5447491, 5600137, 5766436, 5934920, 6623873, 5652021, 5644102, 5883857, 5780910, 5870204, 6060260, 6189149, 10441652, 6056711, 6032954, 5971787, 6019301, 6061081, 6037324, 6316674, 6213727, 6231750, 6215912, 6233935, 6249773, 6331148, 8516792, 7299451, 8479382, 15513639, 59852120, 9006406, 7691852, 7084274, 6846704, 6666752, 6761780, 7128239, 7452918, 6845340, 6766150, 6831687, 6895039, 6889305, 8916569, 7129060, 6970680, 11177854, 8358690, 7648165, 7426433, 7484051, 8022543, 7470398, 8230622, 7551773, 8098184, 8203316, 7474768, 13146957, 8070878, 7494976, 7502895, 7766407, 8882986, 7784430, 7697321, 7675749, 7699506, 7772962, 7780881, 18988451, 9778654, 7872360, 7959469, 7929978, 8032925, 8066786, 8415222, 8076890, 8061052, 8142427, 8134508, 8809808, 8390101, 8265582, 8257663, 8505337, 8766664, 20655268, 10012132, 8470112, 8517626, 8575244, 8551487, 8585348, 8617024, 8650885, 8650885, 8763936, 8756017, 8797797, 8924501, 8918767, 8990038, 8913033, 9055575, 9802146, 16176941, 19924813, 9059945, 9212591, 9117563, 9183100, 9191019, 9280313, 9248637, 9322093, 9314174, 9561848, 9443063, 9524438, 9453167, 9613732, 9518704, 9576322, 9568403, 9689373, 10132837, 9739072, 9723234, 9907556, 9883799, 9830551, 9838470, 9911926, 9927764, 9977463, 9969544, 10027162, 10074676, 10092699, 10092699, 10166155, 10229507, 10295044, 10247530, 10471447, 10368500, 11685239, 10925015, 10436222, 10523331, 10485921, 10565111, 11034517, 10630648, 10616995, 10807051, 10682532, 10682532, 11056910, 10779745, 10813606, 10837363, 11417635, 11385959, 10960518, 10960518, 11224030, 11026055, 11535056, 11297486, 11204643, 11165048, 11761158, 11222666, 11367393, 11454502, 11345821, 11432930, 11870660, 11949850, 11849088, 11540247, 11582027, 11621622, 12486978, 12629520, 11673506, 11689344, 11739043, 11739043, 13261676, 11796661, 12004740, 11917631, 11951492, 11935654, 12143733, 12207085, 12122161, 12082566, 12298564, 13399305, 12237397, 12189883, 12255420, 12271258, 12352633, 12368471, 13518911, 16258885, 12483707, 12491626, 12541325, 13087736, 12614781, 12844432, 12672399, 12648642, 17323037, 76295830, 12779716, 12827230, 12900686, 12861091, 13924422, 13781880, 135023955, 87216952, 17452747, 13984225];
|
||||
CampaignRoutes: [400]s32 = .[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 1];
|
||||
CampaignSeeds: [400]u32 = .[1, 1, 65538, 65538, 131075, 131075, 196612, 196612, 262149, 262149, 327686, 327686, 393223, 401142, 466679, 458760, 532216, 540135, 589834, 597753, 655371, 679128, 728827, 720908, 786445, 786445, 867820, 851982, 917519, 917519, 1014732, 983056, 1064431, 1064431, 1114130, 1114130, 1195505, 1211343, 1245204, 1261042, 1318660, 1326579, 1384197, 1392116, 1441815, 1544762, 1586542, 1546947, 1596646, 1572889, 1638426, 1638426, 1703963, 1703963, 2070422, 1824933, 1898389, 1850875, 1932250, 1900574, 1966111, 1974030, 2039567, 2047486, 2303079, 2105104, 2202317, 2210236, 2252016, 2236178, 2293796, 2301715, 2367252, 2391009, 2440708, 2456546, 4525590, 3155603, 2595539, 2650972, 2637319, 2621481, 2726613, 2900831, 2752555, 2752555, 2857687, 2826011, 2891548, 2891548, 2949166, 2949166, 3030541, 3022622, 3080240, 3088159, 3201210, 3153696, 3211314, 3235071, 3292689, 3276851, 3342388, 3350307, 3439601, 3423763, 3473462, 3631842, 3538999, 3538999, 3604536, 3762916, 3670073, 3670073, 3751448, 3767286, 3809066, 3816985, 3874603, 3866684, 4003492, 4003492, 4005677, 3997758, 4118728, 4205837, 4279293, 4366402, 4210207, 4233964, 4299501, 4299501, 4349200, 4325443, 4390980, 4406818, 4464436, 4496112, 4577487, 4545811, 4619267, 4643024, 4668966, 4661047, 4766179, 4750341, 4879230, 4815878, 5895047, 4849739, 6966297, 6950459, 5004570, 4980813, 5062188, 5101783, 5135644, 5230672, 5256614, 5399156, 5250880, 5242961, 5356012, 5332255, 5389873, 5405711, 5534600, 5463329, 5505109, 5560542, 5633998, 5784459, 5652021, 5652021, 5717558, 5812586, 5767257, 5767257, 6315853, 6426719, 5898331, 5953764, 5979706, 6019301, 6061081, 6037324, 6094942, 6094942, 6168398, 6160479, 6233935, 6241854, 6845883, 7827839, 7299451, 6626336, 6478060, 7103661, 6543597, 6488164, 7084274, 6846704, 6619238, 6761780, 7128239, 7452918, 6845340, 6766150, 6831687, 6926715, 6889305, 6936819, 7129060, 6970680, 8627936, 8279500, 7173025, 7196782, 7689945, 7872082, 7612940, 7351613, 7298365, 7892290, 7411416, 7474768, 8633127, 10715824, 7487057, 7502895, 7560513, 8106924, 7736916, 7602293, 7675749, 7683668, 7772962, 8160993, 11085289, 12455276, 7911955, 8054497, 8025006, 8436794, 8027191, 8145976, 8076890, 8068971, 8134508, 8158265, 8643509, 8564319, 8281420, 8257663, 8394471, 8552851, 12783782, 9980456, 8454274, 8881900, 8527730, 8535649, 8617024, 8617024, 8658804, 8872617, 8866883, 8771855, 8797797, 8813635, 8918767, 9203851, 8944709, 9055575, 13294425, 14632736, 11491078, 9107459, 9220510, 9172996, 9191019, 9175181, 9280313, 9565397, 9306255, 9314174, 9514334, 9743985, 9476924, 9508600, 9613732, 9708760, 9576322, 9584241, 9816077, 9903186, 9865776, 9762829, 9947151, 10343101, 9830551, 9838470, 9911926, 9911926, 10009139, 9977463, 10027162, 10130109, 10092699, 10092699, 10205750, 10308697, 10683075, 10302963, 10344743, 10289310, 10536984, 10639931, 10444141, 10555007, 10485921, 10604706, 10717757, 10630648, 11092135, 10862484, 10706289, 10690451, 10819340, 10803502, 10861120, 10971986, 11417635, 11758152, 11047627, 11023870, 11176516, 11422005, 11083673, 11202458, 11212562, 11141291, 11222666, 11262261, 11351555, 11723748, 11417092, 11377497, 11466791, 11680604, 11532328, 11500652, 11550351, 11558270, 12447383, 11972243, 11681425, 11665587, 11739043, 11826152, 12303477, 11820418, 12424447, 12273986, 11927735, 11927735, 12001191, 12207085, 12454759, 12066728, 12251050, 13486414, 12221559, 12197802, 12287096, 12271258, 12423904, 12360552, 12608226, 19949139, 12483707, 12491626, 12580920, 12881842, 12662295, 13002812, 12775346, 12648642, 15002770, 17291361, 12795554, 12803473, 12861091, 12845253, 12926628, 13243388, 131452486, 33446942, 13659546, 15124561];
|
||||
CampaignRoutes: [400]s32 = .[0, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0];
|
||||
// campaign-cases:end
|
||||
libc :: #system_library "libc";
|
||||
ParseNumber :: (text: *u8) -> s32 #foreign libc "atoi";
|
||||
@@ -235,8 +235,9 @@ Replay :: (level: s32, portrait: bool, seed: u32, route: []Point) -> bool {
|
||||
replay_deaths: s32;
|
||||
#program_export
|
||||
main :: (argc: s32, argv: **u8) -> s32 {
|
||||
// The certificate proves every board can be won without a portal.
|
||||
portals_enabled = false
|
||||
// The certificate proves every board can be won without its puzzle idea
|
||||
// (portals, gates and switches); the animals stay active.
|
||||
features_enabled = false
|
||||
search := argc > 1
|
||||
first: s32 = ifx argc > 2 then ParseNumber(argv[2]) - 1 else 0
|
||||
last: s32 = ifx argc > 3 then ParseNumber(argv[3]) - 1 else LEVEL_COUNT - 1
|
||||
|
||||
@@ -123,29 +123,83 @@ main :: () -> s32 {
|
||||
Tick(*game)
|
||||
Expect(game.lives == 3 && game.worm[0].y == 496, "death consumes a life and respawns")
|
||||
|
||||
// Portals arrive slowly from level 61, then rings in open floor carry
|
||||
// the head across.
|
||||
for level: 0..PORTAL_FIRST - 1 {
|
||||
StartGame(*game, cast(s32)level, 0)
|
||||
Expect(game.portal_count == 0, "no portals before level 61")
|
||||
}
|
||||
Expect(PortalPairsFor(60) == 1 && PortalPairsFor(61) == 0 && PortalPairsFor(81) == 0 && PortalPairsFor(82) == 1 &&
|
||||
PortalPairsFor(170) == 1 && PortalPairsFor(199) == 2, "portals spread out over the journey")
|
||||
portal_boards: s32 = 0
|
||||
// New ideas open one at a time and come back in a mix.
|
||||
for level: 0..IDEA_PORTALS - 1 { Expect(BoardFeature(cast(s32)level) == FEATURE_NONE, "no puzzle idea before level 61") }
|
||||
Expect(BoardFeature(IDEA_PORTALS) == FEATURE_PORTALS && BoardFeature(IDEA_PORTALS + 1) == FEATURE_NONE &&
|
||||
BoardFeature(IDEA_KEY) == FEATURE_KEY && BoardFeature(IDEA_SWITCH) == FEATURE_SWITCH &&
|
||||
BoardFeature(IDEA_PORTAL_ROOM) == FEATURE_PORTAL_ROOM, "each puzzle idea opens on its own board")
|
||||
for level: 0..IDEA_SQUIRREL - 1 { Expect(RoamerAnimal(cast(s32)level, 0) == ANIMAL_CLASSIC, "no new animals in the meadow") }
|
||||
Expect(RoamerAnimal(IDEA_SQUIRREL, 0) == ANIMAL_SQUIRREL && RoamerAnimal(IDEA_HEDGEHOG, 0) == ANIMAL_HEDGEHOG &&
|
||||
RoamerAnimal(IDEA_FROG, 0) == ANIMAL_FROG && PatrolAnimal(IDEA_STONE, 0) == ANIMAL_STONE &&
|
||||
PatrolAnimal(IDEA_STONE - 1, 0) == ANIMAL_CLASSIC, "each animal opens in its own landscape")
|
||||
placed: [5]s32
|
||||
later_animals: [5]s32
|
||||
key_level: s32 = -1
|
||||
switch_level: s32 = -1
|
||||
room_level: s32 = -1
|
||||
portal_level: s32 = -1
|
||||
for level: 40..LEVEL_COUNT - 1 {
|
||||
reached: [CELLS]bool
|
||||
for level: 0..LEVEL_COUNT - 1 {
|
||||
StartGame(*game, cast(s32)level, 0)
|
||||
if game.portal_count > 0 { portal_boards += 1 }
|
||||
if game.portal_count > 0 && portal_level < 0 { portal_level = cast(s32)level }
|
||||
placed[game.feature] += 1
|
||||
for index: 0..game.monster_count - 1 {
|
||||
if level >= IDEA_PORTAL_ROOM { later_animals[game.monsters[index].animal] += 1 }
|
||||
}
|
||||
start := Index(board_columns / 2, board_rows - 2)
|
||||
unused FloodFrom(*game, start, -1, reached[:])
|
||||
if game.feature == FEATURE_PORTALS && portal_level < 0 { portal_level = cast(s32)level }
|
||||
for pair: 0..game.portal_count - 1 {
|
||||
a := game.portals[pair].a
|
||||
b := game.portals[pair].b
|
||||
Expect(OpenAround(*game, a.x / 16, a.y / 16) && OpenAround(*game, b.x / 16, b.y / 16) &&
|
||||
CellsApart(Index(a.x / 16, a.y / 16), Index(b.x / 16, b.y / 16)) >= 14, "portals stand in open floor, far apart")
|
||||
Expect(OpenAround(*game, a.x / 16, a.y / 16) && OpenAround(*game, b.x / 16, b.y / 16), "portals stand in open floor")
|
||||
Expect(!Near(game.apple, a, 12) && !Near(game.apple, b, 12), "apples never land on a portal")
|
||||
}
|
||||
if game.feature == FEATURE_KEY || game.feature == FEATURE_SWITCH {
|
||||
Expect(game.gate >= 0 && !game.gate_open && game.board[game.gate] == 20, "a gate starts closed")
|
||||
spot := ifx game.feature == FEATURE_KEY then game.key else game.switch_stone
|
||||
Expect(reached[Index(spot.x / 16, spot.y / 16)], "its key or switch lies on the entrance side")
|
||||
if game.feature == FEATURE_KEY && key_level < 0 { key_level = cast(s32)level }
|
||||
if game.feature == FEATURE_SWITCH && switch_level < 0 { switch_level = cast(s32)level }
|
||||
}
|
||||
if game.feature == FEATURE_PORTAL_ROOM {
|
||||
a := game.portals[0].a
|
||||
b := game.portals[0].b
|
||||
Expect(reached[Index(a.x / 16, a.y / 16)] && !reached[Index(b.x / 16, b.y / 16)], "a portal room is reached only through its portal")
|
||||
if room_level < 0 { room_level = cast(s32)level }
|
||||
}
|
||||
}
|
||||
Expect(portal_boards >= 70 && portal_level >= PORTAL_FIRST, "portals grow common after level 61")
|
||||
print("Ideas placed: portals % keys % switches % rooms %; animals after 180: flames % squirrels % hedgehogs % frogs % stones %\n",
|
||||
placed[1], placed[2], placed[3], placed[4], later_animals[0], later_animals[1], later_animals[2], later_animals[3], later_animals[4])
|
||||
Expect(placed[FEATURE_PORTALS] >= 20 && placed[FEATURE_KEY] >= 8 && placed[FEATURE_SWITCH] >= 6 && placed[FEATURE_PORTAL_ROOM] >= 3,
|
||||
"every puzzle idea comes back in later levels")
|
||||
Expect(later_animals[1] > 0 && later_animals[2] > 0 && later_animals[3] > 0 && later_animals[4] > 0, "the last boards mix every animal")
|
||||
Expect(key_level >= 0 && switch_level >= 0 && room_level >= 0 && portal_level >= 0, "every puzzle idea is placed somewhere")
|
||||
if key_level < 0 || switch_level < 0 || portal_level < 0 { print("Gameplay failures: %\n", failures); return failures }
|
||||
// The key opens its gate for good.
|
||||
StartGame(*game, key_level, 0)
|
||||
game.apples = 3
|
||||
game.worm[0] = Point.{game.key.x, game.key.y + 4}
|
||||
game.direction = DIR_UP
|
||||
game.next_direction = DIR_UP
|
||||
Tick(*game)
|
||||
Expect(game.key.x < 0 && game.gate_open && game.board[game.gate] == game.gate_tiles[0], "the key opens its gate")
|
||||
// A switch stone flips its gate each time the head arrives on it.
|
||||
StartGame(*game, switch_level, 0)
|
||||
game.apples = 3
|
||||
stone := game.switch_stone
|
||||
game.worm[0] = Point.{stone.x, stone.y + 8}
|
||||
game.direction = DIR_UP
|
||||
game.next_direction = DIR_UP
|
||||
Tick(*game)
|
||||
Expect(game.gate_open, "a switch stone opens its gate")
|
||||
Tick(*game)
|
||||
Tick(*game)
|
||||
Tick(*game)
|
||||
Expect(game.gate_open && game.on_switch == false, "it stays open as the head moves on")
|
||||
game.worm[0] = Point.{stone.x, stone.y + 8}
|
||||
Tick(*game)
|
||||
Expect(!game.gate_open && game.board[game.gate] == 20, "arriving again closes it")
|
||||
// A head stepping into a ring comes out of its partner.
|
||||
StartGame(*game, portal_level, 0)
|
||||
portal := game.portals[0]
|
||||
game.apples = 3
|
||||
@@ -156,6 +210,41 @@ main :: () -> s32 {
|
||||
Expect(game.worm[0].x == portal.b.x && game.worm[0].y == portal.b.y, "the worm comes out of the partner ring")
|
||||
Tick(*game)
|
||||
Expect(game.worm[0].x == portal.b.x && game.worm[0].y == portal.b.y - 4 && game.death_ticks == 0, "it keeps its course out of the ring")
|
||||
// A squirrel sits between dashes; a frog hops two tiles or not at all.
|
||||
StartGame(*game, IDEA_SQUIRREL, 0)
|
||||
for index: 0..game.monster_count - 1 {
|
||||
if game.monsters[index].animal != ANIMAL_SQUIRREL { continue }
|
||||
game.monsters[index].timer = 8
|
||||
before := game.monsters[index].position
|
||||
MoveMonster(*game, cast(s32)index)
|
||||
Expect(game.monsters[index].position.x == before.x && game.monsters[index].position.y == before.y, "a squirrel sits between dashes")
|
||||
}
|
||||
// A hedgehog curls into a still ball as the worm's head comes close.
|
||||
StartGame(*game, IDEA_HEDGEHOG, 0)
|
||||
curled := false
|
||||
for index: 0..game.monster_count - 1 {
|
||||
if game.monsters[index].animal != ANIMAL_HEDGEHOG { continue }
|
||||
curled = true
|
||||
before := game.monsters[index].position
|
||||
game.worm[0] = Point.{before.x + 24, before.y}
|
||||
for tick: 0..HEDGEHOG_CURL - 2 { MoveMonster(*game, cast(s32)index) }
|
||||
Expect(game.monsters[index].timer < 0 && game.monsters[index].position.x == before.x &&
|
||||
game.monsters[index].position.y == before.y, "a hedgehog curls up and keeps still")
|
||||
game.worm[0] = Point.{-100, -100}
|
||||
for tick: 0..3 { MoveMonster(*game, cast(s32)index) }
|
||||
Expect(game.monsters[index].timer >= 0, "it uncurls once the worm has gone")
|
||||
break
|
||||
}
|
||||
Expect(curled, "the first hedgehog board has a hedgehog")
|
||||
StartGame(*game, IDEA_FROG, 0)
|
||||
for index: 0..game.monster_count - 1 {
|
||||
if game.monsters[index].animal != ANIMAL_FROG { continue }
|
||||
game.monsters[index].timer = 13
|
||||
before := game.monsters[index].position
|
||||
MoveMonster(*game, cast(s32)index)
|
||||
moved := Abs(game.monsters[index].position.x - before.x) + Abs(game.monsters[index].position.y - before.y)
|
||||
Expect(moved == 0 || moved == 32, "a frog hops two tiles")
|
||||
}
|
||||
game.lives = 1
|
||||
game.death_ticks = 1
|
||||
Tick(*game)
|
||||
@@ -176,7 +265,7 @@ main :: () -> s32 {
|
||||
|
||||
StartGame(*game, 0, 0)
|
||||
game.monster_count = 1
|
||||
game.monsters[0] = Monster.{Point.{168, 168}, 3, 1}
|
||||
game.monsters[0] = Monster.{Point.{168, 168}, 3, 1, 0, 0}
|
||||
game.board[Index(10, 10)] = 0
|
||||
MoveMonster(*game, 0)
|
||||
Expect(game.monsters[0].position.x == 169, "monster moves one pixel")
|
||||
|
||||
@@ -107,12 +107,10 @@ def main():
|
||||
assert ((title_pixels.max(axis=2) > 40).mean()) > 0.95, "title artwork is missing or black"
|
||||
# Launch from build/, as the actual desktop launcher does, then use
|
||||
# the single Play button. Q from a paused level returns to the title.
|
||||
# A desktop has a keyboard, so Play starts swipe steering without
|
||||
# asking, straight into level 1: no controls, stage or level menu.
|
||||
pointer(480, 530)
|
||||
time.sleep(0.15)
|
||||
capture("controls-choice")
|
||||
pointer(340, 428)
|
||||
assert (level_directory / "controls.dat").read_bytes() == bytes([0]), "swipe choice was not persisted"
|
||||
# The choice goes straight into level 1: no stage or level menu.
|
||||
assert not (level_directory / "controls.dat").exists(), "the desktop asked for controls"
|
||||
time.sleep(0.2)
|
||||
key("space")
|
||||
time.sleep(0.15)
|
||||
|
||||
@@ -25,7 +25,7 @@ main :: () -> s32 {
|
||||
unused File.CreateDirectory("build/progress-test-data")
|
||||
unused File.RemoveFile("build/progress-test-data/controls.dat")
|
||||
Clear()
|
||||
Expect(!Controls.Chosen(), "first play asks for controls")
|
||||
Expect(Controls.Chosen() && !Controls.Pad(), "a desktop starts with swipe steering without asking")
|
||||
Expect(Controls.SetPad(true) && Controls.Pad(), "choose direction pad")
|
||||
Controls.mode = -2
|
||||
Expect(Controls.Chosen() && Controls.Pad(), "pad survives restart")
|
||||
|
||||
@@ -43,13 +43,15 @@ def main():
|
||||
subprocess.run([str(compiler / 'build/bin/zi2c'), '--define', 'PLATFORM_WEB', '--root', str(ir),
|
||||
'-o', str(code), *map(str, ir.glob('*.zir'))], cwd=ROOT, env=env, check=True)
|
||||
art = OUT / 'assets/art'
|
||||
# Legacy cover studies are not used by the game. Keep the browser preload
|
||||
# Legacy cover studies and the old level previews (the game shows
|
||||
# campaign-previews) are not used by the game. Keep the browser preload
|
||||
# below Pages' per-file limit without changing the published artwork.
|
||||
unused_art = ('*.argb', 'garden-cover.png', 'space-cover.png', 'factory-cover.png', 'stage-covers.png')
|
||||
shutil.copytree(ROOT / 'assets/art', art, dirs_exist_ok=True,
|
||||
ignore=shutil.ignore_patterns(*unused_art))
|
||||
ignore=shutil.ignore_patterns(*unused_art, 'previews'))
|
||||
for name in unused_art[1:]:
|
||||
(art / name).unlink(missing_ok=True)
|
||||
shutil.rmtree(art / 'previews', ignore_errors=True)
|
||||
emcc = (env.get('EMCC') or shutil.which('emcc', path=env.get('PATH'))
|
||||
or str(Path.home() / 'emsdk/upstream/emscripten/emcc'))
|
||||
subprocess.run([emcc, '-O2', '-Wno-parentheses-equality', '-I' + str(compiler / 'include'),
|
||||
@@ -76,6 +78,12 @@ def main():
|
||||
for source in (ROOT / 'src/web').iterdir():
|
||||
if source.is_file():
|
||||
shutil.copy2(source, OUT / source.name)
|
||||
# The page shows the title art while the game loads and in link previews.
|
||||
# Small copies keep that first paint fast; the game keeps the original.
|
||||
from PIL import Image
|
||||
title = Image.open(ROOT / 'assets/art/title.png').convert('RGB')
|
||||
title.resize((1280, 853), Image.Resampling.LANCZOS).save(OUT / 'loading.webp', 'WEBP', quality=86, method=6)
|
||||
title.resize((1200, 800), Image.Resampling.LANCZOS).save(OUT / 'social.jpg', 'JPEG', quality=88, optimize=True, progressive=True)
|
||||
version = json.loads((ROOT / 'version.json').read_text())['version']
|
||||
revision = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip()
|
||||
(OUT / 'version.json').write_text(json.dumps({'version': version, 'revision': revision,
|
||||
|
||||
@@ -139,11 +139,18 @@ def main():
|
||||
# keep the previous campaign and its cached art while development runs.
|
||||
fire = cells(SOURCE / 'fire.png', 2, 2)
|
||||
assert Image.open(SOURCE / 'fire.png').getchannel('A').getextrema()[0] == 0
|
||||
# Row four: squirrel, hedgehog, frog and rolling stone frames, then the
|
||||
# key, the switch stone off and on, and the gate across and down.
|
||||
creatures = cells(SOURCE / 'journey-creatures.png', 4, 3)
|
||||
assert Image.open(SOURCE / 'journey-creatures.png').getchannel('A').getextrema()[0] == 0
|
||||
creatures.append(creatures[11].rotate(90))
|
||||
for row, (stage, _, _) in enumerate(STAGES):
|
||||
sheet = journey_sheet(base, journey[row * 4:row * 4 + 4])
|
||||
sheet.paste(fire[0], (0, 2 * CELL))
|
||||
for frame, image in enumerate(fire):
|
||||
sheet.paste(image, ((6 + frame) * CELL, 2 * CELL))
|
||||
for column, image in enumerate(creatures):
|
||||
sheet.paste(image, (column * CELL, 4 * CELL))
|
||||
save(sheet, ART / ('campaign-' + stage + '.png'), args.check)
|
||||
covers = Image.open(SOURCE / 'stage-covers.png').convert('RGBA').resize((960, 1600), Image.Resampling.LANCZOS)
|
||||
save(covers, ART / 'stage-covers.png', args.check)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"version": "0.2.6",
|
||||
"version_code": 16
|
||||
"version": "0.2.8",
|
||||
"version_code": 18
|
||||
}
|
||||
@@ -98,7 +98,7 @@
|
||||
"name": "Apfelwurm"
|
||||
},
|
||||
"toolchain": {
|
||||
"commit": "79ad8431baaa8d3c948ade12909fe721c551e217",
|
||||
"commit": "7c883e8458f9a728ff390d40e9c8b094a2683bab",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/ziranlang/ziran.git"
|
||||
}
|
||||
|
||||