Class Rubygame::Queue
In: lib/rubygame/queue.rb
ext/rubygame/rubygame_transform.c
Parent: Object

(Note: I‘m not putting much effort into documenting the current Queue class, because it is going to be changing substantially in the next version. It is mostly usable for now, but neither elegant nor fun to use. Frankly, I think it‘s an abomination, and it took all my willpower to put off rewriting it until next version.)

Queue provides an interface to SDL‘s events, allowing the application to detect keyboard presses, mouse movements and clicks, joystick movement, etc.

The full list of default events is:

You are allowed to create new child classes of Event and post them to the Queue, but for now you would probably be better off using some other data structure to hold your own events. I recommend checking out the queue class in Ruby‘s stardard library.

P.S. Queue is a singleton, so you must use Queue.instance, not Queue.new.

Methods

allow   allowed   allowed=   block   blocked   blocked=   get   get_sdl   post   wait  

Included Modules

Singleton

Public Instance methods

Allow the given event classes. Returns all event classes that had previously been disallowed, but are now allowed.

Returns all event classes which are allowed.

Allow ONLY the given event classes. Returns all event classes that had previously been disallowed, but are now allowed.

Disallow the given event classes from being posted. Returns all classes which had previously been allowed, but are now disallowed.

Return all default Rubygame event classes which are disallowed by the Queue.

Cause the Queue to allow ONLY all default Rubygame event classes EXCEPT the given classes. Returns all classes which had previously been allowed, but are now disallowed.

Get all events currently in the Queue which match the classes in the Array klasses, and return them in an Array. If klasses is omitted, returns all

Events which did not match will remain on the Queue, so make sure you eventually get every class of events that is allowed, or they might build up in the Queue.)

(This private method is intended for internal use, but you might need to worry about it if you extend Queue.)

Retrieves all pending events from SDL‘s event buffer and converts them into Rubygame Event objects. Returns an Array of all the events, in the order they were read.

Post one or more events to the Queue. Only events which meet these criteria will be posted:

Returns all the given events which were not posted.

Waits until an event matching the classes in Array klasses occurs, then return that event. All non-matching events will be discarded in the meantime.

If klasses is omitted, ANY event class allowed by the Queue will trigger return. (Important: omitting klasses is not the same as giving nil.)

klasses is an Array of the Event classes which will trigger this method to return. Any classes which are blocked by the Queue or are not Rubygame-generated hardware events will be stripped from klasses.

If klasses is given, but does not contain any valid classes, this method will immediately return nil.

[Validate]