felflame 1.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.ruby-version +1 -0
- data/CHANGELOG.mdown +60 -5
- data/Gemfile +2 -3
- data/Gemfile.lock +4 -4
- data/README.mdown +127 -74
- data/Rakefile +30 -10
- data/bin/console +3 -3
- data/docs/FelFlame/ComponentManager.html +131 -519
- data/docs/FelFlame/Components.html +29 -119
- data/docs/FelFlame/Entities.html +125 -387
- data/docs/FelFlame/Order.html +251 -0
- data/docs/FelFlame/Scenes.html +72 -68
- data/docs/FelFlame/Stage.html +30 -56
- data/docs/FelFlame/Systems.html +208 -244
- data/docs/FelFlame.html +34 -32
- data/docs/Felflame_.html +143 -0
- data/docs/_index.html +24 -4
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +145 -83
- data/docs/file.version.html +74 -0
- data/docs/index.html +145 -83
- data/docs/method_list.html +52 -108
- data/docs/top-level-namespace.html +5 -5
- data/felflame.gemspec +22 -22
- data/lib/felflame/component_manager.rb +99 -71
- data/lib/felflame/entity_manager.rb +84 -59
- data/lib/felflame/order.rb +24 -0
- data/lib/felflame/scene_manager.rb +23 -12
- data/lib/felflame/stage_manager.rb +10 -33
- data/lib/felflame/system_manager.rb +92 -47
- data/lib/felflame/version.rb +5 -1
- data/lib/felflame.rb +23 -15
- metadata +34 -53
- data/.yardopts +0 -13
- data/codeclimate/env.rb +0 -1
- data/codeclimate/export-coverage.rb +0 -16
- data/codeclimate/test-reporter-latest-linux-amd64 +0 -0
- data/deprecated/components/00_renderable.rb +0 -19
- data/deprecated/components/01_sprite.rb +0 -57
- data/deprecated/components/02_label.rb +0 -32
- data/deprecated/components/03_player_control.rb +0 -26
- data/deprecated/components/04_map.rb +0 -21
- data/deprecated/components/05_interactable.rb +0 -16
- data/deprecated/components/06_collidable.rb +0 -22
- data/deprecated/components/07_battle.rb +0 -4
- data/deprecated/components/07_indoor.rb +0 -4
- data/deprecated/components/07_overworld.rb +0 -16
- data/deprecated/components/debug_singleton.rb +0 -13
- data/deprecated/helpers/00_tileset.rb +0 -56
- data/deprecated/helpers/01_component.rb +0 -74
- data/deprecated/systems/00_update_levels.rb +0 -34
- data/deprecated/systems/10_player.rb +0 -41
- data/deprecated/systems/99_render.rb +0 -37
- data/logos/felflame-logo-text.png +0 -0
- data/logos/felflame-logo-text.svg +0 -172
- data/logos/felflame-logo.png +0 -0
- data/logos/felflame-logo.svg +0 -97
data/docs/index.html
CHANGED
@@ -57,7 +57,9 @@
|
|
57
57
|
<div class="clear"></div>
|
58
58
|
</div>
|
59
59
|
|
60
|
-
<div id="content"><div id='filecontents'><p><img src="https://
|
60
|
+
<div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelFlame/master/logos/felflame-logo-text.png" alt="FelFlame"></p>
|
61
|
+
|
62
|
+
<!-- ![FelFlame](https://filestorage.catgirls.rodeo/images/felflame-logo-smaller-text.png) -->
|
61
63
|
|
62
64
|
<p><a href="https://codeclimate.com/github/realtradam/FelFlame/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a>
|
63
65
|
<a href="https://codeclimate.com/github/realtradam/FelFlame/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a>
|
@@ -65,16 +67,21 @@
|
|
65
67
|
<a href="https://github.com/realtradam/FelFlame/blob/master/LICENSE"><img src="https://img.shields.io/github/license/realtradam/FelFlame?label=license&style=flat" alt="MIT License"></a>
|
66
68
|
<a href="https://ko-fi.com/tradam"><img src="https://img.shields.io/static/v1?message=Buy%20me%20a%20coffee&logo=kofi&labelColor=ff5e5b&color=434B57&logoColor=white&label=%20" alt="Ko-Fi"></a></p>
|
67
69
|
|
70
|
+
<p><strong><a href="https://felflame.tradam.fyi/">Check out the comprehensive documentation here!</a></strong></p>
|
71
|
+
|
72
|
+
<hr>
|
73
|
+
|
68
74
|
<!-- vim-markdown-toc GFM -->
|
69
75
|
|
70
76
|
<ul>
|
71
77
|
<li><a href="#what-is-felflame">What is FelFlame?</a></li>
|
72
78
|
<li><a href="#what-is-ecs">What is ECS?</a>
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
* <a href="#components">Components</a>
|
80
|
+
* <a href="#entities">Entities</a>
|
81
|
+
* <a href="#systems">Systems</a>
|
82
|
+
* <a href="#scenes">Scenes</a>
|
83
|
+
* <a href="#stage">Stage</a>
|
84
|
+
* <a href="#order">Order</a></li>
|
78
85
|
<li><a href="#usage">Usage</a>
|
79
86
|
|
80
87
|
<ul>
|
@@ -83,8 +90,8 @@
|
|
83
90
|
<ul>
|
84
91
|
<li><a href="#creation">Creation</a></li>
|
85
92
|
<li><a href="#accessing">Accessing</a></li>
|
86
|
-
<li><a href="#get-id">Get ID</a></li>
|
87
93
|
<li><a href="#adding-and-removing-components">Adding and Removing Components</a></li>
|
94
|
+
<li><a href="#accessing-entities-attached-components">Accessing Entities' Attached Components</a></li>
|
88
95
|
<li><a href="#deletion">Deletion</a></li>
|
89
96
|
</ul></li>
|
90
97
|
<li><a href="#components-1">Components</a>
|
@@ -92,10 +99,10 @@
|
|
92
99
|
<ul>
|
93
100
|
<li><a href="#creating-a-component-manager">Creating a Component Manager</a></li>
|
94
101
|
<li><a href="#creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</a></li>
|
95
|
-
<li><a href="#accessing-
|
102
|
+
<li><a href="#accessing-1">Accessing</a></li>
|
96
103
|
<li><a href="#accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</a></li>
|
97
104
|
<li><a href="#deleting-components">Deleting Components</a></li>
|
98
|
-
<li><a href="#
|
105
|
+
<li><a href="#accessing-components-attached-entities">Accessing Components' attached Entities</a></li>
|
99
106
|
</ul></li>
|
100
107
|
<li><a href="#systems-1">Systems</a>
|
101
108
|
|
@@ -110,7 +117,7 @@
|
|
110
117
|
|
111
118
|
<ul>
|
112
119
|
<li><a href="#creation-2">Creation</a></li>
|
113
|
-
<li><a href="#accessing-
|
120
|
+
<li><a href="#accessing-2">Accessing</a></li>
|
114
121
|
<li><a href="#adding-systems">Adding Systems</a></li>
|
115
122
|
<li><a href="#removing-systems">Removing Systems</a></li>
|
116
123
|
<li><a href="#clearing">Clearing</a></li>
|
@@ -123,6 +130,11 @@
|
|
123
130
|
<li><a href="#removing-scenes">Removing Scenes</a></li>
|
124
131
|
<li><a href="#executing">Executing</a></li>
|
125
132
|
</ul></li>
|
133
|
+
<li><a href="#order-1">Order</a>
|
134
|
+
|
135
|
+
<ul>
|
136
|
+
<li><a href="#setting-the-order">Setting the order</a></li>
|
137
|
+
</ul></li>
|
126
138
|
<li><a href="#closing-notes">Closing Notes</a></li>
|
127
139
|
</ul></li>
|
128
140
|
<li><a href="#contribution">Contribution</a></li>
|
@@ -137,7 +149,7 @@
|
|
137
149
|
<ol>
|
138
150
|
<li><strong>Engine Agnostic:</strong> FelFlame has been designed to be rendering engine agnostic as long as the target rendering engine is written in Ruby. This means that this framework can be dropped into existing rendering engines such as <a href="http://www.ruby2d.com">Ruby2D</a> or <a href="https://dragonruby.org/toolkit/game">DRGTK</a> with little modifications.</li>
|
139
151
|
<li><strong>Easily Extensible:</strong> FelFlame has been designed such that extensions to its capabilities can be easily added. Extensions such as rendering engine wrappers, premade systems, premade components, etcetera can be easily coded and then distributed as gems.</li>
|
140
|
-
<li><strong>
|
152
|
+
<li><strong>Principle of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li>
|
141
153
|
</ol>
|
142
154
|
|
143
155
|
<h1 id="what-is-ecs">What is ECS?</h1>
|
@@ -163,7 +175,7 @@ ECS stands for Entity, Component, and System.</p>
|
|
163
175
|
|
164
176
|
<p>By using this pattern it allows programmers to easily control what an "object" or entity can do and how much data it needs to have. It avoids the issue of inhertance as no inhertance is ever required in this system. If you need a certain entity to have a certain functionality you just add the relevant component to it, and the systems that automatically go over specific components will give your entitiy the desired functionality. </p>
|
165
177
|
|
166
|
-
<p><strong>"But your framework also has <code>Scenes</code> and
|
178
|
+
<p><strong>"But your framework also has <code>Scenes</code>, <code>Stage</code>, and <code>Order</code>, what is that about?"</strong> </p>
|
167
179
|
|
168
180
|
<hr>
|
169
181
|
|
@@ -175,42 +187,47 @@ ECS stands for Entity, Component, and System.</p>
|
|
175
187
|
|
176
188
|
<p>The Stage is Scenes which are activated. This means any Scenes on the Stage are executed each frame, while the rest of the Systems are not.</p>
|
177
189
|
|
178
|
-
<
|
190
|
+
<h3 id="order">Order</h3>
|
179
191
|
|
180
|
-
<p>
|
192
|
+
<p>Order is a helper class which can set the priority of Scenes and Systems.</p>
|
193
|
+
|
194
|
+
<hr>
|
181
195
|
|
182
196
|
<h1 id="usage">Usage</h1>
|
183
197
|
|
198
|
+
<p>There are 2 ways of using FelFlame. You can either <code>include</code> it as a gem in your project if your game engine supports this. The other option is to download the single file export of FelFlame and then <code>require_relative</code> this file in your project. The single file export takes all the ruby code in the various files and concatenates them into a single file so it is more portable and easy to add.</p>
|
199
|
+
|
200
|
+
<p>To use the gem method you can do the following: install the gem using <code>gem install felflame</code> or using bundler <code>bundle add felflame</code> and then require it in your project like so: <code>require 'felflame'</code>.</p>
|
201
|
+
|
202
|
+
<p>To use the single file export method you simply download the felflame.rb file from the <a href="https://github.com/realtradam/FelFlame/releases">releases page on Github</a> and add it to your source folder and add a <code>require relative 'felflame.rb'</code> line or wherever you have placed the file to use it.</p>
|
203
|
+
|
184
204
|
<h2 id="entities">Entities</h2>
|
185
205
|
|
186
206
|
<h3 id="creation">Creation</h3>
|
187
207
|
|
188
208
|
<p>Entities are essentially "objects" in the game world. To create a new Entity we do the following:</p>
|
189
209
|
|
190
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
210
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span>
|
191
211
|
</code></pre>
|
192
212
|
|
193
|
-
<p>or if we want to add (any number of)components to it:</p>
|
213
|
+
<p>or if we want to add (any number of)components to it when creating it:</p>
|
194
214
|
|
195
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
196
|
-
|
197
|
-
|
215
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
216
|
+
<span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span>
|
217
|
+
<span class='ivar'>@component</span><span class='comma'>,</span>
|
218
|
+
<span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>EnemyTeam</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
219
|
+
<span class='rparen'>)</span>
|
198
220
|
</code></pre>
|
199
221
|
|
200
222
|
<h3 id="accessing">Accessing</h3>
|
201
223
|
|
202
|
-
<p>
|
224
|
+
<p>Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities.
|
225
|
+
If you need to you can access Entities using the <code>Entities</code> module:</p>
|
203
226
|
|
204
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
205
|
-
</
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
<p>Entity ID's are generated starting from 0 and ascending, unless if there is a missing ID because of a deleted
|
210
|
-
entity where a new entity will claim that ID. To get the ID of an Entity:</p>
|
211
|
-
|
212
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
|
213
|
-
</code></pre>
|
227
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
228
|
+
<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
229
|
+
<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can iterate over all entities this way. Any valid array method can be used
|
230
|
+
</span></code></pre>
|
214
231
|
|
215
232
|
<h3 id="adding-and-removing-components">Adding and Removing Components</h3>
|
216
233
|
|
@@ -220,9 +237,20 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p>
|
|
220
237
|
<span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='ivar'>@component</span>
|
221
238
|
</code></pre>
|
222
239
|
|
240
|
+
<h3 id="accessing-entities-attached-components">Accessing Entities' Attached Components</h3>
|
241
|
+
|
242
|
+
<p>This is the most common way of accessing an Entity</p>
|
243
|
+
|
244
|
+
<p>When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity:</p>
|
245
|
+
|
246
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># => [@component1, @component2, @component3]
|
247
|
+
</span></code></pre>
|
248
|
+
|
223
249
|
<h3 id="deletion">Deletion</h3>
|
224
250
|
|
225
|
-
<p>To have all Components from an Entity removed and the Entity deleted we do the following:</p>
|
251
|
+
<p>To have all Components from an Entity <strong>removed</strong> and the Entity deleted we do the following:</p>
|
252
|
+
|
253
|
+
<p>NOTE: The components will <strong>not be deleted</strong>. They are simply <strong>removed</strong> from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted.</p>
|
226
254
|
|
227
255
|
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
|
228
256
|
</code></pre>
|
@@ -234,7 +262,7 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p>
|
|
234
262
|
<p>Components are where all the data is stored. The data is stored in variables or accessors in each component.
|
235
263
|
These accessors and their defaults are configured when a component manager is created, like so:</p>
|
236
264
|
|
237
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
265
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span>
|
238
266
|
</code></pre>
|
239
267
|
|
240
268
|
<p>In this example we created a component manager called "Stats".
|
@@ -248,22 +276,21 @@ When defining attributes symbols should be used.</p>
|
|
248
276
|
|
249
277
|
<p>Now that we have a component manager we can make components from it like so:</p>
|
250
278
|
|
251
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
279
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
252
280
|
</code></pre>
|
253
281
|
|
254
|
-
<p>Or we can even
|
282
|
+
<p>Or we can even override the defaults when creating the component:</p>
|
255
283
|
|
256
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
284
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
257
285
|
</code></pre>
|
258
286
|
|
259
|
-
<h3 id="accessing
|
287
|
+
<h3 id="accessing">Accessing</h3>
|
260
288
|
|
261
|
-
<p>
|
262
|
-
These IDs are only unique within the scope of their respective Component Managers.
|
263
|
-
Here is how we can get the ID, as well as how to access a Component from its Component Manager.</p>
|
289
|
+
<p>You can access components using any array method.</p>
|
264
290
|
|
265
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
266
|
-
<span class='ivar'>@component</span><span class='
|
291
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
292
|
+
<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
293
|
+
<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can use iterators this way
|
267
294
|
</span></code></pre>
|
268
295
|
|
269
296
|
<h3 id="accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</h3>
|
@@ -276,24 +303,27 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p>
|
|
276
303
|
</code></pre>
|
277
304
|
|
278
305
|
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_hp'>hp</span> <span class='comment'># => 95
|
279
|
-
</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier
|
306
|
+
</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='comment'># => {armour: 'Leather', hp: 95}
|
280
307
|
</span></code></pre>
|
281
308
|
|
282
309
|
<h3 id="deleting-components">Deleting Components</h3>
|
283
310
|
|
284
|
-
<p>Deleting a Component is the same
|
311
|
+
<p>Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.</p>
|
285
312
|
|
286
313
|
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
|
287
314
|
</code></pre>
|
288
315
|
|
289
|
-
<h3 id="
|
316
|
+
<h3 id="accessing-components-attached-entities">Accessing Components' attached Entities</h3>
|
290
317
|
|
291
|
-
<p>
|
318
|
+
<p>Components also keep track of what Entities are using it. To access this list we do the following:</p>
|
292
319
|
|
293
|
-
<pre class="code ruby"><code class="ruby"><span class='
|
294
|
-
|
295
|
-
|
296
|
-
</
|
320
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span> <span class='comment'># => [@entity1, @entity2, @entity3]
|
321
|
+
</span>
|
322
|
+
<span class='comment'># get the first entity attached.
|
323
|
+
</span><span class='comment'># this will throw a warning if there is more or less then
|
324
|
+
</span><span class='comment'># exactly one entity
|
325
|
+
</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='comment'># => @entity
|
326
|
+
</span></code></pre>
|
297
327
|
|
298
328
|
<h2 id="systems">Systems</h2>
|
299
329
|
|
@@ -301,24 +331,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p>
|
|
301
331
|
|
302
332
|
<p>We can create Systems like so:</p>
|
303
333
|
|
304
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
334
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
305
335
|
<span class='comment'># Code and Logic
|
306
336
|
</span><span class='kw'>end</span>
|
307
337
|
</code></pre>
|
308
338
|
|
309
339
|
<p>The name we assign is how we can access the System, like so:</p>
|
310
340
|
|
311
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
341
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span>
|
312
342
|
</code></pre>
|
313
343
|
|
314
344
|
<p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>.
|
315
345
|
The lower the number, the earlier a given System will be executed.
|
316
|
-
E.g priority 1 will go first, priority 2 will go second, etcetera.
|
346
|
+
E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
347
|
+
|
348
|
+
<p>Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage.</p>
|
317
349
|
|
318
350
|
<p>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p>
|
319
351
|
|
320
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
321
|
-
<span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
352
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
353
|
+
<span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span>
|
322
354
|
<span class='comment'># do something with these components
|
323
355
|
</span> <span class='kw'>end</span>
|
324
356
|
<span class='kw'>end</span>
|
@@ -328,7 +360,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
328
360
|
|
329
361
|
<p>After we create a System, it won't do anything on its own until we tell it to. Here is how:</p>
|
330
362
|
|
331
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
363
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
332
364
|
</code></pre>
|
333
365
|
|
334
366
|
<p>Sometimes you might want to manually activate a System, but the more common way to have Systems be triggered is to use Scenes and the Stage or the alternative ways of execution.</p>
|
@@ -338,25 +370,25 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
338
370
|
<p>Sometimes you want a System to automatically trigger when a special even happens. FelFlame can keep track of when a Component is added, removed, or when an attribute is changed and then execute Systems linked to these events. Here is how to create these links:</p>
|
339
371
|
|
340
372
|
<pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called
|
341
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
373
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span>
|
342
374
|
|
343
375
|
<span class='comment'># When this Component is removed from an Entity, this System will be called
|
344
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
376
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span>
|
345
377
|
|
346
378
|
<span class='comment'># When this Component's health attribute is changed, this System will be called
|
347
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
379
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span>
|
348
380
|
</code></pre>
|
349
381
|
|
350
382
|
<p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p>
|
351
383
|
|
352
384
|
<pre class="code ruby"><code class="ruby"><span class='comment'># When a Component from this Component Manager is added to an Entity, this System will be called
|
353
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
385
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span>
|
354
386
|
|
355
387
|
<span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called
|
356
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
388
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span>
|
357
389
|
|
358
390
|
<span class='comment'># When this Component's health attribute from this Component Manager is changed, this System will be called
|
359
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
391
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span>
|
360
392
|
</code></pre>
|
361
393
|
|
362
394
|
<p>We can create any number of these links between Systems, Components, and Component Manangers as we like, simply call the method again with our other Components and Component Managers</p>
|
@@ -366,41 +398,41 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
366
398
|
<p>If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:</p>
|
367
399
|
|
368
400
|
<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system
|
369
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
401
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span>
|
370
402
|
|
371
403
|
<span class='comment'># clears ALL triggers with this Component Manager
|
372
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
404
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span>
|
373
405
|
|
374
406
|
<span class='comment'># clear the 'trigger_when_added' for this Component
|
375
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
407
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span>
|
376
408
|
|
377
409
|
<span class='comment'># clear the 'trigger_when_removed' for this Component
|
378
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
410
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span>
|
379
411
|
|
380
412
|
<span class='comment'># clear the 'trigger_when_is_set' for this Component specifically for the health attribute
|
381
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
413
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span>
|
382
414
|
</code></pre>
|
383
415
|
|
384
416
|
<p>Likewise we can do the same with Component Managers:</p>
|
385
417
|
|
386
418
|
<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component
|
387
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
419
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span>
|
388
420
|
|
389
421
|
<span class='comment'># clear the 'trigger_when_added' for this Component Manager
|
390
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
422
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span>
|
391
423
|
|
392
424
|
<span class='comment'># clear the 'trigger_when_removed' for this Component Manager
|
393
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
425
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span>
|
394
426
|
|
395
427
|
<span class='comment'># clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute
|
396
|
-
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
428
|
+
</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span>
|
397
429
|
</code></pre>
|
398
430
|
|
399
431
|
<h3 id="redefinition">Redefinition</h3>
|
400
432
|
|
401
433
|
<p>If we wanted to change what code or logic a given System executes, we could do that with:</p>
|
402
434
|
|
403
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
435
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span>
|
404
436
|
<span class='comment'># Some new logic or code
|
405
437
|
</span><span class='kw'>end</span>
|
406
438
|
</code></pre>
|
@@ -411,28 +443,36 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
411
443
|
|
412
444
|
<p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p>
|
413
445
|
|
414
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
446
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>5</span><span class='rparen'>)</span>
|
415
447
|
</code></pre>
|
416
448
|
|
417
449
|
<h3 id="accessing">Accessing</h3>
|
418
450
|
|
419
451
|
<p>Just like other classes in FelFlame, the name we gave the Scene is how we access it:</p>
|
420
452
|
|
421
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
453
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span>
|
422
454
|
</code></pre>
|
423
455
|
|
424
456
|
<h3 id="adding-systems">Adding Systems</h3>
|
425
457
|
|
426
458
|
<p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p>
|
427
459
|
|
428
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
460
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span>
|
461
|
+
<span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span>
|
462
|
+
<span class='ivar'>@system2</span><span class='comma'>,</span>
|
463
|
+
<span class='ivar'>@system3</span>
|
464
|
+
<span class='rparen'>)</span>
|
429
465
|
</code></pre>
|
430
466
|
|
431
467
|
<h3 id="removing-systems">Removing Systems</h3>
|
432
468
|
|
433
|
-
<p>Removing Systems works
|
469
|
+
<p>Removing Systems works similarly:</p>
|
434
470
|
|
435
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
471
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span>
|
472
|
+
<span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span>
|
473
|
+
<span class='ivar'>@system2</span><span class='comma'>,</span>
|
474
|
+
<span class='ivar'>@system3</span>
|
475
|
+
<span class='rparen'>)</span>
|
436
476
|
</code></pre>
|
437
477
|
|
438
478
|
<h3 id="clearing">Clearing</h3>
|
@@ -455,28 +495,50 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
455
495
|
|
456
496
|
<h3 id="adding-scenes">Adding Scenes</h3>
|
457
497
|
|
458
|
-
<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active
|
498
|
+
<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:</p>
|
459
499
|
|
460
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
500
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span>
|
461
501
|
</code></pre>
|
462
502
|
|
463
503
|
<h3 id="removing-scenes">Removing Scenes</h3>
|
464
504
|
|
465
505
|
<p>Likewise we can remove Scenes:</p>
|
466
506
|
|
467
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
507
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span>
|
468
508
|
</code></pre>
|
469
509
|
|
470
510
|
<h3 id="executing">Executing</h3>
|
471
511
|
|
472
|
-
<p>On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will
|
512
|
+
<p>On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it:</p>
|
513
|
+
|
514
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span>
|
515
|
+
</code></pre>
|
516
|
+
|
517
|
+
<h2 id="order">Order</h2>
|
518
|
+
|
519
|
+
<h3 id="setting-the-order">Setting the order</h3>
|
520
|
+
|
521
|
+
<p>To set the order you just need to call <code>FelFlame::Order.sort</code> and pass Scenes or Systems in the parameters in the order you wish for them to execute</p>
|
522
|
+
|
523
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span>
|
524
|
+
<span class='ivar'>@system1</span><span class='comma'>,</span>
|
525
|
+
<span class='ivar'>@system2</span><span class='comma'>,</span>
|
526
|
+
<span class='ivar'>@system3</span>
|
527
|
+
<span class='rparen'>)</span>
|
528
|
+
</code></pre>
|
529
|
+
|
530
|
+
<p>If you want some Scenes or Systems to have the same priority then just pass them as an array:</p>
|
473
531
|
|
474
|
-
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (
|
532
|
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span>
|
533
|
+
<span class='ivar'>@scene1</span><span class='comma'>,</span>
|
534
|
+
<span class='lbracket'>[</span><span class='ivar'>@scene2_1</span><span class='comma'>,</span> <span class='ivar'>@scene2_2</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
535
|
+
<span class='ivar'>@scene3</span>
|
536
|
+
<span class='rparen'>)</span>
|
475
537
|
</code></pre>
|
476
538
|
|
477
539
|
<h2 id="closing-notes">Closing Notes</h2>
|
478
540
|
|
479
|
-
<p>There are some methods I haven't gone over in the overview. If you want to see everything and read in more detail check out the <a href="https://
|
541
|
+
<p>There are some methods I haven't gone over in the overview. If you want to see everything and read in more detail check out the <a href="https://felflame.tradam.fyi">Documentation</a>!</p>
|
480
542
|
|
481
543
|
<h1 id="contribution">Contribution</h1>
|
482
544
|
|
@@ -488,7 +550,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
488
550
|
</div></div>
|
489
551
|
|
490
552
|
<div id="footer">
|
491
|
-
Generated on
|
553
|
+
Generated on Mon Jan 3 08:23:03 2022 by
|
492
554
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
493
555
|
0.9.26 (ruby-2.7.3).
|
494
556
|
</div>
|