-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# warn_array_primitives! | ||
|
||
This function helps you audit your game of usages of array-based primitives. While array-based primitives are simple to create and use, they are slower to process than Hash or Class based primitives. | ||
|
||
```ruby | ||
def tick args | ||
# enable array based primitives warnings | ||
args.gtk.warn_array_primitives! | ||
|
||
# array-based primitive elsewhere in code | ||
# an log message will be posted giving the location of the array | ||
# based primitive usage | ||
args.outputs.sprites << [100, 100, 200, 200, "sprites/square/blue.png"] | ||
|
||
# instead of using array based primitives, migrate to hashes as needed | ||
args.outputs.sprites << { | ||
x: 100, | ||
y: 100, | ||
w: 200, | ||
h: 200, path: | ||
"sprites/square/blue.png" | ||
} | ||
end | ||
``` | ||
|