forked from RazoftOSS/BallRunner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (94 loc) · 3.96 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!--
#########################################################
# #
# BallRunner #
# http://play.razoft.net #
# #
# https://github.com/RazoftSource/BallRunner #
# #
# #
# Copyright Razoft 2014 #
# http://razoft.com #
# #
# #
# Made by Wojciech Bednarzak #
# http://wojtek.bednarzak.com #
# #
#########################################################
-->
<!DOCTYPE html>
<html>
<head>
<title>BallRunner</title>
<style>
body {
background-color: black;
color: white;
text-align: center;
font-size: 2em;
font-family: sans-serif;
font-weight: 300;
overflow: hidden;
}
.content {
margin: 10% auto;
position: absolute;
width: 100%;
z-index: 100;
}
.content span {
display: block;
font-size: 0.7em;
margin-top: 50px;
opacity: 0.5;
}
.content span a{
text-decoration: underline;
border: 0;
padding: 0;
}
a {
text-decoration: none;
color: inherit;
border-radius: 5px;
border: 1px solid white;
display: inline-block;
padding: 10px 20px;
margin: 20px auto;
}
canvas {
position: absolute;
top: 0;
left: 0;
z-index: 99;
}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-39777815-3', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="content">
<h1>BallRunner</h1>
<a href="sp/">Single Player</a>
<a href="mp/">Multi Player</a>
<br>
<span>© <a href="http://razoft.com">Razoft</a> 2014</span>
</div>
<script type="text/javascript">
// The ball spawning script. Minified. To view "original" version please Beautify the script at http://jsbeautifier.org/
var canvas=document.createElement("canvas"),HEIGHT=window.innerHeight,WIDTH=window.innerWidth,pi=Math.PI,enemy_ball_speed=WIDTH/300,enemy_ball_radius=WIDTH/350,ctx=canvas.getContext("2d");
canvas.height=HEIGHT,canvas.width=WIDTH;var BallRunner=function(){document.body.appendChild(canvas);var a=new Ball,b=function(){ctx.fillRect(0,0,WIDTH,HEIGHT),
ctx.save(),a.update(),a.draw(),ctx.restore(),window.requestAnimationFrame(b,canvas)};window.requestAnimationFrame(b,canvas)},Ball=function(){
this.loc_x=20,this.loc_y=20,this.speed=enemy_ball_speed,this.radius=enemy_ball_radius;var a=Math.floor(Math.random()*(2*pi-.1+1))+.1;this.vel={x:this.speed*Math.sin(a),y:this.speed*Math.cos(a)},
this.update=function(){if(this.loc_x+=this.vel.x,this.loc_y+=this.vel.y,0>this.loc_x+this.radius||this.loc_x+this.radius>WIDTH){var a=this.vel.x<0?0-this.loc_x:WIDTH-(this.loc_x+this.radius);
this.loc_x+=a,this.vel.x*=-1}if(0>this.loc_y-this.radius||this.loc_y+this.radius>HEIGHT){var a=this.vel.y<0?0-this.loc_y:HEIGHT-(this.loc_y+this.radius);this.y+=a,this.vel.y*=-1}},
this.draw=function(){ctx.fillStyle="#f00",ctx.beginPath(),ctx.arc(this.loc_x,this.loc_y,this.radius,0,2*pi,!0),ctx.closePath(),ctx.fill()}};BallRunner();
</script>
</body>
</html>