Game events

In spacewar is necessary to communicate between game components. For example game core have to notify player that he lost planet. Direct API calls can't be used at least because of cyclic dependencies.

Event principles

Evens work is a same way as events in java swing API.

Change language controller and listener

Following example show sequence of calls between user and components. When use change language in main menu than this event is passed to MainMenuController. MainMenuController raise new event that language was changed. Language event controller will trigger all registered listeners.

Change language class call sequence

List of events

Following events are implemented in spacewar. There are not listed swing events.

  • GameChangedListener - allows to detect change of language
  • StatusMessageListener - allows to change status message
  • GameStatusEventListener - inform when user win or lost game, fleet or planet.