public Particle(APhysics physics, AGraphics graphics, Vector2 position, double lifetime) : base(position, physics, graphics) { this.lifetime = lifetime; // Only set task if lifetime is greater than zero. That way we can set lifetime to be // "forever" and set it to done when we see fit. if (lifetime >= 0) { Misc.TaskScheduler.AddTask(() => done = true, lifetime, lifetime, this.id); } }
public PlayerStateMachine(Player player) : base(PlayerStates.Walking) { _player = player; // // Setup components for walking state. // _walkingInput = new PlayerInput(); _walkingPhysics = new TopDownPhysics(_player.WalkSpeed, _player.WalkSpeed / 2, 0.9f); _walkingGraphics = new P8TopDownAnimator(P8TopDownAnimator.AnimationMode.SIDES_ONLY); ((P8TopDownAnimator)_walkingGraphics).RunLeft = new SpriteAnimation(new P8Sprite(33, 1, 1, true, false), 4, 0.3f); ((P8TopDownAnimator)_walkingGraphics).IdleLeft = new SpriteAnimation(new P8Sprite(32, 1, 1, true, false), 1, 0.3f); ((P8TopDownAnimator)_walkingGraphics).RunRight = new SpriteAnimation(new P8Sprite(33, 1, 1, false, false), 4, 0.3f); ((P8TopDownAnimator)_walkingGraphics).IdleRight = new SpriteAnimation(new P8Sprite(32, 1, 1, false, false), 1, 0.3f); }
/// <summary> /// /// </summary> /// <param name="Width"></param> /// <param name="Height"></param> public void Resize(int Width, int Height) { CheckSrcBitmap(); Bitmap ABitmap; Graphics AGraphics; // pomocna Bitmapa urcene velikosti ABitmap = new Bitmap(Width, Height, SrcBitmap.PixelFormat); AGraphics = Graphics.FromImage(ABitmap); AGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; AGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; AGraphics.DrawImage(SrcBitmap, 0, 0, ABitmap.Width, ABitmap.Height); // prehodim novou Bitmapu do stare SrcBitmap.Dispose(); SrcBitmap = ABitmap; AGraphics.Dispose(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { Engine.CurrentGame = this; AMonitor monitor; monitor = new AMonitor(ref graphics); monitor.SetVirtualResolution(800, 600); monitor.SetResolution(Resolutions.R800x600); Engine.Monitor = monitor; Engine.KeyboardDispatcher = new KeyboardDispatcher(Window); staticWindow = Window; // Try and load the settings, if failed, save the current settings to the file if(GameSettings.LoadSettings()) { GameSettings.ApplySettings(); } else { GameSettings.SaveSettings(0.5f, 0.5f); } AGraphics gfx = new AGraphics(); gfx.InitializeGraphics(monitor.gfxDev); Engine.AtriceGraphics = gfx; base.Initialize(); }