felflame 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ee6a6d8fe61bacc1e817ae7449c6633eb62a6d0a1e2eeb6ba1d1fa1f496e1fa
4
- data.tar.gz: 7ce0a798ba4a83c09b452ec7fbc939ff77299d15123dc10a00ddb98b43f5cff9
3
+ metadata.gz: edb62769a2de8d0770e86a9e1462acf08f0212adcfb5022e77976f787bd8d04f
4
+ data.tar.gz: 0e6b390b1c35c6ace23cc296dc30aac9389b35fe47a01b31a32aa3375b320f96
5
5
  SHA512:
6
- metadata.gz: bb597222ff5805c3469ef6470efdc0fab3a87889225eb2272d327395cbd483111bf71d196310eb697bce65afb499cb196ac7ac3ba925f1fda84f9be9768d9852
7
- data.tar.gz: 8025a3a8774bf7cfa8cb34b4ba97cbd11d036085573e780c30b2c2ab047996a661be65038c7d64e9bc9210a8d6d8d4d7c096a0af9d08dedb56df707b14f2b204
6
+ metadata.gz: 8e5dc06f74e3cca7da3a1fe93359adee2d224e027156c5d9f1047d21895a3c96791c0f8907fdbf30496b4256be04d645b6f2fd8a8bb69b9a8a2220defcd96b9c
7
+ data.tar.gz: 9a61a13a77b2ac6196a5405bb614971212bde523f59f85826ef0a4839f78b255947e97ec19c80745df248e90c78bc97589a963f46c609794c41af32fdd4caaa9
data/.rubocop.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.7
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
6
- EnforcedStyle: double_quotes
6
+ EnforcedStyle: single_quotes
7
7
 
8
8
  Style/StringLiteralsInInterpolation:
9
9
  Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/CHANGELOG.mdown CHANGED
