Browse Source

Animate upgrade/building buttons a bit. Show text when buying upgrades

tags/v0.0.2
Fen Dweller 5 years ago
parent
commit
edf8c813aa
2 changed files with 45 additions and 4 deletions
  1. +37
    -2
      gorge.css
  2. +8
    -2
      gorge.js

+ 37
- 2
gorge.css View File

@@ -166,8 +166,16 @@ button {
color: #1a1; color: #1a1;
} }


.building-button:hover {
background-color: #333;
#buildings-area:hover > #buildings:hover ~ .building-button:not(:hover) {
opacity: 1;
}

#buildings-area:hover > .building-button:hover {
opacity: 1;
}

#buildings-area:hover > .building-button:not(:hover) {
opacity: 0.6;
} }


.building-button-disabled:hover { .building-button-disabled:hover {
@@ -265,6 +273,11 @@ button {
margin: 10px; margin: 10px;
display: block; display: block;
background-color: #444; background-color: #444;
transition: 0.2s;
}

.upgrade-button:hover {
transform: scale(1.25, 1.25);
} }


@media (max-aspect-ratio: 1/1) { @media (max-aspect-ratio: 1/1) {
@@ -315,6 +328,17 @@ button {
--target: 200px; --target: 200px;
} }


.click-popup-upgrade {
pointer-events: none;
transform-origin: -50% 50%;
text-align: center;
position: fixed;
animation: click-popup-upgrade 2s linear;
animation-fill-mode: both;
font-size: 36px;
--target: -200px;
}

@keyframes click-popup-food { @keyframes click-popup-food {
0% { 0% {
transform: translate(0px, 0px) scale(1, 1); transform: translate(0px, 0px) scale(1, 1);
@@ -337,6 +361,17 @@ button {
} }
} }


@keyframes click-popup-upgrade {
0% {
transform: translate(0px, 0px) scale(1, 1);
opacity: 1;
}
100% {
transform: translate(var(--target), 200px) scale(0.5, 0.5);
opacity: 0;
}
}





div::-webkit-scrollbar { div::-webkit-scrollbar {


+ 8
- 2
gorge.js View File

@@ -224,7 +224,7 @@ function updateClickBonus() {
clickBonus = bonus; clickBonus = bonus;
} }


function buyUpgrade(id) {
function buyUpgrade(id, e) {
if (ownedUpgrades[id]) { if (ownedUpgrades[id]) {
return; return;
} }
@@ -239,6 +239,10 @@ function buyUpgrade(id) {


ownedUpgrades[id] = true; ownedUpgrades[id] = true;


let text = "Bought " + upgrade.name + "!";

clickPopup(text, "upgrade", [e.clientX, e.clientY]);

updateProductivity(); updateProductivity();
updateClickBonus(); updateClickBonus();
} }
@@ -451,7 +455,7 @@ function createUpgrades() {


button.addEventListener("mousemove", function(e) { upgradeTooltip(key, e); }); button.addEventListener("mousemove", function(e) { upgradeTooltip(key, e); });
button.addEventListener("mouseleave", function() { upgradeTooltipRemove(); }); button.addEventListener("mouseleave", function() { upgradeTooltipRemove(); });
button.addEventListener("click", function() { buyUpgrade(key); });
button.addEventListener("click", function(e) { buyUpgrade(key, e); });


container.appendChild(button); container.appendChild(button);
} }
@@ -563,6 +567,8 @@ function clickPopup(text, type, location) {
direction = -150; direction = -150;
} else if (type == "gulp") { } else if (type == "gulp") {
direction = -150; direction = -150;
} else if (type == "upgrade") {
direction = -50;
} }


direction *= Math.random() * 0.5 + 1; direction *= Math.random() * 0.5 + 1;


Loading…
Cancel
Save