Add auditory active circuit tone
parent
b1a22f7c11
commit
18dae1722d
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
|||
"infinite":false,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 1, 1, 1, 55, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 36, 19, 52, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 36, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 54, 36, 1, 39, 1, 50, 19, 19, 19, 22, 22, 22, 19, 19, 19, 19, 52, 1, 1, 1, 1, 37, 1, 39, 1, 1, 1, 1, 1, 37, 1, 55, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 22, 52, 1, 1, 1, 37, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 37, 54, 19, 52, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 50, 67, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 36, 52, 1, 1, 1, 20, 1, 1, 17, 19, 19, 19, 19, 19, 19, 19, 19, 36, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 50, 67, 1, 1, 51, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 35, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 54, 66, 52, 1, 1, 1, 51, 1, 50, 19, 19, 19, 19, 19, 19, 19, 19, 19, 66, 54, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 35, 1, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 1, 1, 1, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 36, 19, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 36, 1, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 54, 36, 1, 39, 0, 50, 19, 19, 19, 22, 22, 22, 19, 19, 19, 19, 52, 0, 0, 0, 0, 37, 1, 39, 0, 0, 0, 0, 0, 37, 1, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 1, 22, 52, 0, 0, 0, 37, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 1, 39, 0, 0, 0, 0, 37, 54, 19, 52, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 0, 0, 0, 50, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 1, 39, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 1, 36, 52, 0, 0, 0, 20, 0, 0, 17, 19, 19, 19, 19, 19, 19, 19, 19, 36, 1, 1, 39, 0, 0, 0, 0, 20, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 1, 39, 0, 0, 0, 50, 67, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 1, 39, 0, 0, 0, 1, 20, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 37, 1, 54, 66, 52, 0, 0, 1, 51, 0, 50, 19, 19, 19, 19, 19, 19, 19, 19, 19, 66, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 1, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
"height":20,
|
||||
"id":1,
|
||||
"name":"solid",
|
||||
|
@ -143,6 +143,18 @@
|
|||
"width":0,
|
||||
"x":76,
|
||||
"y":124
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"id":12,
|
||||
"name":"",
|
||||
"point":true,
|
||||
"rotation":0,
|
||||
"type":"spawn",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":4,
|
||||
"y":140
|
||||
}],
|
||||
"opacity":1,
|
||||
"type":"objectgroup",
|
||||
|
@ -151,7 +163,7 @@
|
|||
"y":0
|
||||
}],
|
||||
"nextlayerid":5,
|
||||
"nextobjectid":12,
|
||||
"nextobjectid":13,
|
||||
"orientation":"orthogonal",
|
||||
"renderorder":"right-down",
|
||||
"tiledversion":"1.7.2",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="20" height="20" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="12">
|
||||
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="20" height="20" tilewidth="8" tileheight="8" infinite="0" nextlayerid="5" nextobjectid="13">
|
||||
<editorsettings>
|
||||
<export target="test.json" format="json"/>
|
||||
</editorsettings>
|
||||
|
@ -8,22 +8,22 @@
|
|||
<data encoding="csv">
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,1,1,
|
||||
1,55,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
36,19,52,1,1,1,1,1,1,1,1,1,1,1,1,1,1,21,36,1,
|
||||
39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,50,54,36,1,
|
||||
39,1,50,19,19,19,22,22,22,19,19,19,19,52,1,1,1,1,37,1,
|
||||
39,1,1,1,1,1,37,1,55,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,22,52,1,1,1,37,39,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,1,37,54,19,52,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,50,67,1,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,1,20,1,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,36,52,1,1,1,20,1,1,17,19,19,19,19,19,19,19,19,36,1,
|
||||
1,39,1,1,1,1,20,1,1,20,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,50,67,1,1,51,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,1,20,1,1,35,1,1,1,1,1,1,1,1,37,1,
|
||||
54,66,52,1,1,1,51,1,50,19,19,19,19,19,19,19,19,19,66,54,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,35,1,
|
||||
1,55,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,1,
|
||||
39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,1,
|
||||
36,19,52,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,36,1,
|
||||
39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,50,54,36,1,
|
||||
39,0,50,19,19,19,22,22,22,19,19,19,19,52,0,0,0,0,37,1,
|
||||
39,0,0,0,0,0,37,1,55,0,0,0,0,0,0,0,0,0,37,1,
|
||||
1,22,52,0,0,0,37,39,0,0,0,0,0,0,0,0,0,0,37,1,
|
||||
1,39,0,0,0,0,37,54,19,52,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,0,0,0,50,67,0,0,0,0,0,0,0,0,0,0,0,37,1,
|
||||
1,39,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,37,1,
|
||||
1,36,52,0,0,0,20,0,0,17,19,19,19,19,19,19,19,19,36,1,
|
||||
1,39,0,0,0,0,20,0,0,20,0,0,0,0,0,0,0,0,37,1,
|
||||
1,39,0,0,0,50,67,0,0,51,0,0,0,0,0,0,0,0,37,1,
|
||||
1,39,0,0,0,1,20,0,0,35,0,0,0,0,0,0,0,0,37,1,
|
||||
54,66,52,0,0,1,51,0,50,19,19,19,19,19,19,19,19,19,66,54,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,1,
|
||||
22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||
</data>
|
||||
|
@ -78,5 +78,8 @@
|
|||
<object id="11" type="door" x="76" y="124">
|
||||
<point/>
|
||||
</object>
|
||||
<object id="12" type="spawn" x="4" y="140">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
</map>
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
w4 png2src --template assets/assets-template --zig assets/tiles.png -o assets/tiles.zig
|
||||
w4 png2src --template assets/assets-template --zig assets/sprites.png -o assets/sprites.zig
|
||||
zig run map2src.zig -- assets/maps/map.zig assets/maps/map.json
|
||||
zig run map2src.zig -- assets/maps/map.zig assets/maps/test.json
|
||||
|
|
|
@ -177,7 +177,7 @@ pub fn bridge(this: *@This(), cells: [2]Cell) void {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn enabled(this: @This(), cell: Cell) bool {
|
||||
pub fn isEnabled(this: @This(), cell: Cell) bool {
|
||||
if (this.indexOf(cell)) |c| {
|
||||
return this.cells[c].enabled;
|
||||
}
|
||||
|
@ -223,6 +223,7 @@ pub fn fill(this: *@This(), rootRaw: Cell) void {
|
|||
if (!conductor) continue;
|
||||
const s = @intToEnum(Side, i);
|
||||
const delta = dir(s);
|
||||
// TODO: check that cell can recieve from this side
|
||||
q.insert(cell + delta);
|
||||
}
|
||||
if (is_plug(tile)) {
|
||||
|
|
|
@ -109,7 +109,7 @@ export fn start() void {
|
|||
w4.trace("{}, {}, {}", .{ assets.spawn, mapPos, assets.spawn - mapPos });
|
||||
|
||||
_ = world.create(.{
|
||||
.pos = Pos.init(util.vec2ToVec2f((assets.spawn - mapPos) * Map.tile_size) + Vec2f{ 4, 4 }),
|
||||
.pos = Pos.init(util.vec2ToVec2f((assets.spawn - mapPos) * Map.tile_size) + Vec2f{ 4, 8 }),
|
||||
.control = .{ .controller = .player, .state = .stand },
|
||||
.sprite = .{ .offset = .{ -4, -8 }, .size = .{ 8, 8 }, .index = 0, .flags = .{ .bpp = .b1 } },
|
||||
.physics = .{ .friction = Vec2f{ 0.15, 0.1 }, .gravity = Vec2f{ 0, 0.25 } },
|
||||
|
@ -196,13 +196,16 @@ export fn update() void {
|
|||
var size = Vec2{ 0, 0 };
|
||||
switch (stage) {
|
||||
0 => size = Vec2{ 6, 6 },
|
||||
// 1 => size = Vec2{ 5, 5 },
|
||||
else => size = Vec2{ 8, 8 },
|
||||
}
|
||||
|
||||
if (circuit.isEnabled(util.vec2cell(pos))) {
|
||||
w4.tone(.{ .start = 60, .end = 1 }, .{ .release = 30, .sustain = 0 }, 10, .{ .channel = .triangle });
|
||||
w4.DRAW_COLORS.* = 0x0020;
|
||||
} else {
|
||||
w4.DRAW_COLORS.* = 0x0030;
|
||||
}
|
||||
var half = Vec2{ @divTrunc(size[0], 2), @divTrunc(size[1], 2) };
|
||||
// w4.trace("{}", .{half});
|
||||
switch (details.t) {
|
||||
.wire => w4.oval(pos - half, size),
|
||||
.plug => w4.rect(pos - half, size),
|
||||
|
|
|
@ -107,7 +107,7 @@ pub fn collide(this: @This(), rect: util.AABB) std.BoundedArray(util.AABB, 9) {
|
|||
|
||||
pub fn isSolid(this: @This(), cell: Cell) bool {
|
||||
if (this.getTile(cell[0], cell[1])) |tile| {
|
||||
return tile != 0;
|
||||
return tile != 0 and tile != 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ pub fn world2cell(vec: Vec2f) Vec2 {
|
|||
return vec2fToVec2(vec / @splat(2, @as(f32, 8)));
|
||||
}
|
||||
|
||||
pub fn vec2cell(vec: Vec2) Cell {
|
||||
return @divTrunc(vec, @splat(2, @as(i32, 8)));
|
||||
}
|
||||
|
||||
pub fn vec2ToVec2f(vec2: Vec2) Vec2f {
|
||||
return Vec2f{ @intToFloat(f32, vec2[0]), @intToFloat(f32, vec2[1]) };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue