Skip to content

Commit c54744a

Browse files
committed
Boids!
1 parent 3ba5caa commit c54744a

File tree

5 files changed

+48
-9
lines changed

5 files changed

+48
-9
lines changed

Pages/Boids.html Boids.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010

1111
<!-- CDNs -->
1212
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"></script>
14+
1315
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
16+
<link href="/SimulationLabs/Stylesheets/Default.css" rel="stylesheet">
1417
</head>
1518

1619
<body>
1720
{% include HeaderBar.html %}
18-
<div id="headerBar"></div>
1921

2022
<!-- Page content -->
2123
<p> This is the boids page </p>
24+
25+
<h1> What you'll create </h1>
26+
27+
<script src="/Scripts/Boids/Boids.js"></script>
2228
</body>
2329
</html>

Scripts/Boids/Boids.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
var x = 200;
2+
var y = 200;
3+
4+
function addRandomDirection(){
5+
let randomChoice = floor(random(4));
6+
7+
switch(randomChoice){
8+
case 0:
9+
x++;
10+
break;
11+
case 1:
12+
x--;
13+
break;
14+
case 2:
15+
y++;
16+
break;
17+
default:
18+
y--;
19+
}
20+
}
21+
22+
function setup(){
23+
createCanvas(400, 400);
24+
background(140, 205, 230);
25+
}
26+
27+
function draw(){
28+
stroke(245, 175, 0); // pen colour
29+
addRandomDirection(); // change state
30+
point(x,y); // draw state
31+
}

Stylesheets/Default.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.headerStyle {
2-
background-color: red;
3-
}
2+
3+
}

_includes/HeaderBar.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<nav class="navbar navbar-expand-lg navbar-light bg-light headerStyle">
1+
<!-- Header Bar component! -->
2+
<nav class="navbar navbar-expand-lg navbar-light bg-light headerStyle" id="headerStyle">
23
<div class="container-fluid">
34
<a class="navbar-brand" href="/SimulationLabs/">Simulation Labs </a>
45
<!-- This collapsible element is needed for the items to align from the left -->
@@ -8,12 +9,12 @@
89
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownToggle" role="button" data-bs-toggle="dropdown"> Labs </a>
910
<ul class="dropdown-menu">
1011
<li>
11-
<a class="dropdown-item" href="/SimulationLabs/Pages/Boids">
12+
<a class="dropdown-item" href="/SimulationLabs/Boids">
1213
Lab 1 - Boids
1314
</a>
1415
</li>
1516
<li>
16-
<a class="dropdown-item" href="/SimulationLabs/Pages/Boids">
17+
<a class="dropdown-item" href="/SimulationLabs/Boids">
1718
Lab 2 - Noise
1819
</a>
1920
</li>
@@ -22,4 +23,4 @@
2223
</ul>
2324
</div>
2425
</div>
25-
</nav>
26+
</nav>

index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
<!-- CDNs -->
1313
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
1414
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
15+
<link href="/SimulationLabs/Stylesheets/Default.css" rel="stylesheet">
1516
</head>
1617

17-
<body>
18+
<body>
1819
{% include HeaderBar.html %}
1920
<!-- Page content -->
20-
<p> Testing testing123 </p>
21+
<p> </p>
2122

2223
</body>
2324
</html>

0 commit comments

Comments
 (0)