5 <meta content=
"text/html; charset=utf-8" http-equiv=
"Content-Type"/>
7 <link rel=
"stylesheet" href=
"../style/pixelless.css" type=
"text/css"/>
9 <script type=
"text/javascript" src=
"../script/util.js"></script>
10 <script type=
"text/javascript" src=
"../script/canvas.js"></script>
11 <script type=
"text/javascript" src=
"script/shooter-view.js"></script>
12 <script type=
"text/javascript" src=
"script/gun.js"></script>
13 <script type=
"text/javascript" src=
"script/vehicle.js"></script>
14 <script type=
"text/javascript" src=
"script/shooter.js"></script>
15 <script type=
"text/javascript" src=
"script/shooter-controller.js"></script>
19 <div class=
"content header">
20 <h1 id=
"out">Shoot
</h1>
24 <canvas id=
"canvas" width=
"900px" height=
"600px"></canvas>
26 <div class=
"empty_footer">
33 <script type=
"text/javascript">
34 var a
= ['and', 'mail'].join('y@g');
35 var b
= ['<a ', 'href="mai', 'lto:zz',a
, '.com?','subject=','JavaScript Filler', '"', '>Vynogradov<', '/a>'];
36 document
.write(b
.join(''));
41 <script type=
"text/javascript">
42 // Provide testing ground for different kind of shooting agents
44 var canvas
= document
.getElementById('canvas');
45 var ctx
= canvas
.getContext('2d');
46 ctx
.strokeStyle
= '#eee';
47 ctx
.fillStyle
= '#eee';
50 var frameDelay
= 1000 / fps
;
52 var view
= new ShooterView(ctx
, 900, 600);
54 var pos
= new Point(0, 0);
55 var dir
= 0; // radians - moving north.
56 var mass
= 3; // 'size'
57 var speed
= 60; // units per second
60 var damage
= 10; // projecile damage
61 var distance
= 600; // projectile flight distance
62 var pjSpeed
= 300; // projectile speed
64 var rate
= 20000; // shot rate shots per second
65 var clip
= 25; // clip size
66 var reload
= 500; // reload time
67 var spread
= 5; // 5% (100% = 45°)
69 var vehicle
= new Vehicle(pos
, Math
.PI
/ 4, mass
, speed
);
70 var projectile
= new Projectile(damage
, pjSpeed
);
72 var shotgun
= new Gun(projectile
, distance
, rate
, clip
, reload
, spread
);
77 reload
= clip
* damage
/ shotgun
.dps
- clip
/ rate
;
80 projectile
= new Projectile(damage
, pjSpeed
);
81 var rifle
= new Gun(projectile
, distance
, rate
, clip
, reload
, spread
);
82 var sample
= new Shooter(vehicle
, hp
, []);
86 while (shooters
.length
< numShooters
){
87 var clone
= sample
.clone();
88 var dir
= clone
.vehicle
.dir
= rnd(4 * Math
.PI
);
89 clone
.vehicle
.pos
= new Point(speed
*sin(dir
), speed
*cos(dir
));
90 var type
= rnd(100)<50;
91 clone
.guns
= [type
?shotgun
:rifle
];
92 clone
.color
= type
? '#bbf' : '#fbb';
96 var ctrl
= new ShooterController(view
, shooters
, 900, 600);
104 var charge
= last
== 0 ? 0 : t
-last
;
109 window
.mozRequestAnimationFrame(frame
);
113 ctx
.bind('click', function(){
117 window
.mozRequestAnimationFrame(frame
);
120 window
.mozRequestAnimationFrame(frame
);
124 var o
= document
.getElementById('out');
125 out = function(text
){o
.innerHTML
= text
};
132 var lastframe
= (new Date()).getTime();
133 var animframe
= ['. ', ' . ', ' . ', ' .']
134 showFps = function(t
)
137 var fps
= 1000 / (t
-lastframe
);
139 out(fps
.toFixed(0)+' fps');
140 var smoothfps
= [fps
]
142 showFps = function(t
)
145 var fps
= 1000 / (t
-lastframe
);
147 var l
= smoothfps
.length
;
155 smoothfps
[i
+1] = smoothfps
[i
];
158 out((smoothfps
.sum()/l).toFixed(0)+' fps'+animframe[Math.floor(frames/10)%4]);