events

package
v0.0.0-...-309fd15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2017 License: MIT Imports: 0 Imported by: 4

Documentation

Overview

Definitions for different kinds of events. Note that Events in this package are GAME events, not SDL events. The job of this package is to take input from SDL, and convert it into game events which can be passed on into the main game itself.

Index

Constants

View Source
const (
	NONE = iota
	TERMINATE
	TOGGLE_DRAW
	SELECT
	TOGGLE_FRAME_LIMIT
	SPEED_UP
	SPEED_DOWN
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicEvent

type BasicEvent struct {
	EventType EventType
}

A basic event. Contains just an event code, and no additional data.

func (BasicEvent) GetType

func (e BasicEvent) GetType() EventType

GetType returns the event type code for the given event.

type Event

type Event interface {
	GetType() EventType // Returns the event type.
}

Event interface. This is a little weird, but since there's no subclassing, we need an interface here to allow us to pass around different kinds of events blindly.

type EventType

type EventType int

type Handler

type Handler map[EventType][]listener

Handler farms events out to anyone who has registed interest.

var (
	Global Handler = NewHandler()
)

func NewHandler

func NewHandler() Handler

NewHandler returns a new Handler with no registered listeners.

func (Handler) Broadcast

func (h Handler) Broadcast(e Event)

Broadcast sends an event out to any listeners who care.

func (Handler) Register

func (h Handler) Register(t EventType, l listener)

Register ensures the listener will get called whenever an event of type t is raised.

type LocationEvent

type LocationEvent struct {
	BasicEvent
	// contains filtered or unexported fields
}

An event with an associated location.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL