xonecas.io
256
Fl

FlyingFunctions / commit e430f02

tweaks to docs and readme

xonecas2013-03-26 e430f02ed9243b52d66b8e3cc95a9ce1b99fd138 parent c696bdd

3 files changed

README.md+76−74
@@ -13,83 +13,85 @@ After it's loaded you can initialize the engine. There are a options you can pas
1313 check out the annotted source code in `docs/` for more on this.
1414
1515 ```javascript
16- var ff = new FlyingFunctions({
17- width: 640,
18- height: 320
19- });
16+var ff = new FlyingFunctions({
17+ width: 640,
18+ height: 320
19+});
2020
21- ff.on('frame', function () {
22- // my drawing code
23- });
21+ff.on('frame', function () {
22+ // my drawing code
23+});
2424
25- // start the game loop
26- ff.loop();
25+// start the game loop
26+ff.loop();
2727 ```
2828
2929 Here is a full example (form the test folder):
3030
31- <!doctype html>
32- <html lang="en">
33- <head>
34- <title>Flying Functions Main test</title>
35- </head>
36- <body>
37-
38- <script src="../lib/flying-functions.js"></script>
39- <script>
40- console.log(FlyingFunctions);
41- console.log(FlyingFunctions.prototype);
42-
43- var ff = new FlyingFunctions({
44- width: 640,
45- height: 320,
46- init: function (o) {
47- console.log('in init func');
48- // this is the ff object
49- console.log(typeof this);
50- console.log(this instanceof FlyingFunctions);
51- console.log(o);
52- }
53- });
54-
55- console.log(ff);
56-
57- var particle = {
58- x: 10,
59- y: 10,
60- speed: 5,
61- size: 2,
62- random: true
63- };
64-
65- ff.on('frame', function () {
66- var c = this.c;
67-
68- if (particle.random) {
69- particle.x += particle.speed + Math.floor(Math.random() * 220);
70- particle.y += particle.speed + Math.floor(Math.random() * 160);
71- } else {
72- particle.x += particle.speed;
73- particle.y += particle.speed;
74- }
75-
76- if (particle.x >= this.canvas.width || particle.y >= this.canvas.height) {
77- particle.x = 10;
78- particle.y = 10;
79- }
80-
81- c.save();
82- c.fillStyle = "hsl(190, 100%, 50%)";
83- c.beginPath();
84- c.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2, true);
85- c.fill();
86- c.restore();
87- });
88-
89- window.onload = function () {
90- ff.loop();
91- };
92- </script>
93-
94- </body
95- </html>
31+```html
32+<!doctype html>
33+<html lang="en">
34+<head>
35+ <title>Flying Functions Main test</title>
36+</head>
37+<body>
38+
39+ <script src="../lib/flying-functions.js"></script>
40+ <script>
41+ console.log(FlyingFunctions);
42+ console.log(FlyingFunctions.prototype);
43+
44+ var ff = new FlyingFunctions({
45+ width: 640,
46+ height: 320,
47+ init: function (o) {
48+ console.log('in init func');
49+ // this is the ff object
50+ console.log(typeof this);
51+ console.log(this instanceof FlyingFunctions);
52+ console.log(o);
53+ }
54+ });
55+
56+ console.log(ff);
57+
58+ var particle = {
59+ x: 10,
60+ y: 10,
61+ speed: 5,
62+ size: 2,
63+ random: true
64+ };
65+
66+ ff.on('frame', function () {
67+ var c = this.c;
68+
69+ if (particle.random) {
70+ particle.x += particle.speed + Math.floor(Math.random() * 220);
71+ particle.y += particle.speed + Math.floor(Math.random() * 160);
72+ } else {
73+ particle.x += particle.speed;
74+ particle.y += particle.speed;
75+ }
76+
77+ if (particle.x >= this.canvas.width || particle.y >= this.canvas.height) {
78+ particle.x = 10;
79+ particle.y = 10;
80+ }
81+
82+ c.save();
83+ c.fillStyle = "hsl(190, 100%, 50%)";
84+ c.beginPath();
85+ c.arc(particle.x, particle.y, particle.size, 0, Math.PI * 2, true);
86+ c.fill();
87+ c.restore();
88+ });
89+
90+ window.onload = function () {
91+ ff.loop();
92+ };
93+ </script>
94+
95+</body
96+</html>
97+```
docs/flying-functions.html+10−5
@@ -97,11 +97,16 @@ worry about calling this contructor.</p> </td> <td class
9797
9898 <p>Usage: <code>new FlyingFunctions({ option: value, ... });</code></p>
9999
100-<p>options:
101- + fps = an integer between 1 and 60
102- + canvas = the convas html element
103- + c = the drawing context
104- + container = the container to which append the canvas</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">FlyingFunctions</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">opts</span><span class="p">)</span> <span class="p">{</span>
100+<p>options:</p>
101+
102+<pre><code> * fps = an integer between 1 and 60
103+
104+ * canvas = the convas html element
105+
106+ * c = the drawing context
107+
108+ * container = the container to which append the canvas
109+</code></pre> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">FlyingFunctions</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">opts</span><span class="p">)</span> <span class="p">{</span>
105110 <span class="nx">opts</span> <span class="o">=</span> <span class="nx">opts</span> <span class="o">||</span> <span class="p">{};</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-15">&#182;</a> </div> <p>defaults, mark them on the opts obj that gets passed to the
106111 <code>init</code> event.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">this</span><span class="p">.</span><span class="nx">fps</span> <span class="o">=</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">fps</span> <span class="o">||</span> <span class="mi">60</span><span class="p">;</span>
107112 <span class="k">this</span><span class="p">.</span><span class="nx">container</span> <span class="o">=</span> <span class="nx">opts</span><span class="p">.</span><span class="nx">container</span> <span class="o">||</span> <span class="nb">document</span><span class="p">.</span><span class="nx">querySelector</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="secti …
lib/flying-functions.js+8−4
@@ -131,10 +131,14 @@
131131 // Usage: `new FlyingFunctions({ option: value, ... });`
132132 //
133133 // options:
134- // + fps = an integer between 1 and 60
135- // + canvas = the convas html element
136- // + c = the drawing context
137- // + container = the container to which append the canvas
134+ //
135+ // * fps = an integer between 1 and 60
136+ //
137+ // * canvas = the convas html element
138+ //
139+ // * c = the drawing context
140+ //
141+ // * container = the container to which append the canvas
138142
139143 FlyingFunctions = function (opts) {
140144 opts = opts || {};