felflame 1.0.2 → 4.0.1

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: a10a67367ed82f81778fdb4946bcc1ec194dee19a19c0ee53c1be30f328b656c
4
- data.tar.gz: 5dff54e3aaaad691500f5defdf4e674fc91faef4212384791f19bb121da3c593
3
+ metadata.gz: cec067b89ac14359b45b79e06fecca67e8d7f48eb30f1ce81e799b0a0e2fe589
4
+ data.tar.gz: ab4dad9aad4b318e95e536d68997903c0827b94c350c49ce2cc848d2aa446542
5
5
  SHA512:
6
- metadata.gz: 7512900c4a57805afff43f24278a2c059636c86c5f24ffe074635e46cb2354b2cd594293ebbaa11c84e1e481ac0635cebcb49ce2e5183a8adaf6aca41cb2de31
7
- data.tar.gz: ced3d47fdcaac44059fa5a4fd256e6ec4dea180d012a970e42f805a266b8edba4f0c4c44c14ede3de580f0e4c15c00c4ece7f064c000ebe6d6292fd37eeab9a3
6
+ metadata.gz: d93839605990768797fa65d9bd2b3f66b9a1dc79f53a26a1a9aa6ff7147b128a3715a1f35270ddecd26e979e306edf7166566a733089e7a1311396506a4a7e11
7
+ data.tar.gz: bd63c7c26f97f8387b3b9eb717d60e6ce6197b8b20f58b75ade45e17a114118716552a7e75833854ea44094c42c3b66d29dfa7deeed2ff43b1901ab419717616
data/.rubocop.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.5
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,11 +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
+ ## [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
+
15
+ ![Changed](https://img.shields.io/badge/-Changed-yellow)
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 of 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.
34
+
35
+ ## [2.0.0](https://github.com/realtradam/FelFlame/releases/tag/2.0.0) - 2021-07-10
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
39
+ # before:
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
43
+
44
+ # after:
45
+ @entity.components[@component_manager].each do |component|
46
+ # iterate over the components themselves! No need for lookup anymore
47
+ end
48
+ ```
49
+ ```ruby
50
+ # same for components referencing entities
51
+ # before:
52
+ @component.entities.each do |entity_id|
53
+ #iterate over id's
54
+ end
55
+
56
+ # after:
57
+ @component.entities.each do |entity|
58
+ # directly iterate over entities themselves!
59
+ end
60
+ ```
61
+
62
+
63
+ ## [1.0.2](https://github.com/realtradam/FelFlame/releases/tag/1.0.2) - 2021-07-09
64
+ ![Fixed](https://img.shields.io/badge/-Fixed-blue)
65
+ - Stripped superflous files shrinking gem size significantly
66
+
11
67
  ## [1.0.1](https://github.com/realtradam/FelFlame/releases/tag/1.0.1) - 2021-07-09
12
68
  ![Fixed](https://img.shields.io/badge/-Fixed-blue)
13
69
  - Defining attributes in components are no longer allowed to overwrite methods
14
70
 
15
71
  ## [1.0.0](https://github.com/realtradam/FelFlame/releases/tag/1.0.0) - 2021-07-09
16
-
17
72
  ![Added](https://img.shields.io/badge/-Added-brightgreen)
18
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 (1.0.2)
4
+ felflame (4.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -18,10 +18,10 @@ GEM
18
18
  minitest (>= 5.0)
19
19
  ruby-progressbar
20
20
  parallel (1.20.1)
21
- parser (3.0.1.1)
21
+ parser (3.0.2.0)
22
22
  ast (~> 2.4.1)
23
23
  rainbow (3.0.0)
24
- rake (13.0.3)
24
+ rake (13.0.6)
25
25
  redcarpet (3.5.1)
26
26
  regexp_parser (2.1.1)
27
27
  rexml (3.2.5)
@@ -38,7 +38,7 @@ GEM
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
39
  rspec-support (~> 3.10.0)
40
40
  rspec-support (3.10.2)
41
- rubocop (1.17.0)
41
+ rubocop (1.18.3)
42
42
  parallel (~> 1.10)
43
43
  parser (>= 3.0.0.0)
44
44
  rainbow (>= 2.2.2, < 4.0)
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,46 +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
- - [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)
30
31
  * [Components](#components-1)
31
- - [Creating a Component Manager](#creating-a-component-manager)
32
- - [Creating a Component from a Component Manager](#creating-a-component-from-a-component-manager)
33
- - [Accessing and Getting ID](#accessing-and-getting-id)
34
- - [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them)
35
- - [Deleting Components](#deleting-components)
36
- - [Iterating over Components](#iterating-over-components)
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)
37
38
  * [Systems](#systems-1)
38
- - [Creation](#creation-1)
39
- - [Execution](#execution)
40
- - [Alternative Execution](#alternative-execution)
41
- - [Clearing Alternative Executions](#clearing-alternative-executions)
42
- - [Redefinition](#redefinition)
39
+ * [Creation](#creation-1)
40
+ * [Execution](#execution)
41
+ * [Alternative Execution](#alternative-execution)
42
+ * [Clearing Alternative Executions](#clearing-alternative-executions)
43
+ * [Redefinition](#redefinition)
43
44
  * [Scenes](#scenes-1)
44
- - [Creation](#creation-2)
45
- - [Accessing](#accessing-1)
46
- - [Adding Systems](#adding-systems)
47
- - [Removing Systems](#removing-systems)
48
- - [Clearing](#clearing)
49
- - [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)
50
51
  * [Stage](#stage-1)
51
- - [Adding Scenes](#adding-scenes)
52
- - [Removing Scenes](#removing-scenes)
53
- - [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)
54
57
  * [Closing Notes](#closing-notes)
55
- + [Contribution](#contribution)
58
+ * [Contribution](#contribution)
56
59
 
57
60
  <!-- vim-markdown-toc -->
58
61
 
@@ -62,7 +65,7 @@ FelFlame is an ECS framework for developing games in the Ruby language. FelFlame
62
65
 
63
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.
64
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.
65
- 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).
66
69
 
67
70
  # What is ECS?
68
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.
@@ -83,7 +86,7 @@ Systems are where all the logic or code is kept. There is no data stored in here
83
86
 
84
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.
85
88
 
86
- **"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?"**
87
90
 
88
91
  ---
89
92
 
@@ -93,13 +96,19 @@ Scenes are simply a collection or subset of Systems. This allows for an easy way
93
96
  ### Stage
94
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.
95
98
 
99
+ ### Order
100
+ Order is a helper class which can set the priority of Scenes and Systems.
101
+
96
102
  ---
97
103
 
98
- 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.
99
104
 
100
105
  # Usage
101
106
 
102
- 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.
103
112
 
104
113
  ## Entities
105
114
 
@@ -109,29 +118,24 @@ Entities are essentially "objects" in the game world. To create a new Entity we
109
118
  ```ruby
110
119
  @entity = FelFlame::Entities.new
111
120
  ```
112
- 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:
113
122
 
114
123
  ```ruby
115
124
  @entity = FelFlame::Entites.new(
116
125
  FelFlame::Components::Health.new,
117
126
  @component,
118
- FelFlame::Components::Armour[7]
127
+ FelFlame::Components::EnemyTeam.first
119
128
  )
120
129
  ```
121
130
 
122
131
  ### Accessing
123
- 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:
124
134
 
125
135
  ```ruby
126
136
  @entity = FelFlame::Entities[2]
127
- ```
128
-
129
- ### Get ID
130
- Entity ID's are generated starting from 0 and ascending, unless if there is a missing ID because of a deleted
131
- entity where a new entity will claim that ID. To get the ID of an Entity:
132
-
133
- ```ruby
134
- @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
135
139
  ```
136
140
 
137
141
  ### Adding and Removing Components
@@ -142,8 +146,19 @@ We can still add or remove Components from an Entity after it has been created.
142
146
  @entity.remove @component
143
147
  ```
144
148
 
149
+ ### Accessing Entities' Attached Components
150
+ This is the most common way of accessing an Entity
151
+
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:
153
+
154
+ ```ruby
155
+ @entity.components[@component_manager] # => [@component1, @component2, @component3]
156
+ ```
157
+
145
158
  ### Deletion
146
- 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.
147
162
 
148
163
  ```ruby
149
164
  @entity.delete
@@ -173,20 +188,19 @@ Now that we have a component manager we can make components from it like so:
173
188
  @component = FelFlame::Components::Stats.new
174
189
  ```
175
190
 
176
- Or we can even change the defaults:
191
+ Or we can even override the defaults when creating the component:
177
192
 
178
193
  ```ruby
179
194
  @component = FelFlame::Components::Stats.new(armour: 'steel')
180
195
  ```
181
196
 
182
- ### Accessing and Getting ID
183
- Just like Entities, Components have IDs.
184
- These IDs are only unique within the scope of their respective Component Managers.
185
- 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.
186
199
 
187
200
  ```ruby
188
201
  @component = FelFlame::Components::Stats[2]
189
- @component.id # => 2
202
+ @component = FelFlame::Components::Stats.first
203
+ @component = FelFlame::Components::Stats.each # you can use iterators this way
190
204
  ```
191
205
 
192
206
  ### Accessing Attributes and Changing Them
@@ -198,31 +212,36 @@ Here are the ways to edit attrubutes, followed by the ways to read them.
198
212
  ```
199
213
  ```ruby
200
214
  @component.hp # => 95
201
- @component.attrs # => {armour: 'Leather', hp: 95}
215
+ @component.to_h # => {armour: 'Leather', hp: 95}
202
216
  ```
203
217
 
204
218
  ### Deleting Components
205
- 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.
206
220
 
207
221
  ```ruby
208
222
  @component.delete
209
223
  ```
210
224
 
211
- ### Iterating over Components
212
- 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:
225
+ ### Accessing Components' attached Entities
226
+ Components also keep track of what Entities are using it. To access this list we do the following:
227
+
213
228
  ```ruby
214
- FelFlame::Components::Sprites.each do |component|
215
- #do something with components
216
- end
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
217
235
  ```
218
236
 
237
+
219
238
  ## Systems
220
239
 
221
240
  ### Creation
222
241
  We can create Systems like so:
223
242
 
224
243
  ```ruby
225
- FelFlame::Systems.new(name: 'Render', priority: 2) do
244
+ FelFlame::Systems.new('Render', priority: 2) do
226
245
  # Code and Logic
227
246
  end
228
247
  ```
@@ -234,12 +253,14 @@ FelFlame::Systems::Render
234
253
  ```
235
254
  Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`.
236
255
  The lower the number, the earlier a given System will be executed.
237
- 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.
238
259
 
239
260
  Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:
240
261
 
241
262
  ```ruby
242
- FelFlame::Systems.new(name: 'Render', priority: 2) do
263
+ FelFlame::Systems.new('Render', priority: 2) do
243
264
  FelFlame::Components::Sprites.each do |component|
244
265
  # do something with these components
245
266
  end
@@ -337,7 +358,7 @@ end
337
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:
338
359
 
339
360
  ```ruby
340
- @scene = FelFlame::Scenes.new('ExampleScene')
361
+ @scene = FelFlame::Scenes.new('ExampleScene', priority: 5)
341
362
  ```
342
363
 
343
364
  ### Accessing
@@ -351,14 +372,22 @@ Just like other classes in FelFlame, the name we gave the Scene is how we access
351
372
  Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:
352
373
 
353
374
  ```ruby
354
- FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
375
+ FelFlame::Scenes::ExampleScene.add(
376
+ FelFlame::Systems::Render,
377
+ @system2,
378
+ @system3
379
+ )
355
380
  ```
356
381
 
357
382
  ### Removing Systems
358
- Removing Systems works simularly:
383
+ Removing Systems works similarly:
359
384
 
360
385
  ```ruby
361
- FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
386
+ FelFlame::Scenes::ExampleScene.remove(
387
+ FelFlame::Systems::Render,
388
+ @system2,
389
+ @system3
390
+ )
362
391
  ```
363
392
 
364
393
  ### Clearing
@@ -380,7 +409,7 @@ The Scene will make sure that the systems are executed in the correct order base
380
409
  ## Stage
381
410
 
382
411
  ### Adding Scenes
383
- 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:
384
413
 
385
414
  ```ruby
386
415
  FelFlame::Stage.add FelFlame::Scene::ExampleScene
@@ -394,12 +423,36 @@ FelFlame::Stage.remove FelFlame::Scene::ExampleScene
394
423
  ```
395
424
 
396
425
  ### Executing
397
- 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:
398
427
 
399
428
  ```ruby
400
429
  FelFlame::Stage.call
401
430
  ```
402
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
+
403
456
  ## Closing Notes
404
457
 
405
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
 
@@ -26,20 +46,20 @@ namespace :coverage do
26
46
  end
27
47
 
28
48
  YARD::Rake::YardocTask.new do |t|
29
- t.files = ['system_manager.rb', 'component_manager.rb', 'entity_manager.rb', 'scene_manager.rb', 'stage_manager.rb', 'felflame.rb']
49
+ t.files = ['lib/felflame.rb', 'lib/felflame/*'] # ['system_manager.rb', 'component_manager.rb', 'entity_manager.rb', 'scene_manager.rb', 'stage_manager.rb', 'felflame.rb']
30
50
  t.options = ['--output-dir', './docs', 'yardoc --markup=markdown|textile|rdoc(default)']
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__)