Skip to content

Commit 8118449

Browse files
committed
Commit!
1 parent 2d62cbf commit 8118449

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

Boids.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ <h3> Accelerating Ball </h3>
446446
</code>
447447
</pre>
448448

449-
<p> This is all stuff we've basically done, but we also need a method to simulate all the physics.
449+
<p> This is all stuff we've basically done, but we also need a way to simulate all the physics.
450450
From physics, we know that acceleration is the rate of change of velocity, and that velocity is the rate of change of position.
451451
</p>
452452

@@ -461,12 +461,17 @@ <h3> Accelerating Ball </h3>
461461

462462
<p> As we'll soon see, we have to do this in a <em>very careful</em> way. </p>
463463

464-
<h3>Enter deltaTime</h3>
464+
<h4>Enter deltaTime</h4>
465465

466466
<p>Until now, we've not really considered how long each frame takes.
467467
It'd be reasonable to assume each frame takes about 1/60 seconds to process <em>however</em> each frame takes a slightly different amount of time and, when simulations get more complex, each frame might take a non-slight different amount of time!
468-
469468
</p>
469+
470+
<p>To test this theory, console.log the <em>deltaTime</em> variable inside the <em>draw()</em> function; it will set itself to the time taken to process the previous frame! </p>
471+
472+
<h4>Using deltaTime</h4>
473+
474+
<p> We know $v = p/t$ (where ) </p>
470475

471476
<div id="WrongFPSBallsContainer"></div>
472477

Images/Boids/SpeedAgainstTime.drawio

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" version="26.0.3">
2+
<diagram name="Page-1" id="s7K3Om-JziDVqv6ZY2V3">
3+
<mxGraphModel dx="1050" dy="565" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="413" pageHeight="583" math="0" shadow="0">
4+
<root>
5+
<mxCell id="0" />
6+
<mxCell id="1" parent="0" />
7+
<mxCell id="woH91YMG4Nk-elldio-7-17" value="" style="whiteSpace=wrap;html=1;strokeColor=none;fillColor=#f8cecc;opacity=50;" vertex="1" parent="1">
8+
<mxGeometry x="135" y="235" width="130" height="165" as="geometry" />
9+
</mxCell>
10+
<mxCell id="woH91YMG4Nk-elldio-7-1" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=3;" edge="1" parent="1">
11+
<mxGeometry width="50" height="50" relative="1" as="geometry">
12+
<mxPoint x="80" y="400" as="sourcePoint" />
13+
<mxPoint x="80" y="40" as="targetPoint" />
14+
</mxGeometry>
15+
</mxCell>
16+
<mxCell id="woH91YMG4Nk-elldio-7-2" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=3;" edge="1" parent="1">
17+
<mxGeometry width="50" height="50" relative="1" as="geometry">
18+
<mxPoint x="80" y="400" as="sourcePoint" />
19+
<mxPoint x="400" y="400" as="targetPoint" />
20+
</mxGeometry>
21+
</mxCell>
22+
<mxCell id="woH91YMG4Nk-elldio-7-3" value="&lt;b&gt;&lt;font style=&quot;font-size: 18px;&quot;&gt;Speed&lt;/font&gt;&lt;/b&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
23+
<mxGeometry x="10" y="160" width="60" height="30" as="geometry" />
24+
</mxCell>
25+
<mxCell id="woH91YMG4Nk-elldio-7-4" value="&lt;b&gt;&lt;font style=&quot;font-size: 18px;&quot;&gt;Time&lt;/font&gt;&lt;/b&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
26+
<mxGeometry x="190" y="410" width="60" height="30" as="geometry" />
27+
</mxCell>
28+
<mxCell id="woH91YMG4Nk-elldio-7-5" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=2;fillColor=#dae8fc;strokeColor=#6c8ebf;" edge="1" parent="1" source="woH91YMG4Nk-elldio-7-11">
29+
<mxGeometry width="50" height="50" relative="1" as="geometry">
30+
<mxPoint x="80" y="280" as="sourcePoint" />
31+
<mxPoint x="320" y="80" as="targetPoint" />
32+
</mxGeometry>
33+
</mxCell>
34+
<mxCell id="woH91YMG4Nk-elldio-7-14" value="" style="endArrow=none;html=1;rounded=0;strokeWidth=2;fillColor=#dae8fc;strokeColor=#6c8ebf;" edge="1" parent="1" target="woH91YMG4Nk-elldio-7-11">
35+
<mxGeometry width="50" height="50" relative="1" as="geometry">
36+
<mxPoint x="80" y="280" as="sourcePoint" />
37+
<mxPoint x="320" y="80" as="targetPoint" />
38+
</mxGeometry>
39+
</mxCell>
40+
<mxCell id="woH91YMG4Nk-elldio-7-11" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#f8cecc;strokeColor=none;" vertex="1" parent="1">
41+
<mxGeometry x="260" y="120" width="10" height="10" as="geometry" />
42+
</mxCell>
43+
<mxCell id="woH91YMG4Nk-elldio-7-6" value="" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;fillColor=#f8cecc;strokeColor=none;" vertex="1" parent="1">
44+
<mxGeometry x="130" y="230" width="10" height="10" as="geometry" />
45+
</mxCell>
46+
<mxCell id="woH91YMG4Nk-elldio-7-15" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;fillColor=#f8cecc;strokeColor=#b85450;" edge="1" parent="1" target="woH91YMG4Nk-elldio-7-6">
47+
<mxGeometry width="50" height="50" relative="1" as="geometry">
48+
<mxPoint x="135" y="400" as="sourcePoint" />
49+
<mxPoint x="440" y="270" as="targetPoint" />
50+
</mxGeometry>
51+
</mxCell>
52+
<mxCell id="woH91YMG4Nk-elldio-7-16" value="" style="endArrow=none;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;fillColor=#f8cecc;strokeColor=#b85450;" edge="1" parent="1">
53+
<mxGeometry width="50" height="50" relative="1" as="geometry">
54+
<mxPoint x="265" y="400" as="sourcePoint" />
55+
<mxPoint x="264.5" y="130" as="targetPoint" />
56+
</mxGeometry>
57+
</mxCell>
58+
</root>
59+
</mxGraphModel>
60+
</diagram>
61+
</mxfile>

0 commit comments

Comments
 (0)