|
| 1 | +# ArrayClass |
| 2 | +Better arrays/ds_lists for GameMaker Studio 2.3 |
| 3 | + |
| 4 | +ArrayClass is a library that improves the developing experience and reduces frustration when working with arrays |
| 5 | +It's main focus is not |
| 6 | + |
| 7 | +## Features: |
| 8 | + |
| 9 | +- **Methods for every possible situation.** Even if you ever need a function that is not in the list, you can write your own implementation using forEach(). |
| 10 | +- **Automatic garbage collection.** No need to manually destroy the Array, GM will do it for you. |
| 11 | +- **Chaining methods.** Most of the methods return the array, so you can do stuff like this: `arr.add(1).reverse().remove(0).slice(1, 4).find(pi)` (perfectly valid) |
| 12 | +- **Intuitive API,** built to be handy for developers; easy conversion to and from ds_lists/arrays for more flexibility |
| 13 | +- **Customizable sorting.** It's weird that most of the sort functions I've seen only had the ascending/descending option. My implementation of bubble sort takes a custom function to compare values. Sort any types of data in any way you want |
| 14 | +- **Additional features** like iterators or ranges |
| 15 | + |
| 16 | +## Getting Started: |
| 17 | + |
| 18 | +### Importing into an existing project |
| 19 | +- **Download the .yymps file** |
| 20 | +- Open GameMaker IDE, click Tools/Import Local Package |
| 21 | +- Import ArrayClass.gml, documentation is included |
| 22 | +- *Also Import Tests.gml to see examples on how to use the library |
| 23 | +### Exerimenting/Learning API |
| 24 | +- Download the project folder |
| 25 | +- Open the project |
| 26 | +- Try editing Tests.gml in different ways and see what happens! |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +## Some Examples: |
| 31 | + |
| 32 | +## Adding Values: |
| 33 | + |
| 34 | +### GM arrays: |
| 35 | +``` |
| 36 | +arr[array_length(arr) - 1] = item |
| 37 | +``` |
| 38 | +### Array Class: |
| 39 | +``` |
| 40 | +arr.add(item) |
| 41 | +``` |
| 42 | + |
| 43 | +## Looping: |
| 44 | +### GM arrays: |
| 45 | +``` |
| 46 | +for(var i = 0; i < array_length(arr); i++) { |
| 47 | + foo(arr[i], i) |
| 48 | +} |
| 49 | +``` |
| 50 | +### Array Class: |
| 51 | +``` |
| 52 | +arr.forEach(foo) |
| 53 | +``` |
| 54 | + |
| 55 | +## Deleting values: |
| 56 | +### GM arrays: |
| 57 | +``` |
| 58 | +for(var i = pos; i < array_length(arr) - 1; i++) { |
| 59 | + arr[i] = arr[i + 1]; |
| 60 | +} |
| 61 | +``` |
| 62 | +### Array Class: |
| 63 | +``` |
| 64 | +arr.remove(pos) |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +P.s. a new commit erased the old README file, so I was forced to write a new one :( |
0 commit comments