bendy ropes
authorhgn <hgodden00@gmail.com>
Thu, 25 Nov 2021 04:13:56 +0000 (04:13 +0000)
committerhgn <hgodden00@gmail.com>
Thu, 25 Nov 2021 04:13:56 +0000 (04:13 +0000)
fishladder.c
maps/and_small.map [new file with mode: 0644]
maps/xor_small.map [new file with mode: 0644]

index bcb554774c96c1a1b6797eb2a0c83f205fa26c16..bcbc37428b6335433bd2ff7306feb337aeab982d 100644 (file)
@@ -197,14 +197,14 @@ struct world
        *data;
 #pragma pack(pop)
        
-       u32 frame;
+       int frame;
        
        int initialzed;
        
-       u32 sim_frame;
+       int sim_frame;
        float sim_start;
        int simulating;
-       u32 sim_run, max_runs;
+       int sim_run, max_runs;
        
        float frame_lerp;
        
@@ -1775,12 +1775,35 @@ void vg_render(void)
                                        int x2 = cell->links[trigger_id] % world.w;
                                        int y2 = (cell->links[trigger_id] - x2) / world.w;
                                        
-                                       v2f drag_to_co;
+                                       v2f startpoint; 
+                                       v2f midpoint;
+                                       v2f endpoint;
                                        
-                                       drag_to_co[0] = (float)x2 + (trigger_id? 0.75f: 0.25f);
-                                       drag_to_co[1] = (float)y2 + 0.25f;
+                                       startpoint[0] = (float)x2 + (trigger_id? 0.75f: 0.25f);
+                                       startpoint[1] = (float)y2 + 0.25f;
                                        
-                                       vg_line2( (v2f){x+0.5f,y+0.5f}, drag_to_co, 0xff0000ff, 0xff00ffff );
+                                       endpoint[0] = x+0.5f;
+                                       endpoint[1] = y+0.5f;
+                                       v2_add( startpoint, endpoint, midpoint );
+                                       v2_muls( midpoint, 0.5f, midpoint );
+                                       midpoint[1] += -0.8f;
+                                       
+                                       float t, ta;
+                                       v2f lastpoint; v2f curpoint;
+                                       v2_copy( startpoint, lastpoint );
+                                       
+                                       for( int i = 0; i < 10; i ++ )
+                                       {
+                                               t = ((float)i+1.f)/10.0f;
+                                               ta = 1.0f-t;
+                                               
+                                               v2_muls( startpoint, ta*ta, curpoint );
+                                               v2_muladds( curpoint, midpoint, 2.0f*ta*t, curpoint );
+                                               v2_muladds( curpoint, endpoint, t*t, curpoint );
+                                               
+                                               vg_line2( lastpoint, curpoint, 0xff444444, 0xff444444 );
+                                               v2_copy( curpoint, lastpoint );
+                                       }
                                }
                        
                                if( cell->config == k_cell_type_split )
diff --git a/maps/and_small.map b/maps/and_small.map
new file mode 100644 (file)
index 0000000..f241bc0
--- /dev/null
@@ -0,0 +1,9 @@
+#############;
+######-######;::c
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+###+##+###+##;:a:a,a::a,c:c:c
+#############;
diff --git a/maps/xor_small.map b/maps/xor_small.map
new file mode 100644 (file)
index 0000000..1cf622c
--- /dev/null
@@ -0,0 +1,12 @@
+#############;
+######-######;:c:c:
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+##         ##;
+###+##+###+##;::a:a,:a::a,c:c:c:c
+#############;