Skip to content

Commit

Permalink
hitboxes adjust to the images
Browse files Browse the repository at this point in the history
  • Loading branch information
mzelder committed Aug 1, 2024
1 parent 9359d37 commit add89f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ document.addEventListener("DOMContentLoaded", () => {
// lamp min: -100vh, max: -50
// plant min: 20, max: 70
// 120 between lamp and plant
// hitboxes: lamp: +60 plant: +10
function createColumns(size, distanceBetweenTop, distanceBetweenLeft) {
let gap = 0;
for (let i = 0; i < size; i++) {
Expand All @@ -166,12 +167,14 @@ document.addEventListener("DOMContentLoaded", () => {

const plantHitBox = document.createElement("div");
plantHitBox.classList.add("plant-hitbox");
plantHitBox.style.left = bodyWidth + gap + 80 + "px";
plantHitBox.style.left = bodyWidth + gap + 50 + "px";
plantHitBox.style.top = `${plantTop + 10}vh`
body.appendChild(plantHitBox);

const lampHitBox = document.createElement("div");
lampHitBox.classList.add("lamp-hitbox");
lampHitBox.style.left = bodyWidth + gap + 150 + "px";
lampHitBox.style.left = bodyWidth + gap + 110 + "px";
lampHitBox.style.top = `${lampTop + 60}vh`
body.appendChild(lampHitBox);

gap += distanceBetweenLeft;
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ body {
position: absolute;
top: -20vh;
height: 48vh;
width: 10vw;
width: 12vh;
}

.plant-hitbox {
Expand Down

0 comments on commit add89f5

Please sign in to comment.