diff --git a/README.md b/README.md index 6d51869..e355ba8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,5 @@ A game in which a 2.5 year old will hopefully look for bugs under rocks before s ## Todo - Fix all the PWA assets, some are still default -- Make sounds when rocks are flung -- Make rocks smaller so that they're easier to find? - Add things under rocks - Add ridiculous sounds diff --git a/assets/img/unicorn.png b/assets/img/unicorn.png new file mode 100644 index 0000000..b5e7fea Binary files /dev/null and b/assets/img/unicorn.png differ diff --git a/index.html b/index.html index e103b48..7b5740e 100644 --- a/index.html +++ b/index.html @@ -104,8 +104,13 @@

Nora Looks For Bugs

diff --git a/main.js b/main.js index 7162ad1..f321d5c 100644 --- a/main.js +++ b/main.js @@ -4,7 +4,10 @@ const gridSize = 51200 / 256; const rockSounds = []; function preloadAssets() { - const imagesToPreload = ["./assets/img/rock1.png"]; + const imagesToPreload = [ + "./assets/img/rock1.png", + "./assets/img/unicorn.png", + ]; const soundsToPreload = [ "./assets/sound/rock1.m4a", @@ -52,11 +55,13 @@ document.addEventListener("DOMContentLoaded", () => { } function createRockComponent(location) { - const rock = rockTemplate.content.cloneNode(true).querySelector(".rock"); - rock.style.gridRow = location.x; - rock.style.gridColumn = location.y; - rock.addEventListener("click", flingRock); - scrollableArea.appendChild(rock); + const rockContainer = rockTemplate.content + .cloneNode(true) + .querySelector(".rock-container"); + rockContainer.style.gridRow = location.x; + rockContainer.style.gridColumn = location.y; + rockContainer.querySelector(".rock").addEventListener("click", flingRock); + scrollableArea.appendChild(rockContainer); } function createRocks() { diff --git a/style.css b/style.css index ef2df7c..35e6d10 100644 --- a/style.css +++ b/style.css @@ -117,7 +117,14 @@ body { grid-template-rows: repeat(auto-fill, 256px); } +.rock-container { + position: relative; +} + .rock { + position: absolute; + top: 0; + left: 0; width: 256px; height: 256px; cursor: pointer; @@ -126,6 +133,7 @@ body { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; + z-index: 100; } .rock img { @@ -133,3 +141,11 @@ body { height: 100%; pointer-events: none; } + +.bug { + position: absolute; + top: 0; + left: 0; + z-index: 1; + z-index: 50; +}