Made player let go of wire if they go too far
parent
882657f528
commit
dc831e0948
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const Vec2 = std.meta.Vector(2,i32);
|
||||
const Wire = struct { p1: Vec2, p2: Vec2, a1: bool, a2: bool };
|
||||
pub const solid: [400]u8 = .{ 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, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 36, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 54, 36, 1, 1, 39, 1, 1, 1, 50, 65, 19, 19, 19, 19, 19, 19, 52, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 19, 19, 19, 52, 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, 18, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 50, 67, 1, 1, 20, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135, 162, 131, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 151, 162, 131, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 163, 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 };
|
||||
pub const wire: [3]Wire = [_]Wire{.{.a1 = true, .a2 = true,.p1 = Vec2{ 20, 20 },.p2 = Vec2{ 76, 20 },}, .{.a1 = true, .a2 = false,.p1 = Vec2{ 84, 19 },.p2 = Vec2{ 139, 20 },}, .{.a1 = true, .a2 = false,.p1 = Vec2{ 60, 68 },.p2 = Vec2{ 139, 70 },}, };
|
||||
pub const solid: [400]u8 = .{ 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, 19, 52, 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, 18, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 50, 67, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 54, 66, 52, 1, 1, 1, 51, 1, 1, 51, 1, 50, 19, 19, 19, 19, 34, 1, 33, 54, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 51, 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 };
|
||||
pub const conduit: [400]u8 = .{ 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, 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 };
|
||||
pub const wire: [3]Wire = [_]Wire{.{.a1 = true, .a2 = true,.p1 = Vec2{ 20, 20 },.p2 = Vec2{ 76, 20 },}, .{.a1 = true, .a2 = false,.p1 = Vec2{ 84, 20 },.p2 = Vec2{ 140, 20 },}, .{.a1 = true, .a2 = false,.p1 = Vec2{ 68, 68 },.p2 = Vec2{ 140, 68 },}, };
|
||||
|
|
|
@ -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, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 36, 1, 1, 39, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 54, 36, 1, 1, 39, 1, 1, 1, 50, 65, 19, 19, 19, 19, 19, 19, 52, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 19, 19, 19, 52, 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, 18, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 50, 67, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 54, 66, 52, 1, 1, 1, 51, 1, 1, 51, 1, 50, 19, 19, 19, 19, 34, 1, 33, 54, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 51, 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, 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, 19, 52, 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, 18, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 50, 67, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 1, 39, 1, 1, 1, 1, 20, 1, 1, 20, 1, 1, 1, 1, 1, 1, 20, 1, 37, 1, 54, 66, 52, 1, 1, 1, 51, 1, 1, 51, 1, 50, 19, 19, 19, 19, 34, 1, 33, 54, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 51, 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",
|
||||
|
@ -15,7 +15,7 @@
|
|||
"y":0
|
||||
},
|
||||
{
|
||||
"data":[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, 131, 131, 180, 0, 0, 0, 0, 0, 0, 178, 180, 0, 0, 0, 0, 0, 0, 178, 130, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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],
|
||||
"height":20,
|
||||
"id":2,
|
||||
"name":"conduit",
|
||||
|
@ -57,12 +57,12 @@
|
|||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
"x":-0.125,
|
||||
"y":0.125
|
||||
},
|
||||
{
|
||||
"x":55.5909090909091,
|
||||
"y":0.147727272727273
|
||||
"x":55.875,
|
||||
"y":0.125
|
||||
}],
|
||||
"properties":[
|
||||
{
|
||||
|
@ -83,12 +83,12 @@
|
|||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
"x":8,
|
||||
"y":-0.181818181818187
|
||||
},
|
||||
{
|
||||
"x":79.0909090909091,
|
||||
"y":2
|
||||
"x":80,
|
||||
"y":-0.181818181818187
|
||||
}],
|
||||
"properties":[
|
||||
{
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
<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,39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,21,36,1,
|
||||
1,39,1,1,1,1,1,1,1,1,1,1,1,1,1,1,50,54,36,1,
|
||||
1,39,1,1,1,50,65,19,19,19,19,19,19,52,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,1,1,1,1,1,1,1,1,1,37,1,
|
||||
1,39,1,1,1,1,20,19,19,19,52,1,1,1,1,1,1,1,37,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,19,52,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,18,1,37,1,
|
||||
|
@ -38,7 +38,7 @@
|
|||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,147,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,0,147,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,132,0,
|
||||
|
@ -60,13 +60,13 @@
|
|||
<properties>
|
||||
<property name="anchor2" type="bool" value="false"/>
|
||||
</properties>
|
||||
<polyline points="0,0 55.5909,0.147727"/>
|
||||
<polyline points="-0.125,0.125 55.875,0.125"/>
|
||||
</object>
|
||||
<object id="7" type="wire" x="60" y="68.1818">
|
||||
<properties>
|
||||
<property name="anchor2" type="bool" value="false"/>
|
||||
</properties>
|
||||
<polyline points="0,0 79.0909,2"/>
|
||||
<polyline points="8,-0.181818 80,-0.181818"/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
</map>
|
||||
|
|
BIN
assets/tiles.png
BIN
assets/tiles.png
Binary file not shown.
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 691 B |
File diff suppressed because one or more lines are too long
75
src/main.zig
75
src/main.zig
|
@ -160,8 +160,8 @@ export fn start() void {
|
|||
|
||||
var nodes = std.BoundedArray(Pos, 32).init(0) catch showErr("Nodes");
|
||||
var i: usize = 0;
|
||||
const divisions = @floatToInt(usize, length(size) / 6);
|
||||
w4.trace("{d:.0} long, {} divisions", .{ length(size), divisions });
|
||||
const divisions = @floatToInt(usize, vec_length(size) / 6);
|
||||
w4.trace("{d:.0} long, {} divisions", .{ vec_length(size), divisions });
|
||||
while (i <= divisions) : (i += 1) {
|
||||
const pos = begin + @splat(2, @intToFloat(f32, i)) * size / @splat(2, @intToFloat(f32, divisions));
|
||||
nodes.append(Pos.init(pos)) catch showErr("Appending nodes");
|
||||
|
@ -209,12 +209,18 @@ export fn update() void {
|
|||
world.process(1, &.{.wire}, wireDrawProcess);
|
||||
|
||||
if (indicator) |pos| {
|
||||
if (@divTrunc((time % 60), 30) == 0)
|
||||
w4.DRAW_COLORS.* = 0x0031
|
||||
else
|
||||
w4.DRAW_COLORS.* = 0x0030;
|
||||
const stage = @divTrunc((time % 60), 30);
|
||||
var size = Vec2{ 0, 0 };
|
||||
switch (stage) {
|
||||
0 => size = Vec2{ 6, 6 },
|
||||
// 1 => size = Vec2{ 5, 5 },
|
||||
else => size = Vec2{ 8, 8 },
|
||||
}
|
||||
|
||||
w4.oval(pos - w4.Vec2{ 2, 2 }, w4.Vec2{ 5, 5 });
|
||||
w4.DRAW_COLORS.* = 0x0020;
|
||||
var half = Vec2{ @divTrunc(size[0], 2), @divTrunc(size[1], 2) };
|
||||
// w4.trace("{}", .{half});
|
||||
w4.oval(pos - half, size);
|
||||
}
|
||||
|
||||
indicator = null;
|
||||
|
@ -248,18 +254,18 @@ fn wireManipulationProcess(_: f32, id: usize, pos: *Pos, control: *Control) void
|
|||
var e = world.get(details.id);
|
||||
var wire = &e.wire.?;
|
||||
var nodes = wire.nodes.slice();
|
||||
// e.wire.?.nodes.slice()[details.which].pos = pos.pos;
|
||||
// e.wire.?.nodes.slice()[details.which].last = pos.pos;
|
||||
// constrainNodes(pos, &e.wire.?.nodes.slice()[details.which]);
|
||||
var t = if (details.which == 0)
|
||||
tension(&nodes[details.which], &nodes[details.which + 1])
|
||||
else
|
||||
tension(&nodes[details.which], &nodes[details.which - 1]);
|
||||
|
||||
if (t > 1)
|
||||
constrainNodes(pos, &nodes[details.which])
|
||||
else
|
||||
var maxLength = wireMaxLength(wire);
|
||||
var length = wireLength(wire);
|
||||
|
||||
if (length > maxLength * 1.5) {
|
||||
nodes[details.which].pinned = false; // = pos.pos + Vec2f{ 0, -4 };
|
||||
control.grabbing = null;
|
||||
world.set(details.id, e);
|
||||
return;
|
||||
} else {
|
||||
nodes[details.which].pos = pos.pos + Vec2f{ 0, -4 };
|
||||
}
|
||||
|
||||
var mapPos = vec2ftovec2((pos.pos + offset) / @splat(2, @as(f32, 8)));
|
||||
if (is_plug(get_conduit(mapPos) orelse 0)) {
|
||||
|
@ -332,13 +338,13 @@ fn is_solid(pos: Vec2) bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
fn length(vec: Vec2f) f32 {
|
||||
fn vec_length(vec: Vec2f) f32 {
|
||||
var squared = vec * vec;
|
||||
return @sqrt(@reduce(.Add, squared));
|
||||
}
|
||||
|
||||
fn normalize(vec: Vec2f) Vec2f {
|
||||
return vec / @splat(2, length(vec));
|
||||
return vec / @splat(2, vec_length(vec));
|
||||
}
|
||||
|
||||
fn wirePhysicsProcess(dt: f32, wire: *Wire) void {
|
||||
|
@ -349,6 +355,7 @@ fn wirePhysicsProcess(dt: f32, wire: *Wire) void {
|
|||
var physics = Physics{ .gravity = Vec2f{ 0, 0.25 }, .friction = Vec2f{ 0.05, 0.05 } };
|
||||
velocityProcess(dt, node);
|
||||
physicsProcess(dt, node, &physics);
|
||||
collideNode(node);
|
||||
}
|
||||
|
||||
var iterations: usize = 0;
|
||||
|
@ -421,18 +428,32 @@ fn collidePointMap(point: Vec2f) ?Hit {
|
|||
const wireSegmentMaxLength = 4;
|
||||
const wireSegmentMaxLengthV = @splat(2, @as(f32, wireSegmentMaxLength));
|
||||
|
||||
fn constrainToAnchor(anchor: *Pos, node: *Pos) void {
|
||||
var diff = anchor.pos - node.pos;
|
||||
var dist = distancef(node.pos, anchor.pos);
|
||||
var wireLength = @maximum(wireSegmentMaxLength, dist);
|
||||
node.pos = anchor.pos - (normalize(diff) * @splat(2, @as(f32, wireLength)));
|
||||
// fn constrainToAnchor(anchor: *Pos, node: *Pos) void {
|
||||
// var diff = anchor.pos - node.pos;
|
||||
// var dist = distancef(node.pos, anchor.pos);
|
||||
// var wireLength = @maximum(wireSegmentMaxLength, dist);
|
||||
// node.pos = anchor.pos - (normalize(diff) * @splat(2, @as(f32, wireLength)));
|
||||
// }
|
||||
|
||||
fn wireMaxLength(wire: *Wire) f32 {
|
||||
return @intToFloat(f32, wire.nodes.len) * wireSegmentMaxLength;
|
||||
}
|
||||
|
||||
fn wireLength(wire: *Wire) f32 {
|
||||
var nodes = wire.nodes.slice();
|
||||
var length: f32 = 0;
|
||||
var i: usize = 1;
|
||||
while (i < nodes.len) : (i += 1) {
|
||||
length += distancef(nodes[i - 1].pos, nodes[i].pos);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
fn tension(prevNode: *Pos, node: *Pos) f32 {
|
||||
var dist = distancef(node.pos, prevNode.pos);
|
||||
var difference: f32 = 0;
|
||||
if (dist > 0) {
|
||||
difference = (wireSegmentMaxLength - dist) / dist;
|
||||
difference = (@minimum(dist, wireSegmentMaxLength) - dist) / dist;
|
||||
}
|
||||
return difference;
|
||||
}
|
||||
|
@ -453,12 +474,11 @@ fn wireDrawProcess(_: f32, wire: *Wire) void {
|
|||
var nodes = wire.nodes.slice();
|
||||
if (nodes.len == 0) return;
|
||||
|
||||
w4.DRAW_COLORS.* = 0x0001;
|
||||
w4.DRAW_COLORS.* = 0x0002;
|
||||
for (nodes) |node, i| {
|
||||
if (i == 0) continue;
|
||||
w4.line(vec2ftovec2(nodes[i - 1].pos), vec2ftovec2(node.pos));
|
||||
}
|
||||
w4.DRAW_COLORS.* = 0x0031;
|
||||
}
|
||||
|
||||
fn vec2tovec2f(vec2: w4.Vec2) Vec2f {
|
||||
|
@ -522,6 +542,7 @@ fn controlProcess(_: f32, pos: *Pos, control: *Control, physics: *Physics, kinem
|
|||
if (delta[0] > 0) control.facing = .right;
|
||||
if (delta[0] < 0) control.facing = .left;
|
||||
if (input.btn(.one, .up)) control.facing = .up;
|
||||
if (input.btn(.one, .down)) control.facing = .down;
|
||||
var move = delta * @splat(2, @as(f32, 0.2));
|
||||
pos.pos += move;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue