08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Maps<br />

given id.<br />

ds_list_size(id) Returns the number of values stored in the list.<br />

ds_list_empty(id) Returns whether the list is empty. This is the same as<br />

testing whether the size is 0.<br />

ds_list_add(id,val) Adds the value at the end of the list.<br />

ds_list_insert(id,pos,val) Inserts the value at position pos in the list.<br />

The first position is 0, the last position is the size of the list minus 1.<br />

ds_list_replace(id,pos,val) Replaces the value at position pos in the<br />

list <strong>with</strong> the new value.<br />

ds_list_delete(id,pos) Deletes the value at position pos in the list.<br />

(Position 0 is the first element.)<br />

ds_list_find_index(id,val) Find the position storing the indicated<br />

value. If the value is not in the list -1 is returned.<br />

ds_list_find_value(id,pos) Returns the value stored at the indicated<br />

position in the list.<br />

ds_list_sort(id,ascend) Sorts the values in the list. When ascend is true<br />

the values are sorted in ascending order, otherwise in descending order.<br />

ds_list_shuffle(id) Shuffles the values in the list such that they end up<br />

in a random order.<br />

ds_list_write(id) Turns the data structure into a string and returns this<br />

string. The string can then be used to e.g. save it to a file. This provides an<br />

easy mechanism for saving data structures.<br />

ds_list_read(id,str) Reads the data structure from the given string (as<br />

created by the previous call).<br />

In quite a few situations you need to store pairs consisting of a key and a value. For example,<br />

a character can have a number of different items and for each item it has a particular number<br />

of those. In this case the item is the key and the number is the value. Maps maintain such<br />

pairs, sorted by key. You can add pairs to the map and search for the value corresponding to<br />

certain keys. Because the keys are sorted you can also find previous and next keys.<br />

Sometimes it is also useful to use a map to just store keys <strong>with</strong>out a corresponding value. In<br />

that case you can simply use a value of 0. The following functions exist:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!