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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lists<br />

ds_queue_size(id) Returns the number of values stored in the queue.<br />

ds_queue_empty(id) Returns whether the queue is empty. This is the same<br />

as testing whether the size is 0.<br />

ds_queue_enqueue(id,val) Enters the value in the queue.<br />

ds_queue_dequeue(id) Returns the value that is longest in the queue and<br />

removes it from the queue.<br />

ds_queue_head(id) Returns the value at the head of the queue, that is, the<br />

value that has been the longest in the queue. (It does not remove it from the<br />

queue.)<br />

ds_queue_tail(id) Returns the value at the tail of the queue, that is, the<br />

value that has most recently been added to the queue. (It does not remove it<br />

from the queue.)<br />

ds_queue_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_queue_read(id,str) Reads the data structure from the given string (as<br />

created by the previous call).<br />

A list stores a collection of values in a particular order. You can add values at the end or insert<br />

them somewhere in the middle of the list. You can address the values using an index. Also you<br />

can sort the elements, either in ascending or descending order. Lists can be used in many<br />

ways, for example to store changing collections of values. They are implemented using simple<br />

arrays but, as this is done in compiled code it is a lot faster than using an array yourself. The<br />

following functions are available:<br />

ds_list_create() Creates a new list. The function returns an integer as an<br />

id that must be used in all other functions to access the particular list.<br />

ds_list_destroy(id) Destroys the list <strong>with</strong> the given id, freeing the<br />

memory used. Don't forget to call this function when you are ready <strong>with</strong> the<br />

structure.<br />

ds_list_clear(id) Clears the list <strong>with</strong> the given id, removing all data from<br />

it but not destroying it.<br />

ds_list_copy(id,source) Copies the list source into the list <strong>with</strong> the

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

Saved successfully!

Ooh no, something went wrong!