pet
This commit is contained in:
parent
5010652a52
commit
73d8b73284
1 changed files with 13 additions and 2 deletions
15
index.html
15
index.html
|
@ -78,15 +78,26 @@
|
||||||
var header = document.getElementById("header");
|
var header = document.getElementById("header");
|
||||||
var awdog = document.getElementById("awdog");
|
var awdog = document.getElementById("awdog");
|
||||||
|
|
||||||
|
var intensity = 0;
|
||||||
|
|
||||||
function pet() {
|
function pet() {
|
||||||
alert("pet");
|
intensity = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prevTime = 0;
|
||||||
|
|
||||||
async function update(timestamp) {
|
async function update(timestamp) {
|
||||||
|
let dt = (timestamp - prevTime) / 1000;
|
||||||
|
prevTime = timestamp;
|
||||||
|
|
||||||
// petting shake
|
// petting shake
|
||||||
let a = Math.random() * Math.PI * 2;
|
let a = Math.random() * Math.PI * 2;
|
||||||
let intensity = 20;
|
|
||||||
awdog.style.transform = "translate(" + (Math.cos(a) * intensity) + "px, " + (Math.sin(a) * intensity) + "px)";
|
awdog.style.transform = "translate(" + (Math.cos(a) * intensity) + "px, " + (Math.sin(a) * intensity) + "px)";
|
||||||
|
if (intensity > 0) {
|
||||||
|
intensity -= 10 * dt;
|
||||||
|
} else {
|
||||||
|
intensity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// header
|
// header
|
||||||
let t = timestamp / 500;
|
let t = timestamp / 500;
|
||||||
|
|
Reference in a new issue