/// <summary> /// An object used to retrieve input from a game pad. /// </summary> /// <param name="playerIndex">The player index associated with the game pad.</param> public GenGamePad(PlayerIndex playerIndex) { _playerIndex = playerIndex; _gamePadState = GamePad.GetState(_playerIndex); _oldGamePadState = _gamePadState; _leftMotorSpeed = 0f; _rightMotorSpeed = 0f; _vibrateDecreasing = false; _vibrateTimer = new GenTimer(0f, null); }
/// <summary> /// Creates a playable sound instance managed by a <c>GenSound</c> object. /// </summary> /// <param name="sound">The <c>GenSound</c> object that this sound instance is handled by.</param> public GenSoundInstance(GenSound sound) { _soundParent = sound; _sound = _soundParent.Sound; SoundInstance = _soundParent.Sound.CreateInstance(); SoundInstance.IsLooped = _soundParent.IsLooped; SoundInstance.Volume = _soundParent.Volume; SoundInstance.Pitch = _soundParent.Pitch; SoundInstance.Pan = _soundParent.Pan; _fadeTimer = new GenTimer(0f, null); Follow = _soundParent.Follow; // Call UpdateSound initially to correct the volume value. UpdateSound(); }
/// <summary> /// Initializes any necessary resources used by <c>GenMusic</c>. /// </summary> public static void Initialize() { _volume = 1f; _fadeTimer = new GenTimer(0f, null); #if WINDOWS || XBOX VisualData = new VisualizationData(); VisualDataEnabled = false; #endif }
/// <summary> /// A particle used by a particle emitter. /// A particle is a GenSprite object, but has additional features useful to particles. /// </summary> /// <param name="x">The x position of the top-left corner of the particle.</param> /// <param name="y">The y position of the top-left corner of the particle.</param> /// <param name="texture">The texture to use as the particle's texture.</param> /// <param name="width">The width of the particle.</param> /// <param name="height">The height of the particle.</param> /// <param name="lifetime">The amount of time, in seconds, that the particle will last after being emitted.</param> public GenParticle(float x = 0, float y = 0, Texture2D texture = null, int width = 1, int height = 1, float lifetime = 3f) : base(x, y, texture, width, height) { // Set the life timer to kill the particle at the end of its life. LifeTimer = new GenTimer(lifetime, Kill); }
/// <summary> /// Creates a playable sound instance. /// </summary> /// <param name="sound">The loaded <c>SoundEffect</c> to use.</param> /// <param name="volume">The volume of the sound, a value from 0.0 to 1.0.</param> /// <param name="isLooping">A flag used to determine if the sound is played on a loop.</param> public GenSoundInstance(SoundEffect sound, float volume = 1f, bool isLooping = false) { LoadSound(sound, volume, isLooping); _fadeTimer = new GenTimer(0f, null); }
/// <summary> /// A particle emitter that emits particles from a point, /// </summary> /// <param name="x">The x position of the top-left corner of the emitter.</param> /// <param name="y">The y position of the top-left corner of the emitter.</param> public GenEmitter(float x, float y) { _position = new Vector2(x, y); _bounds = new GenAABB(x, y, 0f, 0f); _boundingRect = Rectangle.Empty; MinParticleSpeedX = -100; MaxParticleSpeedX = 100; MinParticleSpeedY = -100; MaxParticleSpeedY = 100; MinRotation = 0; MaxRotation = 0; MinRotationSpeed = 0; MaxRotationSpeed = 0; Colors = new List<Color>(); StartAlpha = 1f; EndAlpha = 1f; StartScale = 1f; EndScale = 1f; Explode = true; EmitQuantity = 10; _emitTimer = new GenTimer(0.1f, EmitParticles); _emitTimer.IsLooping = true; InheritVelocity = false; Parent = null; ParentOffset = Vector2.Zero; }