@@ -8,46 +8,66 @@
8
8
  ![Deprecated](https://img.shields.io/badge/-Deprecated-orange)
9
9
  ![Removed](https://img.shields.io/badge/-Removed-red)
10
10
 
11
- ## [3.0.0](https://github.com/realtradam/FelFlame/releases/tag/3.0.0) - 2021-07-12
11
+ ## [4.0.0](https://github.com/realtradam/FelFlame/releases/tag/4.0.0) - 2021-12-30
12
+ ![Removed](https://img.shields.io/badge/-Removed-red)
13
+ - Removed all ids as they were not used
14
+
12
15
  ![Changed](https://img.shields.io/badge/-Changed-yellow)
13
- - The Scene alias was changed from ```FelFlame::Sce``` to ```FelFlame::Scn``` as it is more intuitive.
16
+ - Scenes now have their own priority attribute
17
+ - Stages now sort and execute by Scenes, rather then the net Systems in the Scenes
18
+ - Component method `.attrs` was renamed to `.to_h`
19
+ - Renamed the `data` accessor to `._data`
20
+ - Various arrays are automatically compacted
21
+
22
+ ![Added](https://img.shields.io/badge/-Added-brightgreen)
23
+ - Classes and Modules which used a data array now have the entire set of array methods available to their respective Classes and Modules
24
+ - Convenience methods for accessing a single entity in a component(`@component.entity`) and accessing a single entity in a component(`@entity.component[@component_manager]`)
25
+ - `FelFlame::Order` class which can set the order if your Scenes and Systems
26
+
27
+ ![Fixed](https://img.shields.io/badge/-Fixed-blue)
28
+ - Replaced all instances of `sort_by!` with `sort_by` for compatibility with mruby
29
+ - Minor optimizations such as less array duplication
30
+
31
+ ## [3.0.0](https://github.com/realtradam/FelFlame/releases/tag/3.0.0) - 2021-07-12
32
+ ![Changed](https://img.shields.io/badge/-Changed-yellow)
33
+ - The Scene alias was changed from ```FelFlame::Sce``` to ```FelFlame::Scn``` as it is more intuitive
14
34
 
15
35
  ## [2.0.0](https://github.com/realtradam/FelFlame/releases/tag/2.0.0) - 2021-07-10
16
- ![Changed](https://img.shields.io/badge/-Changed-yellow)
17
- - Entities and Components now reference each other using the objects themselves rather then their id's
18
- ```ruby
36
+ ![Changed](https://img.shields.io/badge/-Changed-yellow)
37
+ - Entities and Components now reference each other using the objects themselves rather then their id's
38
+ ```ruby
19
39
  # before:
20
- @entity.components[@component_manager].each do |component_id|
21
- # iterate over id's, usually would need to do a lookup to get the component itself
22
- end
40
+ @entity.components[@component_manager].each do |component_id|
41
+ # iterate over id's, usually would need to do a lookup to get the component itself
42
+ end
23
43
 
24
44
  # after:
25
- @entity.components[@component_manager].each do |component|
26
- # iterate over the components themselves! No need for lookup anymore
27
- end
28
- ```
29
- ```ruby
45
+ @entity.components[@component_manager].each do |component|
46
+ # iterate over the components themselves! No need for lookup anymore
47
+ end
48
+ ```
49
+ ```ruby
30
50
  # same for components referencing entities
31
51
  # before:
32
- @component.entities.each do |entity_id|
33
- #iterate over id's
34
- end
52
+ @component.entities.each do |entity_id|
53
+ #iterate over id's
54
+ end
35
55
 
36
56
  # after:
37
- @component.entities.each do |entity|
38
- # directly iterate over entities themselves!
39
- end
40
- ```
41
-
57
+ @component.entities.each do |entity|
58
+ # directly iterate over entities themselves!
59
+ end
60
+ ```
61
+
42
62
 
43
63
  ## [1.0.2](https://github.com/realtradam/FelFlame/releases/tag/1.0.2) - 2021-07-09
44
- ![Fixed](https://img.shields.io/badge/-Fixed-blue)
45
- - Stripped superflous files shrinking gem size significantly
64
+ ![Fixed](https://img.shields.io/badge/-Fixed-blue)
65
+ - Stripped superflous files shrinking gem size significantly
46
66
 
47
67
  ## [1.0.1](https://github.com/realtradam/FelFlame/releases/tag/1.0.1) - 2021-07-09
48
- ![Fixed](https://img.shields.io/badge/-Fixed-blue)
49
- - Defining attributes in components are no longer allowed to overwrite methods
68
+ ![Fixed](https://img.shields.io/badge/-Fixed-blue)
69
+ - Defining attributes in components are no longer allowed to overwrite methods
50
70
 
51
71
  ## [1.0.0](https://github.com/realtradam/FelFlame/releases/tag/1.0.0) - 2021-07-09
52
- ![Added](https://img.shields.io/badge/-Added-brightgreen)
53
- - Initial release
72
+ ![Added](https://img.shields.io/badge/-Added-brightgreen)
73
+ - Initial release
data/Gemfile CHANGED
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in felflame.gemspec
6
6
  gemspec
7
7
 
8
8
  ruby '2.7.3'
9
9
 
10
- gem "rake", "~> 13.0"
11
-
10
+ gem 'rake', '~> 13.0'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- felflame (3.0.0)
4
+ felflame (4.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.mdown CHANGED
@@ -1,5 +1,5 @@
1
-
2
- ![FelFlame](https://filestorage.catgirls.rodeo/images/felflame-logo-smaller-text.png)
1
+ ![FelFlame](https://raw.githubusercontent.com/realtradam/FelFlame/master/logos/felflame-logo-text.png)
2
+ <!-- ![FelFlame](https://filestorage.catgirls.rodeo/images/felflame-logo-smaller-text.png) -->
3
3
 
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability)](https://codeclimate.com/github/realtradam/FelFlame/maintainability)
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage)](https://codeclimate.com/github/realtradam/FelFlame/test_coverage)
@@ -13,48 +13,49 @@
13
13
 
14
14
  <!-- vim-markdown-toc GFM -->
15
15
 
16
- + [What is FelFlame?](#what-is-felflame)
17
- + [What is ECS?](#what-is-ecs)
18
- - [Components](#components)
19
- - [Entities](#entities)
20
- - [Systems](#systems)
21
- - [Scenes](#scenes)
22
- - [Stage](#stage)
23
- + [Usage](#usage)
16
+ * [What is FelFlame?](#what-is-felflame)
17
+ * [What is ECS?](#what-is-ecs)
18
+ * [Components](#components)
19
+ * [Entities](#entities)
20
+ * [Systems](#systems)
21
+ * [Scenes](#scenes)
22
+ * [Stage](#stage)
23
+ * [Order](#order)
24
+ * [Usage](#usage)
24
25
  * [Entities](#entities-1)
25
- - [Creation](#creation)
26
- - [Accessing](#accessing)
27
- - [Get ID](#get-id)
28
- - [Adding and Removing Components](#adding-and-removing-components)
29
- - [Accessing Entities' Attached Components](#accessing-entities-attached-components)
30
- - [Deletion](#deletion)
26
+ * [Creation](#creation)
27
+ * [Accessing](#accessing)
28
+ * [Adding and Removing Components](#adding-and-removing-components)
29
+ * [Accessing Entities' Attached Components](#accessing-entities-attached-components)
30
+ * [Deletion](#deletion)
31
31
  * [Components](#components-1)
32
- - [Creating a Component Manager](#creating-a-component-manager)
33
- - [Creating a Component from a Component Manager](#creating-a-component-from-a-component-manager)
34
- - [Accessing and Getting ID](#accessing-and-getting-id)
35
- - [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them)
36
- - [Deleting Components](#deleting-components)
37
- - [Iterating over Components](#iterating-over-components)
38
- - [Accessing Components' attached Entities](#accessing-components-attached-entities)
32
+ * [Creating a Component Manager](#creating-a-component-manager)
33
+ * [Creating a Component from a Component Manager](#creating-a-component-from-a-component-manager)
34
+ * [Accessing](#accessing-1)
35
+ * [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them)
36
+ * [Deleting Components](#deleting-components)
37
+ * [Accessing Components' attached Entities](#accessing-components-attached-entities)
39
38
  * [Systems](#systems-1)
40
- - [Creation](#creation-1)
41
- - [Execution](#execution)
42
- - [Alternative Execution](#alternative-execution)
43
- - [Clearing Alternative Executions](#clearing-alternative-executions)
44
- - [Redefinition](#redefinition)
39
+ * [Creation](#creation-1)
40
+ * [Execution](#execution)
41
+ * [Alternative Execution](#alternative-execution)
42
+ * [Clearing Alternative Executions](#clearing-alternative-executions)
43
+ * [Redefinition](#redefinition)
45
44
  * [Scenes](#scenes-1)
46
- - [Creation](#creation-2)
47
- - [Accessing](#accessing-1)
48
- - [Adding Systems](#adding-systems)
49
- - [Removing Systems](#removing-systems)
50
- - [Clearing](#clearing)
51
- - [Execution](#execution-1)
45
+ * [Creation](#creation-2)
46
+ * [Accessing](#accessing-2)
47
+ * [Adding Systems](#adding-systems)
48
+ * [Removing Systems](#removing-systems)
49
+ * [Clearing](#clearing)
50
+ * [Execution](#execution-1)
52
51
  * [Stage](#stage-1)
53
- - [Adding Scenes](#adding-scenes)
54
- - [Removing Scenes](#removing-scenes)
55
- - [Executing](#executing)
52
+ * [Adding Scenes](#adding-scenes)
53
+ * [Removing Scenes](#removing-scenes)
54
+ * [Executing](#executing)
55
+ * [Order](#order-1)
56
+ * [Setting the order](#setting-the-order)
56
57
  * [Closing Notes](#closing-notes)
57
- + [Contribution](#contribution)
58
+ * [Contribution](#contribution)
58
59
 
59
60
  <!-- vim-markdown-toc -->
60
61
 
@@ -64,7 +65,7 @@ FelFlame is an ECS framework for developing games in the Ruby language. FelFlame
64
65
 
65
66
  1. **Engine Agnostic:** 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 [Ruby2D](http://www.ruby2d.com) or [DRGTK](https://dragonruby.org/toolkit/game) with little modifications.
66
67
  2. **Easily Extensible:** 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.
67
- 3. **Priciple of (My) Least Astonishment:** I want to develop games using a language and framework I love and makes sense to me, inspired by the [Philosophy of the creator of Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy).
68
+ 3. **Principle of (My) Least Astonishment:** I want to develop games using a language and framework I love and makes sense to me, inspired by the [Philosophy of the creator of Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy).
68
69
 
69
70
  # What is ECS?
70
71
  ECS is a software architectural pattern that is used in video game development. Traditionally games were programmed using an object oriented method, while ECS instead attempts to program games using a data oriented method instead.
@@ -85,7 +86,7 @@ Systems are where all the logic or code is kept. There is no data stored in here
85
86
 
86
87
  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.
87
88
 
88
- **"But your framework also has `Scenes` and a `Stage`, what is that about?"**
89
+ **"But your framework also has `Scenes`, `Stage`, and `Order`, what is that about?"**
89
90
 
90
91
  ---
91
92
 
@@ -95,13 +96,19 @@ Scenes are simply a collection or subset of Systems. This allows for an easy way
95
96
  ### Stage
96
97
  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.
97
98
 
99
+ ### Order
100
+ Order is a helper class which can set the priority of Scenes and Systems.
101
+
98
102
  ---
99
103
 
100
- If all of this sounds very confusing, don't worry. A video tutorial series is in the works where I will build a game using this framework and explain every step of the way. You can also read some examples and explanations below.
101
104
 
102
105
  # Usage
103
106
 
104
- To use FelFlame simply install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`. Working outside of the gem for rendering engines that do not support the usage of gems is a planned feature in the works.
107
+ There are 2 ways of using FelFlame. You can either `include` 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 `require_relative` 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.
108
+
109
+ To use the gem method you can do the following: install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`.
110
+
111
+ To use the single file export method you simply download the felflame.rb file from the [releases page on Github](https://github.com/realtradam/FelFlame/releases) and add it to your source folder and add a `require relative 'felflame.rb'` line or wherever you have placed the file to use it.
105
112
 
106
113
  ## Entities
107
114
 
@@ -111,29 +118,24 @@ Entities are essentially "objects" in the game world. To create a new Entity we
111
118
  ```ruby
112
119
  @entity = FelFlame::Entities.new
113
120
  ```
114
- or if we want to add (any number of)components to it:
121
+ or if we want to add (any number of)components to it when creating it:
115
122
 
116
123
  ```ruby
117
124
  @entity = FelFlame::Entites.new(
118
125
  FelFlame::Components::Health.new,
119
126
  @component,
120
- FelFlame::Components::Armour[7]
127
+ FelFlame::Components::EnemyTeam.first
121
128
  )
122
129
  ```
123
130
 
124
131
  ### Accessing
125
- Once components are created we can access them using their ID like so:
132
+ Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities.
133
+ If you need to you can access Entities using the `Entities` module:
126
134
 
127
135
  ```ruby
128
136
  @entity = FelFlame::Entities[2]
129
- ```
130
-
131
- ### Get ID
132
- Entity ID's are generated starting from 0 and ascending, unless if there is a missing ID because of a deleted
133
- entity where a new entity will claim that ID. To get the ID of an Entity:
134
-
135
- ```ruby
136
- @entity.id
137
+ @entity = FelFlame::Entities.first
138
+ @entity = FelFlame::Entities.each # you can iterate over all entities this way. Any valid array method can be used
137
139
  ```
138
140
 
139
141
  ### Adding and Removing Components
@@ -145,14 +147,18 @@ We can still add or remove Components from an Entity after it has been created.
145
147
  ```
146
148
 
147
149
  ### Accessing Entities' Attached Components
150
+ This is the most common way of accessing an Entity
151
+
148
152
  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:
149
153
 
150
154
  ```ruby
151
- @entity.components[@component_manager] # => [@component1, @component2, component3]
155
+ @entity.components[@component_manager] # => [@component1, @component2, @component3]
152
156
  ```
153
157
 
154
158
  ### Deletion
155
- To have all Components from an Entity removed and the Entity deleted we do the following:
159
+ To have all Components from an Entity **removed** and the Entity deleted we do the following:
160
+
161
+ NOTE: The components will **not be deleted**. They are simply **removed** 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.
156
162
 
157
163
  ```ruby
158
164
  @entity.delete
@@ -182,20 +188,19 @@ Now that we have a component manager we can make components from it like so:
182
188
  @component = FelFlame::Components::Stats.new
183
189
  ```
184
190
 
185
- Or we can even change the defaults:
191
+ Or we can even override the defaults when creating the component:
186
192
 
187
193
  ```ruby
188
194
  @component = FelFlame::Components::Stats.new(armour: 'steel')
189
195
  ```
190
196
 
191
- ### Accessing and Getting ID
192
- Just like Entities, Components have IDs.
193
- These IDs are only unique within the scope of their respective Component Managers.
194
- Here is how we can get the ID, as well as how to access a Component from its Component Manager.
197
+ ### Accessing
198
+ You can access components using any array method.
195
199
 
196
200
  ```ruby
197
201
  @component = FelFlame::Components::Stats[2]
198
- @component.id # => 2
202
+ @component = FelFlame::Components::Stats.first
203
+ @component = FelFlame::Components::Stats.each # you can use iterators this way
199
204
  ```
200
205
 
201
206
  ### Accessing Attributes and Changing Them
@@ -207,30 +212,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them.
207
212
  ```
208
213
  ```ruby
209
214
  @component.hp # => 95
210
- @component.attrs # => {armour: 'Leather', hp: 95}
215
+ @component.to_h # => {armour: 'Leather', hp: 95}
211
216
  ```
212
217
 
213
218
  ### Deleting Components
214
- Deleting a Component is the same format as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.
219
+ 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.
215
220
 
216
221
  ```ruby
217
222
  @component.delete
218
223
  ```
219
224
 
220
- ### Iterating over Components
221
- When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:
222
-
223
- ```ruby
224
- FelFlame::Components::Sprites.each do |component|
225
- #do something with components
226
- end
227
- ```
228
-
229
225
  ### Accessing Components' attached Entities
230
226
  Components also keep track of what Entities are using it. To access this list we do the following:
231
227
 
232
228
  ```ruby
233
229
  @component.entities # => [@entity1, @entity2, @entity3]
230
+
231
+ # get the first entity attached.
232
+ # this will throw a warning if there is more or less then
233
+ # exactly one entity
234
+ @component.entity # => @entity
234
235
  ```
235
236
 
236
237
 
@@ -240,7 +241,7 @@ Components also keep track of what Entities are using it. To access this list we
240
241
  We can create Systems like so:
241
242
 
242
243
  ```ruby
243
- FelFlame::Systems.new(name: 'Render', priority: 2) do
244
+ FelFlame::Systems.new('Render', priority: 2) do
244
245
  # Code and Logic
245
246
  end
246
247
  ```
@@ -252,12 +253,14 @@ FelFlame::Systems::Render
252
253
  ```
253
254
  Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`.
254
255
  The lower the number, the earlier a given System will be executed.
255
- E.g priority 1 will go first, priority 2 will go second, etcetera.
256
+ E.g priority 1 will go first, priority 2 will go second, etcetera.
257
+
258
+ 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.
256
259
 
257
260
  Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:
258
261
 
259
262
  ```ruby
260
- FelFlame::Systems.new(name: 'Render', priority: 2) do
263
+ FelFlame::Systems.new('Render', priority: 2) do
261
264
  FelFlame::Components::Sprites.each do |component|
262
265
  # do something with these components
263
266
  end
@@ -355,7 +358,7 @@ end
355
358
  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 [Alternative Executions](#alternative-execution) will occur even if they are not part of a Scene. Here is how we make a new Scene:
356
359
 
357
360
  ```ruby
358
- @scene = FelFlame::Scenes.new('ExampleScene')
361
+ @scene = FelFlame::Scenes.new('ExampleScene', priority: 5)
359
362
  ```
360
363
 
361
364
  ### Accessing
@@ -369,14 +372,22 @@ Just like other classes in FelFlame, the name we gave the Scene is how we access
369
372
  Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:
370
373
 
371
374
  ```ruby
372
- FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
375
+ FelFlame::Scenes::ExampleScene.add(
376
+ FelFlame::Systems::Render,
377
+ @system2,
378
+ @system3
379
+ )
373
380
  ```
374
381
 
375
382
  ### Removing Systems
376
- Removing Systems works simularly:
383
+ Removing Systems works similarly:
377
384
 
378
385
  ```ruby
379
- FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
386
+ FelFlame::Scenes::ExampleScene.remove(
387
+ FelFlame::Systems::Render,
388
+ @system2,
389
+ @system3
390
+ )
380
391
  ```
381
392
 
382
393
  ### Clearing
@@ -398,7 +409,7 @@ The Scene will make sure that the systems are executed in the correct order base
398
409
  ## Stage
399
410
 
400
411
  ### Adding Scenes
401
- 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:
412
+ 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:
402
413
 
403
414
  ```ruby
404
415
  FelFlame::Stage.add FelFlame::Scene::ExampleScene
@@ -412,12 +423,36 @@ FelFlame::Stage.remove FelFlame::Scene::ExampleScene
412
423
  ```
413
424
 
414
425
  ### Executing
415
- 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 make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:
426
+ 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:
416
427
 
417
428
  ```ruby
418
429
  FelFlame::Stage.call
419
430
  ```
420
431
 
432
+ ## Order
433
+
434
+ ### Setting the order
435
+
436
+ To set the order you just need to call `FelFlame::Order.sort` and pass Scenes or Systems in the parameters in the order you wish for them to execute
437
+
438
+ ```ruby
439
+ FelFlame::Order.sort(
440
+ @system1,
441
+ @system2,
442
+ @system3
443
+ )
444
+ ```
445
+
446
+ If you want some Scenes or Systems to have the same priority then just pass them as an array:
447
+
448
+ ```ruby
449
+ FelFlame::Order.sort(
450
+ @scene1,
451
+ [@scene2_1, @scene2_2],
452
+ @scene3
453
+ )
454
+ ```
455
+
421
456
  ## Closing Notes
422
457
 
423
458
  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 [Documentation](https://felflame.tradam.fyi)!
data/Rakefile CHANGED
@@ -1,15 +1,35 @@
1
1
  # frozen_string_literal: true
2
- #
2
+
3
3
  require 'rubygems'
4
4
  require 'bundler/setup'
5
5
  require 'rspec/core/rake_task'
6
6
  require 'yard'
7
7
  require_relative './codeclimate/export-coverage'
8
- require "bundler/gem_tasks"
9
- require "rubocop/rake_task"
8
+ require 'bundler/gem_tasks'
9
+ require 'rubocop/rake_task'
10
+
11
+ task default: [:spec, :yard, 'coverage:format']
12
+ # task default: :rubocop
13
+
14
+ desc 'Export to single file'
15
+ task :buildfile do
16
+ result = ''
17
+ main = File.read('lib/felflame.rb')
18
+ tmp = main.lines(chomp: true).select do |line|
19
+ line.include? 'require_relative '
20
+ end
21
+ tmp.each do |file|
22
+ file.delete_prefix!('require_relative ')
23
+ result += "#{File.read("lib/#{file[1, file.length - 2]}.rb")}\n"
24
+ end
10
25
 
11
- task :default => [:spec, :yard, 'coverage:format']
12
- #task default: :rubocop
26
+ result += main.lines.reject do |line|
27
+ line.include? 'require_relative '
28
+ end.join
29
+
30
+ `mkdir pkg`
31
+ File.write('pkg/felflame.rb', result)
32
+ end
13
33
 
14
34
  RuboCop::RakeTask.new
15
35
 
@@ -31,15 +51,15 @@ YARD::Rake::YardocTask.new do |t|
31
51
  t.stats_options = ['--list-undoc']
32
52
  end
33
53
 
34
- #Rake::TestTask.new do |t|
54
+ # Rake::TestTask.new do |t|
35
55
  # t.pattern = "tests/**/*_test.rb"
36
- #end
56
+ # end
37
57
 
38
58
  RSpec::Core::RakeTask.new :spec
39
59
 
40
60
  # For installing FelPacks
41
- #Gem::Specification.find_all.each do |a_gem|
61
+ # Gem::Specification.find_all.each do |a_gem|
42
62
  # next unless a_gem.name.include? 'felpack-'
43
63
  #
44
64
  # Dir.glob("#{a_gem.gem_dir}/lib/#{a_gem.name.gsub('-', '/')}/tasks/*.rake").each { |r| load r }
45
- #end
65
+ # end
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
- require "felflame"
4
+ require 'bundler/setup'
5
+ require 'felflame'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require "felflame"
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- require "irb"
14
+ require 'irb'
15
15
  IRB.start(__FILE__)