256
Fl
FlyingFunctions / files
FlyingFunctions / test / flying-functions.html
1.7 KB
1<!doctype html> 2<html lang="en"> 3<head> 4 <title>Flying Functions Main test</title> 5</head> 6<body> 7 8 <script src="../lib/flying-functions.js"></script> 9 <script> 10 console.log(FlyingFunctions); 11 console.log(FlyingFunctions.prototype); 12 13 var ff = new FlyingFunctions({ 14 width: 640, 15 height: 320, 16 init: function (o) { 17 console.log('in init func'); 18 // this is the ff object 19 console.log(typeof this); 20 console.log(this instanceof FlyingFunctions); 21 console.log(o); 22 } 23 }); 24 25 console.log(ff); 26 27 var particle = { 28 x: 10, 29 y: 10, 30 speed: 5, 31 size: 2, 32 random: true 33 }; 34 35 ff.on('frame', function () { 36 var c = this.c; 37 38 if (particle.random) { 39 particle.x += particle.speed + Math.floor(Math.random() * 220); 40 particle.y += particle.speed + Math.floor(Math.random() * 160); 41 } else { 42 particle.x += particle.speed; 43 particle.y += particle.speed; 44 } 45 46 if (particle.x >= this.canvas.width || particle.y >= this.canvas.height) { 47 particle.x = 10; 48 particle.y = 10; 49 } 50 51 c.save(); 52 c.fillStyle = "hsl(190, 100%, 50%)"; 53 c.beginPath(); 54 c.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2, true); 55 c.fill(); 56 c.restore(); 57 }); 58 59 window.onload = function () { 60 ff.loop(); 61 }; 62 </script> 63 64</body> 65</html>