Browse Source

New features and added HTML stuff

master
Stephen 4 months ago
parent
commit
feef48ba6c
2 changed files with 19 additions and 1 deletions
  1. +5
    -1
      index.html
  2. +14
    -0
      script.js

+ 5
- 1
index.html View File

@ -1,6 +1,9 @@
<html>
<html lang="en">
<head>
<title>Buzz buzz</title>
<meta name="description" content="That's a lot of bees!">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<script src="script.js">
</script>
<style>
@ -21,6 +24,7 @@
<body>
<div id="container">
<button onclick="addBee()">Add bee</button>
<div id="numBeeText"></div>
</div>
</body>
</html>

+ 14
- 0
script.js View File

@ -1,3 +1,13 @@
function setNumBees() {
const numBeeDiv = document.getElementById("numBeeText");
const numBees = document.getElementsByClassName("bee").length;
numBeeDiv.innerHTML = `${numBees} bee${numBees == 1 ? '' : 's'}. `;
if(numBees >= 10)
{
numBeeDiv.innerHTML += " That's a lot of bees!";
}
}
function addBee() {
const rect = document.body.getBoundingClientRect();
const width = rect.width;
@ -16,9 +26,13 @@ function addBee() {
bee.style.left = `${bee.vars.x}px`;
document.body.appendChild(bee);
setNumBees();
}
window.onload = function() {
setNumBees();
const rect = document.body.getBoundingClientRect();
const width = rect.width;
const height = rect.height;


Loading…
Cancel
Save