diff --git a/maps/RPGmap.json b/maps/RPGmap.json index acc40db..153c88d 100644 --- a/maps/RPGmap.json +++ b/maps/RPGmap.json @@ -3,26 +3,26 @@ "infinite":false, "layers":[ { - "data":[1, 2, 137, 138, 1, 2, 137, 138, 1, 2, 71, 72, 73, 74, 75, 76, 1, 2, 137, 138, - 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, 105, 106, 107, 108, 109, 110, 35, 36, 171, 172, - 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 139, 140, 207, 208, 143, 144, 69, 70, 205, 206, + "data":[1, 2, 39, 40, 1, 2, 137, 138, 1, 2, 71, 72, 73, 74, 75, 76, 1, 2, 137, 138, + 35, 36, 73, 74, 35, 36, 171, 172, 35, 36, 105, 106, 107, 108, 109, 110, 35, 39, 40, 172, + 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 139, 140, 207, 208, 143, 144, 69, 73, 74, 206, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 173, 174, 241, 242, 177, 178, 103, 104, 239, 240, - 137, 138, 137, 138, 1, 2, 137, 138, 341, 342, 345, 346, 411, 412, 137, 138, 1, 2, 33, 34, - 171, 172, 171, 172, 35, 36, 171, 172, 375, 376, 379, 380, 445, 446, 171, 172, 35, 36, 67, 68, - 205, 206, 205, 206, 69, 70, 205, 206, 413, 414, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, - 239, 240, 239, 240, 103, 104, 239, 240, 447, 448, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, - 1, 2, 137, 138, 1, 2, 137, 138, 413, 414, 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, - 35, 36, 171, 172, 35, 36, 171, 172, 447, 448, 171, 172, 35, 36, 171, 172, 331, 332, 171, 172, - 69, 70, 205, 206, 69, 70, 205, 206, 413, 414, 235, 236, 233, 234, 205, 364, 365, 366, 367, 206, - 103, 104, 239, 240, 103, 104, 239, 240, 447, 448, 269, 270, 267, 268, 397, 398, 399, 400, 401, 402, - 1, 2, 237, 238, 1, 2, 137, 138, 413, 414, 233, 234, 235, 236, 431, 432, 433, 434, 435, 436, + 137, 138, 137, 138, 307, 274, 137, 138, 341, 342, 345, 346, 411, 412, 137, 138, 1, 2, 33, 34, + 171, 172, 171, 172, 307, 307, 171, 172, 375, 376, 379, 380, 445, 446, 171, 172, 35, 36, 67, 68, + 205, 206, 205, 206, 69, 70, 205, 206, 413, 414, 39, 40, 69, 70, 205, 206, 69, 70, 205, 206, + 239, 240, 239, 240, 103, 104, 39, 40, 447, 448, 73, 74, 307, 104, 239, 274, 103, 104, 239, 240, + 1, 2, 137, 307, 1, 2, 73, 74, 413, 414, 137, 39, 40, 2, 137, 138, 1, 2, 137, 138, + 35, 36, 171, 172, 35, 36, 171, 172, 447, 448, 171, 73, 74, 36, 171, 172, 331, 332, 171, 172, + 69, 70, 205, 206, 69, 70, 274, 206, 413, 414, 235, 236, 233, 234, 205, 364, 365, 366, 367, 206, + 103, 104, 239, 240, 39, 40, 239, 240, 447, 448, 269, 270, 267, 268, 397, 398, 399, 400, 401, 402, + 1, 2, 237, 238, 73, 74, 137, 138, 413, 414, 233, 234, 235, 236, 431, 432, 433, 434, 435, 436, 35, 36, 271, 272, 35, 353, 354, 172, 447, 448, 267, 268, 269, 270, 465, 466, 467, 468, 469, 470, 69, 70, 351, 352, 69, 387, 388, 206, 347, 348, 349, 350, 343, 344, 499, 500, 439, 440, 503, 504, - 103, 104, 385, 386, 103, 104, 239, 240, 381, 382, 383, 384, 377, 378, 403, 404, 473, 474, 405, 406, - 1, 2, 409, 410, 345, 346, 345, 346, 417, 418, 417, 418, 417, 418, 345, 346, 417, 418, 345, 346, + 103, 104, 385, 386, 103, 104, 239, 240, 381, 121, 121, 121, 121, 378, 403, 404, 473, 474, 405, 406, + 1, 2, 409, 410, 345, 346, 345, 346, 417, 121, 121, 121, 121, 418, 345, 346, 417, 418, 345, 346, 35, 36, 443, 444, 379, 380, 379, 380, 451, 452, 451, 452, 451, 452, 379, 380, 451, 452, 379, 380, - 69, 57, 58, 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, - 90, 91, 92, 93, 103, 104, 57, 58, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240], + 69, 57, 58, 206, 69, 70, 205, 206, 69, 307, 205, 206, 69, 70, 205, 206, 39, 40, 205, 206, + 90, 91, 92, 93, 103, 104, 57, 58, 103, 104, 239, 240, 103, 104, 239, 240, 73, 74, 239, 240], "height":20, "id":1, "name":"map", @@ -234,7 +234,7 @@ { "name":"dialogue", "type":"string", - "value":"Test message!" + "value":"18 chars per line\\nallowed. Or else!" }, { "name":"direction", @@ -304,7 +304,7 @@ "objects":[ { "class":"", - "height":13.8767, + "height":10, "id":35, "name":"dungeon 1", "properties":[ diff --git a/maps/RPGmap.tmx b/maps/RPGmap.tmx index 41db434..3522df2 100644 --- a/maps/RPGmap.tmx +++ b/maps/RPGmap.tmx @@ -6,26 +6,26 @@ -1,2,137,138,1,2,137,138,1,2,71,72,73,74,75,76,1,2,137,138, -35,36,171,172,35,36,171,172,35,36,105,106,107,108,109,110,35,36,171,172, -69,70,205,206,69,70,205,206,69,70,139,140,207,208,143,144,69,70,205,206, +1,2,39,40,1,2,137,138,1,2,71,72,73,74,75,76,1,2,137,138, +35,36,73,74,35,36,171,172,35,36,105,106,107,108,109,110,35,39,40,172, +69,70,205,206,69,70,205,206,69,70,139,140,207,208,143,144,69,73,74,206, 103,104,239,240,103,104,239,240,103,104,173,174,241,242,177,178,103,104,239,240, -137,138,137,138,1,2,137,138,341,342,345,346,411,412,137,138,1,2,33,34, -171,172,171,172,35,36,171,172,375,376,379,380,445,446,171,172,35,36,67,68, -205,206,205,206,69,70,205,206,413,414,205,206,69,70,205,206,69,70,205,206, -239,240,239,240,103,104,239,240,447,448,239,240,103,104,239,240,103,104,239,240, -1,2,137,138,1,2,137,138,413,414,137,138,1,2,137,138,1,2,137,138, -35,36,171,172,35,36,171,172,447,448,171,172,35,36,171,172,331,332,171,172, -69,70,205,206,69,70,205,206,413,414,235,236,233,234,205,364,365,366,367,206, -103,104,239,240,103,104,239,240,447,448,269,270,267,268,397,398,399,400,401,402, -1,2,237,238,1,2,137,138,413,414,233,234,235,236,431,432,433,434,435,436, +137,138,137,138,307,274,137,138,341,342,345,346,411,412,137,138,1,2,33,34, +171,172,171,172,307,307,171,172,375,376,379,380,445,446,171,172,35,36,67,68, +205,206,205,206,69,70,205,206,413,414,39,40,69,70,205,206,69,70,205,206, +239,240,239,240,103,104,39,40,447,448,73,74,307,104,239,274,103,104,239,240, +1,2,137,307,1,2,73,74,413,414,137,39,40,2,137,138,1,2,137,138, +35,36,171,172,35,36,171,172,447,448,171,73,74,36,171,172,331,332,171,172, +69,70,205,206,69,70,274,206,413,414,235,236,233,234,205,364,365,366,367,206, +103,104,239,240,39,40,239,240,447,448,269,270,267,268,397,398,399,400,401,402, +1,2,237,238,73,74,137,138,413,414,233,234,235,236,431,432,433,434,435,436, 35,36,271,272,35,353,354,172,447,448,267,268,269,270,465,466,467,468,469,470, 69,70,351,352,69,387,388,206,347,348,349,350,343,344,499,500,439,440,503,504, -103,104,385,386,103,104,239,240,381,382,383,384,377,378,403,404,473,474,405,406, -1,2,409,410,345,346,345,346,417,418,417,418,417,418,345,346,417,418,345,346, +103,104,385,386,103,104,239,240,381,121,121,121,121,378,403,404,473,474,405,406, +1,2,409,410,345,346,345,346,417,121,121,121,121,418,345,346,417,418,345,346, 35,36,443,444,379,380,379,380,451,452,451,452,451,452,379,380,451,452,379,380, -69,57,58,206,69,70,205,206,69,70,205,206,69,70,205,206,69,70,205,206, -90,91,92,93,103,104,57,58,103,104,239,240,103,104,239,240,103,104,239,240 +69,57,58,206,69,70,205,206,69,307,205,206,69,70,205,206,39,40,205,206, +90,91,92,93,103,104,57,58,103,104,239,240,103,104,239,240,73,74,239,240 @@ -49,7 +49,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/src/main.zig b/src/main.zig index 8b2ca22..9bdcd0d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -30,8 +30,10 @@ var done: bool = false; var camera: [400]u9 = []u9{} ** 400; +var state: sh0rk.State = .Title; + export fn start() void { - //palette.mist(); + palette.tamtam(); } fn bonk() void { @@ -134,13 +136,88 @@ fn move_mara(gamepad: w4.GamePad) void { } } -fn title() void { +fn title() !void { w4.m.colors._0 = .p3; w4.m.colors._1 = .p0; - w4.text("Mara 2:\nTamamo's Fury", 10, 10); + w4.text("Mara 2:\nTamamo's Fury", 28, 8); + w4.text("Press z or x", 32, 136); + w4.text("From Within 2022", 16, 152); + + w4.m.colors._0 = .p0; + w4.m.colors._1 = .p1; + w4.m.colors._2 = .p2; + w4.m.colors._3 = .p3; + + w4.blit(&sprites.tamamotitle, 48, 60, sprites.tamamotitle_width, sprites.tamamotitle_height, w4.BlitFlags{.two_bits = true}); + + const gamepad = w4.m.gamepads[0]; + if (gamepad.a or gamepad.b) { + state = .StoryDump; + } +} + +const story = "After defeating\nthe evil mage,\nMalto was at\npeace.\n\nOne day Mara was\nwalking along the\nbeach when she saw\nthe killing stone\nwas split in two.\nTamamo-no-Mae was\nfree to wreak havoc\nacross the land.\n\nHelp us again Mara!\nSave Kanar from\nTamamo-no-Mae!\n\nPress x."; +var story_idx: usize = 0; +var story_counter: u8 = 4; + +fn storydump() !void { + w4.m.colors._0 = .p3; + w4.m.colors._1 = .p0; + + w4.text(story[0..story_idx], 4, 4); + + const gamepad = w4.m.gamepads[0]; + if (gamepad.b) { + state = .Gameplay; + palette.mist(); + } + + if (story_idx < story.len) { + story_counter -= 1; + + if (gamepad.a) { + story_counter = 0; + } + + if (story_counter == 0) { + story_idx += 1; + story_counter = 4; + + w4.tone( + w4.Tone.Frequency{.start = 280, .end = 310}, + w4.Tone.Duration{ + .attack = 0, + .decay = 0, + .sustain = 2, + .release = 0, + }, + w4.Tone.Volume{ + .sustain = 100, + .attack = 100, + }, + w4.Tone.Flags{ + .channel = .triangle, + .pulse_duty = .@"1/4", + }, + ); + } + } else { + if (gamepad.a) { + state = .Gameplay; + palette.mist(); + } + } } export fn update() void { + switch (state) { + .Title => title() catch unreachable, + .StoryDump => storydump() catch unreachable, + .Gameplay => gameplay() catch unreachable, + } +} + +fn gameplay() !void { defer done = true; if (sound_timer != 0) { sound_timer -= 1; @@ -203,13 +280,6 @@ export fn update() void { .two_bits = true, }; - // w4.m.colors._0 = .p0; - // w4.m.colors._1 = .p1; - // w4.m.colors._2 = .p2; - // w4.m.colors._3 = .p3; - - // w4.blit(&sprites.tamamotitle, 60, 60, sprites.tamamotitle_width, sprites.tamamotitle_height, flags); - // w4.m.colors._0 = .p0; // w4.m.colors._1 = .p1; // w4.m.colors._2 = .p3; diff --git a/src/maps/overworld.zig b/src/maps/overworld.zig index 294416e..5f330f1 100644 --- a/src/maps/overworld.zig +++ b/src/maps/overworld.zig @@ -15,46 +15,46 @@ pub const ts_width = 34; pub const ts_height = 16; pub const data = [400]u9{ - 0, 1, 136, 137, 0, 1, 136, 137, 0, 1, 70, + 0, 1, 38, 39, 0, 1, 136, 137, 0, 1, 70, 71, 72, 73, 74, 75, 0, 1, 136, 137, 34, - 35, 170, 171, 34, 35, 170, 171, 34, 35, 104, - 105, 106, 107, 108, 109, 34, 35, 170, 171, 68, + 35, 72, 73, 34, 35, 170, 171, 34, 35, 104, + 105, 106, 107, 108, 109, 34, 38, 39, 171, 68, 69, 204, 205, 68, 69, 204, 205, 68, 69, 138, - 139, 206, 207, 142, 143, 68, 69, 204, 205, 102, + 139, 206, 207, 142, 143, 68, 72, 73, 205, 102, 103, 238, 239, 102, 103, 238, 239, 102, 103, 172, 173, 240, 241, 176, 177, 102, 103, 238, 239, 136, - 137, 136, 137, 0, 1, 136, 137, 340, 341, 344, + 137, 136, 137, 306, 273, 136, 137, 340, 341, 344, 345, 410, 411, 136, 137, 0, 1, 32, 33, 170, - 171, 170, 171, 34, 35, 170, 171, 374, 375, 378, + 171, 170, 171, 306, 306, 170, 171, 374, 375, 378, 379, 444, 445, 170, 171, 34, 35, 66, 67, 204, - 205, 204, 205, 68, 69, 204, 205, 412, 413, 204, - 205, 68, 69, 204, 205, 68, 69, 204, 205, 238, - 239, 238, 239, 102, 103, 238, 239, 446, 447, 238, - 239, 102, 103, 238, 239, 102, 103, 238, 239, 0, - 1, 136, 137, 0, 1, 136, 137, 412, 413, 136, - 137, 0, 1, 136, 137, 0, 1, 136, 137, 34, + 205, 204, 205, 68, 69, 204, 205, 412, 413, 38, + 39, 68, 69, 204, 205, 68, 69, 204, 205, 238, + 239, 238, 239, 102, 103, 38, 39, 446, 447, 72, + 73, 306, 103, 238, 273, 102, 103, 238, 239, 0, + 1, 136, 306, 0, 1, 72, 73, 412, 413, 136, + 38, 39, 1, 136, 137, 0, 1, 136, 137, 34, 35, 170, 171, 34, 35, 170, 171, 446, 447, 170, - 171, 34, 35, 170, 171, 330, 331, 170, 171, 68, - 69, 204, 205, 68, 69, 204, 205, 412, 413, 234, + 72, 73, 35, 170, 171, 330, 331, 170, 171, 68, + 69, 204, 205, 68, 69, 273, 205, 412, 413, 234, 235, 232, 233, 204, 363, 364, 365, 366, 205, 102, - 103, 238, 239, 102, 103, 238, 239, 446, 447, 268, + 103, 238, 239, 38, 39, 238, 239, 446, 447, 268, 269, 266, 267, 396, 397, 398, 399, 400, 401, 0, - 1, 236, 237, 0, 1, 136, 137, 412, 413, 232, + 1, 236, 237, 72, 73, 136, 137, 412, 413, 232, 233, 234, 235, 430, 431, 432, 433, 434, 435, 34, 35, 270, 271, 34, 352, 353, 171, 446, 447, 266, 267, 268, 269, 464, 465, 466, 467, 468, 469, 68, 69, 350, 351, 68, 386, 387, 205, 346, 347, 348, 349, 342, 343, 498, 499, 438, 439, 502, 503, 102, - 103, 384, 385, 102, 103, 238, 239, 380, 381, 382, - 383, 376, 377, 402, 403, 472, 473, 404, 405, 0, - 1, 408, 409, 344, 345, 344, 345, 416, 417, 416, - 417, 416, 417, 344, 345, 416, 417, 344, 345, 34, + 103, 384, 385, 102, 103, 238, 239, 380, 120, 120, + 120, 120, 377, 402, 403, 472, 473, 404, 405, 0, + 1, 408, 409, 344, 345, 344, 345, 416, 120, 120, + 120, 120, 417, 344, 345, 416, 417, 344, 345, 34, 35, 442, 443, 378, 379, 378, 379, 450, 451, 450, 451, 450, 451, 378, 379, 450, 451, 378, 379, 68, - 56, 57, 205, 68, 69, 204, 205, 68, 69, 204, - 205, 68, 69, 204, 205, 68, 69, 204, 205, 89, + 56, 57, 205, 68, 69, 204, 205, 68, 306, 204, + 205, 68, 69, 204, 205, 38, 39, 204, 205, 89, 90, 91, 92, 102, 103, 56, 57, 102, 103, 238, - 239, 102, 103, 238, 239, 102, 103, 238, 239, + 239, 102, 103, 238, 239, 72, 73, 238, 239, }; pub const coll = [_]Rect{ @@ -77,7 +77,7 @@ pub const coll = [_]Rect{ }; pub const triggers = [_]Trigger{ - Trigger{.aura = Rect{.base = Point{.x = 16, .y = 96}, .width = 16, .height = 20}, .direction = Direction.Up, .dialogue = "Test message!"}, // sign + Trigger{.aura = Rect{.base = Point{.x = 16, .y = 96}, .width = 16, .height = 20}, .direction = Direction.Up, .dialogue = "18 chars per line\nallowed. Or else!"}, // sign Trigger{.aura = Rect{.base = Point{.x = 83, .y = 103}, .width = 7, .height = 16}, .direction = Direction.Up, .dialogue = "Ded."}, // gravestone 1 Trigger{.aura = Rect{.base = Point{.x = 96, .y = 103}, .width = 7, .height = 16}, .direction = Direction.Up, .dialogue = "Moar ded."}, // gravestone 2 }; diff --git a/src/palette.zig b/src/palette.zig index 0dd2b82..621faef 100644 --- a/src/palette.zig +++ b/src/palette.zig @@ -1,5 +1,19 @@ const w4 = @import("./wasm4.zig"); +// https://lospec.com/palette-list/dusty4 +pub fn overworld() void { + w4.m.palette.* = .{ + w4.Color{.blue = 0xdf, .green = 0xf6, .red = 0xf5}, + //0xf5f6df + w4.Color{.blue = 0x78, .green = 0x8f, .red = 0x5a}, + //0x5a8f78 + w4.Color{.blue = 0x68, .green = 0xa5, .red = 0x3a}, + //0x3a5068 + w4.Color{.blue = 0x51, .green = 0x2a, .red = 0x37}, + //0x372a51 + }; +} + pub fn mist() void { w4.m.palette.* = .{ w4.Color{.blue = 0xc2, .green = 0xf0, .red = 0xc4}, diff --git a/src/sh0rk.zig b/src/sh0rk.zig index 964765f..6074a1f 100644 --- a/src/sh0rk.zig +++ b/src/sh0rk.zig @@ -39,6 +39,15 @@ pub const Direction = enum(u2) { Down, Left, Right, + + pub fn opposite(this: @This()) @This() { + switch(this) { + .Up => .Down, + .Down => .Up, + .Left => .Right, + .Right => .Left, + } + } }; pub const Trigger = struct { @@ -51,4 +60,10 @@ pub const Tileset = enum(u2) { Cave, Rpg, Dungeon, +}; + +pub const State = enum { + Title, + StoryDump, + Gameplay, }; \ No newline at end of file diff --git a/src/tframe.zig b/src/tframe.zig index 56514c3..285f1ba 100644 --- a/src/tframe.zig +++ b/src/tframe.zig @@ -177,7 +177,7 @@ pub fn update(gamepad: w4.GamePad) void { w4.m.colors._0 = .p3; w4.m.colors._1 = .p0; - w4.text(curr_text[0..text_index], 12, 140); + w4.text(curr_text[0..text_index], 8, 136); if (gamepad.a) { w4.trace("dismissing");