Skip to content

Commit

Permalink
Boids!
Browse files Browse the repository at this point in the history
  • Loading branch information
RexMortem committed Dec 20, 2024
1 parent 3ba5caa commit c54744a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Pages/Boids.html → Boids.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@

<!-- CDNs -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"></script>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/SimulationLabs/Stylesheets/Default.css" rel="stylesheet">
</head>

<body>
{% include HeaderBar.html %}
<div id="headerBar"></div>

<!-- Page content -->
<p> This is the boids page </p>

<h1> What you'll create </h1>

<script src="/Scripts/Boids/Boids.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions Scripts/Boids/Boids.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var x = 200;
var y = 200;

function addRandomDirection(){
let randomChoice = floor(random(4));

switch(randomChoice){
case 0:
x++;
break;
case 1:
x--;
break;
case 2:
y++;
break;
default:
y--;
}
}

function setup(){
createCanvas(400, 400);
background(140, 205, 230);
}

function draw(){
stroke(245, 175, 0); // pen colour
addRandomDirection(); // change state
point(x,y); // draw state
}
4 changes: 2 additions & 2 deletions Stylesheets/Default.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.headerStyle {
background-color: red;
}

}
9 changes: 5 additions & 4 deletions _includes/HeaderBar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light headerStyle">
<!-- Header Bar component! -->
<nav class="navbar navbar-expand-lg navbar-light bg-light headerStyle" id="headerStyle">
<div class="container-fluid">
<a class="navbar-brand" href="/SimulationLabs/">Simulation Labs </a>
<!-- This collapsible element is needed for the items to align from the left -->
Expand All @@ -8,12 +9,12 @@
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownToggle" role="button" data-bs-toggle="dropdown"> Labs </a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="/SimulationLabs/Pages/Boids">
<a class="dropdown-item" href="/SimulationLabs/Boids">
Lab 1 - Boids
</a>
</li>
<li>
<a class="dropdown-item" href="/SimulationLabs/Pages/Boids">
<a class="dropdown-item" href="/SimulationLabs/Boids">
Lab 2 - Noise
</a>
</li>
Expand All @@ -22,4 +23,4 @@
</ul>
</div>
</div>
</nav>
</nav>
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
<!-- CDNs -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/SimulationLabs/Stylesheets/Default.css" rel="stylesheet">
</head>

<body>
<body>
{% include HeaderBar.html %}
<!-- Page content -->
<p> Testing testing123 </p>
<p> </p>

</body>
</html>

0 comments on commit c54744a

Please sign in to comment.