html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body><!--Helped by leichickenburGER-->
<div ng-app="myApp" ng-controller="clickCounter" id="gamearea">
<button ng-click="count=count+5" id="virus"></button>
<p>Score:{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('clickCounter', function($scope) {
$scope.count = 0;
});
function setGoldenPos(x,y) {
var virus = document.querySelector("#virus");
virus.style.left = x + "px";
virus.style.top = y + "px";
}
function getRandom(max) {
return Math.floor(Math.random() * max);
}
setGoldenPos(getRandom(350-25),getRandom(350-35));
setInterval(function() {
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#virus{
height:30px;
width:20px;
background-color: #ffd800;
border:4px dashed #ff4681;
border-radius:30px;
position:relative;
transition:all 2s;
}
div {
height:500px;
width:570px;
background-color: black;
color: papayawhip;
border:3px solid yellow;
}
body {
background-color: dodgerblue;
font-size:30pt;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
alert("Touch the virus to catch it . Let me see how many of you can get more than 100.\n Good luck!")
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run