@@ -0,0 +1,89 @@
1+ ____ _ __ __ _ __ _ ____ ____ __ __ __ _ ____ _____ _ ____ __ _ ____
2+ | ===|| |__\ \/ /| || \| |/ (_,` | ===|| | || \| |/ (__`|_ _|| |/ () \| \| | (_ (_`
3+ |__| |____||__| |_||_|\__|\____) |__| \___/ |_|\__|\____) |_| |_|\____/|_|\__|.__)__)
4+
5+
6+Flying functions is a JS game engine. This is a study project, I'm doing this to learn more about
7+game development and in specific game development in the browser.
8+
9+I started with an engine, so that I can use it for future experiments with animating the HTML5 canvas.
10+
11+Still want to try it out? Ok, just include the `lib/flying-functions.js` in your page.
12+After it's loaded you can initialize the engine. There are a options you can pass to the constructor
13+check out the annotted source code in `docs/` for more on this.
14+
15+ <script src="../lib/flying-functions.js"></script>
16+ <script>
17+ var ff = new FlyingFunctions({
18+ width: 640,
19+ height: 320
20+ });
21+ </script>
22+
23+Here is a full example (form the test folder):
24+
25+ <!doctype html>
26+ <html lang="en">
27+ <head>
28+ <title>Flying Functions Main test</title>
29+ </head>
30+ <body>
31+
32+ <script src="../lib/flying-functions.js"></script>
33+ <script>
34+ console.log(FlyingFunctions);
35+ console.log(FlyingFunctions.prototype);
36+
37+ var ff = new FlyingFunctions({
38+ width: 640,
39+ height: 320,
40+ init: function (o) {
41+ console.log('in init func');
42+ // this is the ff object
43+ console.log(typeof this);
44+ console.log(this instanceof FlyingFunctions);
45+ console.log(o);
46+ }
47+ });
48+
49+ console.log(ff);
50+
51+ var particle = {
52+ x: 10,
53+ y: 10,
54+ speed: 5,
55+ size: 2,
56+ random: true
57+ };
58+
59+ ff.on('frame', function () {
60+ var c = this.c;
61+
62+ if (particle.random) {
63+ particle.x += particle.speed + Math.floor(Math.random() * 220);
64+ particle.y += particle.speed + Math.floor(Math.random() * 160);
65+ } else {
66+ particle.x += particle.speed;
67+ particle.y += particle.speed;
68+ }
69+
70+ if (particle.x >= this.canvas.width || particle.y >= this.canvas.height) {
71+ particle.x = 10;
72+ particle.y = 10;
73+ }
74+
75+ c.save();
76+ c.fillStyle = "hsl(190, 100%, 50%)";
77+ c.beginPath();
78+ c.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2, true);
79+ c.fill();
80+ c.restore();
81+ });
82+
83+ window.onload = function () {
84+ ff.loop();
85+ };
86+ </script>
87+
88+ </body
89+ </html>