try to make movement work, fail miserably
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
6641e29997
commit
d8ec754e37
|
@ -222,7 +222,7 @@
|
|||
{
|
||||
"name":"dialogue",
|
||||
"type":"string",
|
||||
"value":"18 chars per line\\nallowed. Or else!"
|
||||
"value":"Kanar News\\nThe mayor is\\nacting weird today."
|
||||
},
|
||||
{
|
||||
"name":"direction",
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<objectgroup id="3" name="act">
|
||||
<object id="30" name="sign" x="16" y="96" width="16" height="20">
|
||||
<properties>
|
||||
<property name="dialogue" value="18 chars per line\nallowed. Or else!"/>
|
||||
<property name="dialogue" value="Kanar News\nThe mayor is\nacting weird today."/>
|
||||
<property name="direction" value="Up"/>
|
||||
</properties>
|
||||
</object>
|
||||
|
|
118
src/main.zig
118
src/main.zig
|
@ -3,6 +3,7 @@ const sh0rk = @import("./sh0rk.zig");
|
|||
const sprites = @import("./sprites.zig");
|
||||
const palette = @import("./palette.zig");
|
||||
const tframe = @import("./tframe.zig");
|
||||
const overhead = @import("./overhead.zig");
|
||||
|
||||
const std = @import("std");
|
||||
const fmt = std.fmt;
|
||||
|
@ -29,9 +30,7 @@ var sound_timer: u8 = 0;
|
|||
var textBuf: [160]u8 = undefined;
|
||||
var done: bool = false;
|
||||
|
||||
var camera = Point{ .x = 32, .y = 0 };
|
||||
|
||||
var state: sh0rk.State = .Gameplay;
|
||||
var camera = Point{ .x = 0, .y = 0 };
|
||||
|
||||
fn world_to_screen(p: Point) Point {
|
||||
return p.sub(camera);
|
||||
|
@ -42,7 +41,11 @@ fn screen_to_world(p: Point) Point {
|
|||
}
|
||||
|
||||
export fn start() void {
|
||||
if (sh0rk.state == .Gameplay) {
|
||||
palette.mist();
|
||||
} else {
|
||||
palette.tamtam();
|
||||
}
|
||||
}
|
||||
|
||||
fn bonk() void {
|
||||
|
@ -192,94 +195,33 @@ fn move_mara(gamepad: w4.GamePad) void {
|
|||
|
||||
switch (mara_direction) {
|
||||
.Up => {
|
||||
camera.y -= mara_speed;
|
||||
if (camera.y == 0 or camera.y == (map.width * tile_size) - (20 * tile_size)) {
|
||||
mara_box.base.y -= mara_speed;
|
||||
} else {
|
||||
camera.y -= mara_speed;
|
||||
}
|
||||
},
|
||||
.Down => {
|
||||
camera.y += mara_speed;
|
||||
if (camera.y == 0 or camera.y == (map.width * tile_size) - (20 * tile_size)) {
|
||||
mara_box.base.y += mara_speed;
|
||||
} else {
|
||||
camera.y += mara_speed;
|
||||
}
|
||||
},
|
||||
.Left => {
|
||||
camera.x -= mara_speed;
|
||||
if (camera.x == 0 or camera.x == (map.width * tile_size) - (20 * tile_size)) {
|
||||
mara_box.base.x -= mara_speed;
|
||||
} else {
|
||||
camera.x -= mara_speed;
|
||||
}
|
||||
},
|
||||
.Right => {
|
||||
camera.x += mara_speed;
|
||||
if (camera.x == 0 or camera.x == (map.width * tile_size) - (20 * tile_size)) {
|
||||
mara_box.base.x += mara_speed;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn title() !void {
|
||||
w4.m.colors._0 = .p3;
|
||||
w4.m.colors._1 = .p0;
|
||||
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: u16 = 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();
|
||||
camera.x += mara_speed;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,9 +231,9 @@ export fn update() void {
|
|||
done = false;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
.Title => title() catch unreachable,
|
||||
.StoryDump => storydump() catch unreachable,
|
||||
switch (sh0rk.state) {
|
||||
.Title => overhead.title() catch unreachable,
|
||||
.StoryDump => overhead.storydump() catch unreachable,
|
||||
.Gameplay => gameplay() catch unreachable,
|
||||
}
|
||||
}
|
||||
|
@ -393,18 +335,6 @@ fn draw_mara() void {
|
|||
};
|
||||
var step: u32 = if (mara_frame) 1 else 0;
|
||||
|
||||
w4.blitSub(
|
||||
&sprites.Mara,
|
||||
mara_box.base.x,
|
||||
mara_box.base.y,
|
||||
16,
|
||||
16,
|
||||
16 * (frame + step),
|
||||
0,
|
||||
96,
|
||||
flags,
|
||||
);
|
||||
|
||||
var scr = world_to_screen(mara_box.base);
|
||||
|
||||
w4.blitSub(
|
||||
|
|
|
@ -192,7 +192,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 = "18 chars per line\nallowed. Or else!" }, // sign
|
||||
Trigger{ .aura = Rect{ .base = Point{ .x = 16, .y = 96 }, .width = 16, .height = 20 }, .direction = Direction.Up, .dialogue = "Kanar News\nThe mayor is\nacting weird today." }, // 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
|
||||
};
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
const palette = @import("./palette.zig");
|
||||
const sh0rk = @import("./sh0rk.zig");
|
||||
const sprites = @import("./sprites.zig");
|
||||
const w4 = @import("./wasm4.zig");
|
||||
|
||||
pub fn title() !void {
|
||||
w4.m.colors._0 = .p3;
|
||||
w4.m.colors._1 = .p0;
|
||||
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) {
|
||||
sh0rk.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 Malto from\nTamamo-no-Mae!\n\nPress x.";
|
||||
var story_idx: u16 = 0;
|
||||
var story_counter: u8 = 4;
|
||||
|
||||
pub 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) {
|
||||
sh0rk.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) {
|
||||
sh0rk.state = .Gameplay;
|
||||
palette.mist();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -84,3 +84,5 @@ pub const State = enum {
|
|||
StoryDump,
|
||||
Gameplay,
|
||||
};
|
||||
|
||||
pub var state: State = .Gameplay;
|
Loading…
Reference in New Issue