public void Run() { timer = new FpsTimer(); timer.Fps = 60; DoGC(); while (SDLFrame.PollEvent() == YanesdkResult.NoError) { timer.WaitFrame(); audioDevice.Update(); inputDevice.Update(); bool gc = Tick(); if (currentState == State.Exit) { break; } if (!timer.ToBeSkip) { Draw(); } if (gc) { DoGC(); } } settings.NumUnlockedStages = numUnlockedStages; settings.Save("settings.cfg"); if (log != null) { log.Close(); } SDLFrame.Quit(); }
public void Run() { timer = new FpsTimer(); timer.Fps = 30; GameManager manager = new GameManager(audio, startLevel); manager.LoadScoreDataFromFile("score.dat"); while (SDLFrame.PollEvent() == YanesdkResult.NoError) { input.Update(); manager.Update(input); if (manager.Exiting) { break; } if (!timer.ToBeSkip) { graphics.Begin(); manager.Draw(graphics); graphics.End(); } timer.WaitFrame(); } manager.SaveScoreDataToFile("score.dat"); }
public void ShowAnimation(IList <Bitmap> bitmaps, IList <double> delays, bool startPlaying) { fpsTimer = new FpsTimer(60); LoopControl.FpsTimer = fpsTimer; LoopControl.SetAndStartAction(control1, Go); drawManager = null; var myDrawManager = new DrawManager(control1, fpsTimer); if (bitmaps.Count != delays.Count) { throw new ArgumentException("must have same number of bitmaps as delays"); } IList <Bitmap> oldBitmaps = null; if (flipBook != null) { oldBitmaps = flipBook.Bitmaps; } spriteManager = new SpriteManager(fpsTimer); sprite = new JustSitThereSprite(new Point(0, 0)); if (flipBook != null) { flipBook.FrameChanged -= flipBook_FrameChanged; } flipBook = new FlipBook(bitmaps, delays); flipBook.Loop = true; flipBook.Paused = true; flipBook.FrameChanged += new EventHandler(flipBook_FrameChanged); sprite.AddAlteration(flipBook); spriteManager.AddObject(sprite); myDrawManager.AddDrawable(spriteManager); playButton.Enabled = true; drawManager = myDrawManager; trackBar1.Minimum = 0; trackBar1.Maximum = bitmaps.Count - 1; trackBar1.Value = 0; if (startPlaying) { Play(); } if (oldBitmaps != null) { foreach (Bitmap b in oldBitmaps) { if (b != null) { b.Dispose(); } } } }
public MonstersMovment(List <Monster> theMonsters, int _frameWaitTime, int _stepsToTake) { monsters = theMonsters; stepsToTakeEachTime = _stepsToTake; stepsToke = 0; goRight = true; fpsTimer = new FpsTimer(_frameWaitTime); fpsTimer.TheFunctionToRun = movingDown; }
/// <summary> /// Trigger frame update. /// </summary> public void Update() { var fpsTimerElapsed = FpsTimer.Elapsed; if (fpsTimerElapsed > TimeSpanFpsUpdate) { Fps = FpsFrameCount / fpsTimerElapsed.TotalSeconds; FpsTimer.Restart(); FpsFrameCount = 0; } FpsFrameCount++; }
public Gun(ContentManager content, string textureName, string arrowTextureName, Point startLoc, Size spaceshipSize, int speed, int winHeight, int winWidth) : base(content, textureName, startLoc, speed, winHeight, winWidth) { this.content = content; this.arrowTextureName = arrowTextureName; this.ArrowList = new List <Arrow>(); orignalLocation = new Point(location.X, location.Y); SpaceshipSize = spaceshipSize; fpsTimer = new FpsTimer(30); fpsTimer.TheFunctionToRun = ShootingAnimation; fpsTimer.StartTimer(); gunShotSound = new MasterSound(content, Sounds.GUN_SHOT); }
protected override void Initialize() { content = new ContentManager(Services, "Content"); spriteBatch = new SpriteBatch(GraphicsDevice); viewport = GraphicsDevice.Viewport; Texture2D tex1 = content.Load <Texture2D>("Images/smoke2"); particleSystem = new ParticleSystem(); Effect = new ParticleEffect(); Effect.Rotation = 0f; Effect.Position = new Vector2(viewport.Width / 2, viewport.Height / 2); ParticleEmitter emitter = new CircleEmitter(new Circle(100.0f, Vector2.Zero)); emitter.AutoGenerate = true; ParticleGenerationParams config = new ParticleGenerationParams(); config.AddTexture(tex1); config.ColorRangeStart = Color.Red; config.ColorRangeEnd = Color.Yellow; config.QuantityRange = new Vector2(10, 100); config.Flags = EmitterCastStyle.None; config.ScaleRange = new Vector2(0.1f, 1.1f); config.DepthRange = new Vector2(0.0f, 1.0f); config.OpacityRange = new Vector2(0.6f, 0f); config.InitialSpeedRange = new Vector2(0.1f, 2.0f); config.SpeedDamping = 0.99f; config.RotationRange = new Vector2(-1.0f, 1.0f); config.InitialRotationVariation = 1.0f; config.TTLRange = new Vector2(500.0f, 4000.0f); emitter.Configuration = config; Effect.AddEmitter(emitter); particleSystem.AddEffect(Effect); // Start the animation timer. // timer = Stopwatch.StartNew(); timer = new FpsTimer(1.0f / 20); totalTimeSpan = TimeSpan.FromTicks(DateTime.Now.Ticks); timer.Elapsed += timer_Elapsed; timer.Start(); gameTime = new GameTime(TimeSpan.Zero, TimeSpan.Zero); // Hook the idle event to constantly redraw our animation. Application.Idle += delegate { Invalidate(); }; }
public SpriteAnimation(ContentManager _content, string _textureName, Rectangle _locAndSize, int _frameWaiteTime, int _frameWidth, int _frameHeight, int _rows, int _culloms, int _rotation) { frameWidth = _frameWidth; frameHeight = _frameHeight; rows = _rows; culloms = _culloms; rotation = _rotation; texture = _content.Load <Texture2D>(_textureName); sourceRectangle = new Rectangle(0, 0, frameWidth, frameHeight); SizeAndLocationRect = _locAndSize; animationIsOver = false; fpsTimer = new FpsTimer(_frameWaiteTime); fpsTimer.TheFunctionToRun = animationProgress; fpsTimer.StartTimer(); }
public FpsCounter() { timer = new FpsTimer(); TextStyleClass = "Small"; }
/// <summary> /// /// </summary> /// <param name="fpstimer_"></param> public FpsLayer(FpsTimer fpstimer_) { fpstimer = fpstimer_; size = 25; }
public void Stop() { FpsTimer.Stop(); }
/// <summary> /// FPSカウントをスタートします /// </summary> public void Start() { counter = 0; FpsTimer.Start(); }