public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); base.Draw ( gameTime ); effect.Use ( Core.GraphicsDevice.ImmediateContext ); effect.SetUniform<Matrix4x4> ( "worldMatrix", world.Matrix ); effect.SetUniform<Matrix4x4> ( "viewMatrix", look.Matrix ); effect.SetUniform<Matrix4x4> ( "projMatrix", proj.Matrix ); Core.GraphicsDevice.ImmediateContext.SetSampler ( 0, textureArgs ); Core.GraphicsDevice.ImmediateContext.InputAssembler = new InputAssembler ( vertexBuffer, vertexDeclaration, PrimitiveType.TriangleList, indexBuffer ); Core.GraphicsDevice.ImmediateContext.Draw ( 0, numOfIndices ); spriteWorld.Translate = new Vector2 ( 0, Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Height - texture1.Height ); sprite.Reset ( texture1 ); sprite.Draw ( spriteWorld ); spriteWorld.Translate = new Vector2 ( Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Width - texture2.Width, Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Height - texture1.Height ); sprite.Reset ( texture2 ); sprite.Draw ( spriteWorld ); FpsCalculator calc = Children.First () as FpsCalculator; Core.Window.Title = string.Format ( "Terrain {{ Update FPS: {0}, Draw FPS: {1} }}", calc.UpdateFPS, calc.DrawFPS ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public void Update( GameTime gameTime ) { if ( !IsAnimating ) return; Position += gameTime.ElapsedGameTime; double totalAnimated = TotalAnimated; TotalAnimated = Position.TotalMilliseconds / Duration.TotalMilliseconds * Objective; Animated = TotalAnimated - totalAnimated; if ( Objective <= TotalAnimated ) { if ( IsLoopingMode ) { Position -= Duration; TotalAnimated -= Objective; Animated = TotalAnimated; IsAnimating = true; //lastElapsed = gameTime.ElapsedGameTime; } else { TotalAnimated = Objective; IsAnimating = false; } } //lastElapsed = gameTime.ElapsedGameTime; }
public TransitionState Transitioning( TransitionState currentState, Node scene, GameTime gameTime ) { if ( currentState == TransitionState.Begin ) return TransitionState.PretransitionEnd; else if ( currentState == TransitionState.PretransitionEnd ) return TransitionState.End; else throw new ArgumentException (); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); font.DrawFont ( infoText, Color.White, new Vector2 ( 10, 10 + offset ) ); base.Draw ( gameTime ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); base.Draw ( gameTime ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Draw( GameTime gameTime ) { if ( currentNode != null ) currentNode.Draw ( gameTime ); if ( TransitionState != TransitionState.None ) { TransitionState = SceneTransitor.Transitioning ( TransitionState, sceneList.Peek (), gameTime ); if ( TransitionState == Scenes.TransitionState.PretransitionEnd ) { switch ( ContainMethod ) { case SceneContainMethod.Flat: spinlock.Enter (); sceneList.Pop ().Outro (); nextNode.Intro ( nextNodeArgs ); nextNode.Parent = this; sceneList.Push ( currentNode = nextNode ); nextNode = null; nextNodeArgs = null; spinlock.Exit (); break; case SceneContainMethod.Stack: if ( nextNode == null ) { spinlock.Enter (); Node nn = sceneList.Pop (); nn.Parent = null; nn.Outro (); currentNode = null; nextNode = null; nextNodeArgs = null; spinlock.Exit (); } else { spinlock.Enter (); nextNode.Intro ( nextNodeArgs ); sceneList.Push ( currentNode = nextNode ); nextNode = null; nextNodeArgs = null; spinlock.Exit (); } break; } gameTime.Reset (); } else if ( TransitionState == Scenes.TransitionState.End ) { TransitionState = TransitionState.None; nextNode = null; } } base.Draw ( gameTime ); }
public override void Draw( GameTime gameTime ) { double times = ( lastTimeSpan - GeneratePeriod ).TotalMilliseconds / GeneratePeriod.TotalMilliseconds; if ( ( ( int ) times ) != 0 ) { for ( int i = 0; i < ( int ) ( times * GenerateCountInOneTime ); ++i ) Add ( GenerateParticle () ); lastTimeSpan = gameTime.ElapsedGameTime; } else lastTimeSpan += gameTime.ElapsedGameTime; base.Draw ( gameTime ); }
public override void Draw( GameTime gameTime ) { titleFont.DrawFont ( "Dodge", Color.White, new Vector2 ( 24 ) ); menuFont.DrawFont ( "A. START", Color.White, new Vector2 ( 24, 256 ) ); menuFont.DrawFont ( "B. EXIT", Color.White, new Vector2 ( 24, 304 ) ); logoWorld.Translate = Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Size () / 2 - logo.Texture.Size () / 2; logo.Draw ( logoWorld ); base.Draw ( gameTime ); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); base.Draw ( gameTime ); string fpsString = string.Format ( "Update FPS:{0:0.00}\nRender FPS:{1:0.00}", calc.UpdateFPS, calc.DrawFPS ); fpsFont.DrawFont ( fpsString, Color.White, Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Size () - fpsFont.MeasureString ( fpsString ) - new Vector2 ( 10, 10 ) ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Update( GameTime gameTime ) { updateSum += gameTime.ElapsedGameTime; ++updateFrame; if ( updateSum.TotalSeconds >= 1 ) { updateFps = updateFrame + updateFrame * ( updateSum.TotalSeconds - 1 ); updateFrame = 0; updateSum = new TimeSpan (); } base.Update ( gameTime ); }
public override void Update( GameTime gameTime ) { Vector2 pos = ( this [ 0 ] as SpriteNode ).World.Translate; if ( InputHelper.CurrentKeyboardState.IsKeyDown ( Key.Up ) ) pos += new Vector2 ( 0, -1 ) * ( ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 5.0f ); if ( InputHelper.CurrentKeyboardState.IsKeyDown ( Key.Down ) ) pos += new Vector2 ( 0, 1 ) * ( ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 5.0f ); if ( InputHelper.CurrentKeyboardState.IsKeyDown ( Key.Left ) ) pos += new Vector2 ( -1, 0 ) * ( ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 5.0f ); if ( InputHelper.CurrentKeyboardState.IsKeyDown ( Key.Right ) ) pos += new Vector2 ( 1, 0 ) * ( ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 5.0f ); ( this [ 0 ] as SpriteNode ).World.Translate = ( this [ 1 ] as SpriteNode ).World.Translate = pos; base.Update ( gameTime ); }
public override void Draw( GameTime gameTime ) { drawSum += gameTime.ElapsedGameTime; ++drawFrame; if ( drawSum.TotalSeconds >= 1 ) { drawFps = drawFrame + drawFrame * ( drawSum.TotalSeconds - 1 ); drawFrame = 0; drawSum = new TimeSpan (); } base.Draw ( gameTime ); }
public override void Update( GameTime gameTime ) { if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.A ) ) { ( Parent as SceneContainer ).Transition ( new GameScene () ); } if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.B ) ) { //LiqueurSystem.Launcher.InvokeInMainThread ( () => //{ Core.Exit (); //} ); } base.Update ( gameTime ); }
public override void Draw( GameTime gameTime ) { Vector2 position = Position; Vector2 measure = ( Alignment != 0 ) ? font.MeasureString ( Text ) : new Vector2 (); if ( ( Alignment & SpriteAlignment.Center ) != 0 ) position += new Vector2 ( -measure.X / 2, 0 ); if ( ( Alignment & SpriteAlignment.Right ) != 0 ) position += new Vector2 ( -measure.X, 0 ); if ( ( Alignment & SpriteAlignment.Middle ) != 0 ) position += new Vector2 ( 0, -measure.Y / 2 ); if ( ( Alignment & SpriteAlignment.Bottom ) != 0 ) position += new Vector2 ( 0, -measure.Y ); font.DrawFont ( Text, Color, position ); base.Draw ( gameTime ); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); base.Draw ( gameTime ); int childrenCount = 0; for ( int i = 0; i < 6; ++i ) childrenCount += nodes [ i ].ChildrenCount; Core.Window.Title = string.Format ( "Update FPS: {0}, Draw FPS: {1}, Children count: {2}, Game Looper: {3}", calc.UpdateFPS, calc.DrawFPS, childrenCount, Core.GameLooper.ToString () ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Update( GameTime gameTime ) { World.Translate += new Vector2 ( ( float ) Math.Cos ( angle ), ( float ) Math.Sin ( angle ) ) * ( ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 10.0f ); if ( World.Translate.X < 0 || World.Translate.X > 800 ) InitializeBullet (); if ( World.Translate.Y < 0 || World.Translate.Y > 600 ) InitializeBullet (); SpriteNode chr = Parent.Parent [ 0 ] [ 1 ] as SpriteNode; if ( CheckCollaps ( World.Translate, Texture.Width / 2, chr.World.Translate, chr.Texture.Width / 2 ) ) ( Parent.Parent as GameScene ).IsGameOver = true; base.Update ( gameTime ); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); font.DrawFont ( string.Format ( "Audio1: {0}/{1}, Is Playing? {2}, Volume: {3}", audio1.Position, audio1.Duration, audio1.IsPlaying, audio1.Volume ), Color.White, new Vector2 ( 0, 0 ) ); //font.DrawFont ( string.Format ( "Audio2: {0}/{1}, Is Playing? {2}, Volume: {3}", audio2.Position, audio2.Duration, audio2.IsPlaying, audio2.Volume ), // Color.White, new Vector2 ( 0, 30 ) ); font.DrawFont ( string.Format ( "Audio3: {0}/{1}, Is Playing? {2}, Volume: {3}", audio3.Position, audio3.Duration, audio3.IsPlaying, audio3.Volume ), Color.White, new Vector2 ( 0, 60 ) ); base.Draw ( gameTime ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Draw( GameTime gameTime ) { base.Draw ( gameTime ); string currentTime = string.Format ( "ELAPSED: {0:0.00}sec", timeStamp.TotalSeconds ); timeStampFont.DrawFont ( currentTime, Color.White, new Vector2 () ); if ( isGameOver ) { gameOverFont.DrawFont ( "GAME OVER", Color.White, Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Size () / 2 - gameOverFont.MeasureString ( "GAME OVER" ) / 2 ); string noticeString = "PRESS SPACEBAR TO MENU"; timeStampFont.DrawFont ( noticeString, Color.White, ( Core.GraphicsDevice.ImmediateContext.CurrentRenderBuffer.Size () / 2 - timeStampFont.MeasureString ( noticeString ) / 2 ) + new Vector2 ( 0, 48 ) ); } }
public override void Update( GameTime gameTime ) { if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.Grave ) ) Core.CurrentCulture = CultureInfo.CurrentCulture; else if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D1 ) ) Core.CurrentCulture = new CultureInfo ( "ko-KR" ); else if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D2 ) ) Core.CurrentCulture = new CultureInfo ( "en-US" ); else if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D3 ) ) Core.CurrentCulture = new CultureInfo ( "ja-JP" ); else if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D4 ) ) Core.CurrentCulture = new CultureInfo ( "de-DE" ); else if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D5 ) ) Core.CurrentCulture = new CultureInfo ( "ru-RU" ); base.Update ( gameTime ); }
public override void Update( GameTime gameTime ) { List<Timer> removeTimers = new List<Timer> (); foreach ( KeyValuePair<Timer, Action<Timer>> pair in timers.ToArray () ) { pair.Key.Update ( gameTime.ElapsedGameTime ); if ( pair.Key.Check ) { pair.Key.Reset (); pair.Value ( pair.Key ); removeTimers.Add ( pair.Key ); } } foreach ( Timer timer in removeTimers ) timers.Remove ( timer ); base.Update ( gameTime ); }
public override void Update( GameTime gameTime ) { StringBuilder builder = new StringBuilder (); builder.Append ( "Input keys: " ); if ( InputHelper.CurrentKeyboardState.PressedKeys != null ) foreach ( Key key in InputHelper.CurrentKeyboardState.PressedKeys ) builder.Append ( key.ToString () ).Append ( " " ); builder.AppendLine (); builder.AppendFormat ( "Mouse position: {0}", InputHelper.CurrentMouseState.Position ); builder.AppendLine (); builder.Append ( InputHelper.CurrentMouseState.MouseButtons ); inputInfo = builder.ToString (); base.Update ( gameTime ); }
public override void Update( GameTime gameTime ) { if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D1 ) ) { if ( !audio1.IsPlaying ) audio1.Play (); else audio1.Pause (); } //if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D2 ) ) //{ if ( !audio2.IsPlaying ) audio2.Play (); else audio2.Pause (); } if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D3 ) ) { if ( !audio3.IsPlaying ) audio3.Play (); else audio3.Pause (); } if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.Q ) ) audio1.Volume += 0.1f; //if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.W ) ) audio2.Volume += 0.1f; if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.E ) ) audio3.Volume += 0.1f; if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.A ) ) audio1.Volume -= 0.1f; //if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.S ) ) audio2.Volume -= 0.1f; if ( InputHelper.IsKeyboardKeyUpRightNow ( Key.D ) ) audio3.Volume -= 0.1f; base.Update ( gameTime ); }
public TransitionState Transitioning( TransitionState currentState, Node scene, GameTime gameTime ) { switch ( currentState ) { case TransitionState.Begin: fadeAlpha += ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f * FadeUnit; if ( fadeAlpha >= 255 ) fadeAlpha = 255; DrawFade (); if ( fadeAlpha >= 255 ) return TransitionState.PretransitionEnd; return TransitionState.Begin; case TransitionState.Posttransition: case TransitionState.PretransitionEnd: fadeAlpha -= ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f * FadeUnit; DrawFade (); if ( fadeAlpha <= 0 ) { fadeAlpha = 0; return TransitionState.End; } return TransitionState.Posttransition; default: throw new ArgumentException (); } }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); font.DrawFont ( string.Format ( "Animate state: {0}, Position: {1}/{2}, Animated: {3:0.000}/{4:0.000}", animate.IsAnimating, animate.Position, animate.Duration, animate.Animated, animate.TotalAnimated ), Color.White, new Vector2 ( ( float ) animate.Animated, 0 ) ); font.DrawFont ( string.Format ( "Animate state: {0}, Position: {1}/{2}, Animated: {3:0.000}/{4:0.000}", loopAnimate.IsAnimating, loopAnimate.Position, loopAnimate.Duration, loopAnimate.Animated, loopAnimate.TotalAnimated ), Color.White, new Vector2 ( ( float ) loopAnimate.Animated, 60 ) ); world.Translate = new Vector2 ( ( float ) animate.TotalAnimated, 100 ); sprite.Draw ( world ); sprite.Draw ( new Vector2 ( ( float ) loopAnimate.TotalAnimated, 300 ), Vector2.One, Vector2.Zero, 0, Vector2.Zero ); base.Draw ( gameTime ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); Matrix4x4 projMatrix, lookAtMatrix, worldMatrix; proj.GetMatrix ( out projMatrix ); lookAt.GetMatrix ( out lookAtMatrix ); world.GetMatrix ( out worldMatrix ); cubeEffect.Use ( Core.GraphicsDevice.ImmediateContext ); cubeEffect.SetUniform ( "projMatrix", ref projMatrix ); cubeEffect.SetUniform ( "viewMatrix", ref lookAtMatrix ); cubeEffect.SetUniform ( "worldMatrix", ref worldMatrix ); Core.GraphicsDevice.ImmediateContext.InputAssembler = new InputAssembler ( cubeVertices, vertexDeclarataion, PrimitiveType.TriangleList, cubeIndices ); Core.GraphicsDevice.ImmediateContext.Draw ( 0, 12 ); base.Draw ( gameTime ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Draw( GameTime gameTime ) { Core.GraphicsDevice.ImmediateContext.BeginScene (); Core.GraphicsDevice.ImmediateContext.Clear ( ClearBuffer.AllBuffer, Color.Black ); font.DrawFont ( @"Current culture: ` Korean: 1 English: 2 Japanese: 3 Deutchland: 4 Unknown Culture(Russian): 5", Color.White, new Vector2 () ); font2.DrawFont ( string.Format ( @"Culture code: {0}({1}) string1: {2} string2: {3} string3: {4}", Core.CurrentCulture, Core.CurrentCulture.NativeName, stt [ "string1" ], stt [ "string2" ], stt [ "string3" ] ), Color.White, new Vector2 ( 0, 160 ) ); base.Draw ( gameTime ); Core.GraphicsDevice.ImmediateContext.EndScene (); Core.GraphicsDevice.SwapBuffer (); }
public override void Update( GameTime gameTime ) { if ( InputHelper.CurrentKeyboardState.IsKeyDown ( Key.Down ) ) offset -= ( float ) gameTime.ElapsedGameTime.TotalMilliseconds * 0.1f; if ( InputHelper.CurrentKeyboardState.IsKeyDown ( Key.Up ) ) { offset += ( float ) gameTime.ElapsedGameTime.TotalMilliseconds * 0.1f; if ( offset >= 0 ) offset = 0; } base.Update ( gameTime ); }
public override void Update( GameTime gameTime ) { World.Rotation += rotateUnit * ( float ) gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f; base.Update ( gameTime ); }
public static void Run( ILauncher launcher, Node mainNode, IGameLooper gameLooper = null, Type gameTimeType = null ) { Launcher = launcher; MainNode = mainNode; if ( gameLooper == null ) GameLooper = new PlainGameLooper (); else GameLooper = gameLooper; int elapsedUpdateTimeStep = 0, elapsedDrawTimeStep = 0; int lastUpdateTimeStep = Environment.TickCount, lastDrawTimeStep = Environment.TickCount; GameTime updateGameTime, drawGameTime; if ( gameTimeType == null ) { updateGameTime = new GameTime (); drawGameTime = new GameTime (); } else { updateGameTime = Activator.CreateInstance ( gameTimeType ) as GameTime; drawGameTime = Activator.CreateInstance ( gameTimeType ) as GameTime; } thisThread = Thread.CurrentThread; launcher.Initialize (); Window.Show (); mainNode.Intro (); isRunningMode = true; GameLooper.Run ( () => { if ( AudioDevice != null ) AudioDevice.Update (); if ( elapsedUpdateTimeStep >= fixedUpdateTimeStep ) { updateGameTime.Update (); mainNode.Update ( updateGameTime ); elapsedUpdateTimeStep -= fixedUpdateTimeStep; } else { int temp = Environment.TickCount; elapsedUpdateTimeStep += ( temp - lastUpdateTimeStep ); lastUpdateTimeStep = temp; } }, () => { if ( invokedMethod.Count > 0 ) { foreach ( Action action in invokedMethod.ToArray () ) { action (); invokeSpinLock.Enter (); invokedMethod.Remove ( action ); invokeSpinLock.Exit (); } } if ( elapsedDrawTimeStep >= fixedDrawTimeStep ) { drawGameTime.Update (); mainNode.Draw ( drawGameTime ); elapsedDrawTimeStep -= fixedDrawTimeStep; } else { int temp = Environment.TickCount; elapsedDrawTimeStep += ( temp - lastDrawTimeStep ); lastDrawTimeStep = temp; } Window.DoEvents (); }, ref isRunningMode ); mainNode.Outro (); launcher.Dispose (); }
public override void Update( GameTime gameTime ) { base.Update ( gameTime ); }