Game class

The main game object.

Constructors

Game({required String title, required Sdl sdl, required SoundBackend soundBackend, String orgName = 'com.example', String appName = 'untitled_game', String preferencesFileName = 'preferences.json', String preferencesKey = defaultPreferencesKey, TriggerMap triggerMap = const TriggerMap([]), Random? random})
Create an instance.

Properties

ambianceSounds SoundChannel
The sound channel to play ambiance sounds through.
final
appName String
The internal name for this game.
final
currentLevel Level?
Get the current level.
no setter
defaultPannerStrategy DefaultPannerStrategy
Set the default panner strategy.
no getter
gameControllers Map<int, GameController>
The game controllers that are currently open.
final
hashCode int
The hash code for this object.
no setterinherited
interfaceSounds SoundChannel
The default channel for playing interface sounds through.
final
isRunning bool
Whether or not this game is running.
no setter
joysticks Map<int, Joystick>
The loaded joysticks.
final
musicSounds SoundChannel
The sound channel for Level music.
latefinal
orgName String
The name of the organisation who makes this game.
final
preferences Preferences
The preferences object for this game.
no setter
preferencesDirectory Directory
Get the preferences directory for this game.
no setter
preferencesFile File
The file where preferences will be stored.
no setter
preferencesFileName String
The filename where preferences will be read from.
final
preferencesKey String
The key where preferences will be stored.
final
random Random
The random number generator to use.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sdl → Sdl
The SDL instance to use.
final
soundBackend SoundBackend
The sound backend to use.
final
tasks List<TaskRunner>
The tasks which have been registered using registerTask.
final
title String
The title of this game.
final
triggerMap TriggerMap
The trigger map.
final
window → Window?
The sdl window that will be shown when the run method is called.
no setter

Methods

callAfter({required TaskFunction func, required int runAfter}) Task
Call the given func after the specified time.
createEcho(Iterable<EchoTap> taps) BackendEcho
Create an echo.
createReverb(ReverbPreset reverb) BackendReverb
Create a reverb.
createSoundChannel({SoundPosition position = unpanned, double gain = 0.7}) SoundChannel
Create a sound channel.
destroy() → void
Destroy this game.
handleSdlEvent(Event event) → void
Handle SDL events.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outputMessage(Message message, {SoundChannel? soundChannel, Sound? oldSound}) Sound?
Output a message.
outputSound({required AssetReference? sound, SoundChannel? soundChannel, Sound? oldSound, bool keepAlive = false, bool looping = false, double pitchBend = 1.0}) Sound?
Output a sound.
outputText(String text) → void
How to output text.
playSimpleSound({required AssetReference sound, SoundPosition position = unpanned, bool looping = false, double pitchBend = 1.0}) Sound
Quickly play a sound.
popLevel({double? ambianceFadeTime}) Level?
Pop the most recent level.
pushLevel(Level level, {int? after, double? fadeLength}) → void
Push a level onto the stack.
registerTask(Task task) → void
Register a new task.
replaceLevel(Level level, {double? fadeOutTime, double? fadeInTime}) → void
Replace the current level with level.
rumble({required int duration, int lowFrequency = 65535, int highFrequency = 65535}) → void
Rumble on all joysticks.
run({int framesPerSecond = 60, TaskFunction? onStart}) Future<void>
Run this game.
setListenerOrientation(double angle) → void
Set the orientation of the listener.
setListenerPosition(double x, double y, double z) → void
Set the listener position.
stop() → void
Stop this game.
tick(int timeDelta) Future<void>
Tick this game.
toString() String
A string representation of this object.
inherited
unregisterTask(Task task) → void
Unregister a task.

Operators

operator ==(Object other) bool
The equality operator.
inherited