瀏覽代碼

Add a system for showing news popups at the bottom

tags/v0.0.4
Fen Dweller 5 年之前
父節點
當前提交
3d5258f449
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: E80B35A6F11C3656
共有 3 個文件被更改,包括 64 次插入1 次删除
  1. +31
    -0
      gorge.css
  2. +1
    -1
      gorge.html
  3. +32
    -0
      gorge.js

+ 31
- 0
gorge.css 查看文件

@@ -496,3 +496,34 @@ div::-webkit-scrollbar-corner {
border-color: #333;
background-color: #111;
}

.news-text {
pointer-events: none;
text-align: center;
position: fixed;
top: 50vw;
left: 50vw;
transform-origin: 0% 0%;
animation: news-text-frames 10s cubic-bezier(0.68, -0.55, 0.265, 1.55);
animation-fill-mode: both;
font-size: 24px;
}

@keyframes news-text-frames {
0% {
transform: translate(0px, 0px);
opacity: 0;
}
20% {
transform: translate(0px, -200px);
opacity: 1;
}
80% {
transform: translate(0px, -200px);
opacity: 1;
}
100% {
transform: translate(0px, 0px);
opacity: 0;
}
}

+ 1
- 1
gorge.html 查看文件

@@ -45,7 +45,7 @@
<div id="upgrades-list"></div>
</div>
<div id="buildings-area">
<div id="buildings" class="title">Buildings</div>
<div id="buildings" class="title">Prey</div>
<div id="building-tooltip">
<div id="building-tooltip-name"></div>
<div id="building-tooltip-desc"></div>


+ 32
- 0
gorge.js 查看文件

@@ -646,6 +646,36 @@ function clickPopup(text, type, location) {
}, 2000);
}

function doNews() {
let news = [
"This is news",
"This is also news",
"SPORTS!"
];

const choice = Math.floor(Math.random() * news.length);

showNews(news[choice]);

setTimeout(() => {
doNews();
}, 30000);
}

function showNews(text) {
const div = document.createElement("div");
div.textContent = text;

div.classList.add("news-text");

const body = document.querySelector("body");

body.appendChild(div);

setTimeout(() => {
body.removeChild(div);
}, 10000);
}
function fillTooltip(type, field, content) {
let item = document.querySelector("#" + type + "-tooltip-" + field);
if (typeof(content) === "string") {
@@ -745,6 +775,8 @@ window.onload = function() {

lastTime = performance.now();

doNews();

setTimeout(updateDisplay, 1000/updateRate);

setTimeout(autosave, 60000);


Loading…
取消
儲存