/// <summary> /// Load the game over screen /// </summary> public override void Load() { GridStyle = GridStyles.Ticks; BackgroundColor = Color.Black; FontName = "QuartzMS"; // Add the score text ScoreText = AddText(new Text { Alignment = HorizontalAlignments.Left, VerticalAlign = VerticalAlignments.Top, Scale = .4f, Position = new Vector2(-100f, 100f), Color = Color.White }); // Add the start key text RestartText = AddText(new Text { Value = "Press SPACE to Play", Position = new Vector2(0f, -100f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Bottom, AnimationType = TextAnimations.Typewriter, AnimationSeconds = 0.2, Scale = 0.5f, Color = Color.Lime }); if (Game.Platform == GamePlatforms.XBox) { RestartText.Value = "Press START to Play"; } else if (Game.Platform == GamePlatforms.WindowsPhone) { RestartText.Value = "TAP to Play"; } missile = AddSprite <MissileSprite>(); missile.SetCostume("ufo"); missile.Costume.YCenter = VerticalAlignments.Center; missile.Scale = 2; missile.Show(); missile.X = 0; missile.Y = 50; barrier = AddSprite <BarrierSprite>(); barrier.Scale = 2.5f; barrier.Y = -70; ufo = AddSprite <UfoSprite>(); ufo.Position = Vector2.Zero; ufo.Costume.YCenter = VerticalAlignments.Top; ufo.Scale = 1; ufo.Show(); }
/// <summary> /// Load the game over screen /// </summary> public override void Load() { GridStyle = GridStyles.Ticks; BackgroundColor = Color.Black; FontName = "QuartzMS"; // Add the score text ScoreText = AddText(new Text { Alignment = HorizontalAlignments.Left, VerticalAlign = VerticalAlignments.Top, Scale = .4f, Position = new Vector2(-100f, 100f), Color = Color.White }); // Add the start key text RestartText = AddText(new Text { Value = "Press SPACE to Play", Position = new Vector2(0f, -100f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Bottom, AnimationType = TextAnimations.Typewriter, AnimationSeconds = 0.2, Scale = 0.5f, Color = Color.Lime }); if (Game.Platform == GamePlatforms.XBox) { RestartText.Value = "Press START to Play"; } else if (Game.Platform == GamePlatforms.WindowsPhone) { RestartText.Value = "TAP to Play"; } missile = AddSprite<MissileSprite>(); missile.SetCostume("ufo"); missile.Costume.YCenter = VerticalAlignments.Center; missile.Scale = 2; missile.Show(); missile.X = 0; missile.Y = 50; barrier = AddSprite<BarrierSprite>(); barrier.Scale = 2.5f; barrier.Y = -70; ufo = AddSprite<UfoSprite>(); ufo.Position = Vector2.Zero; ufo.Costume.YCenter = VerticalAlignments.Top; ufo.Scale = 1; ufo.Show(); }
using Color = Microsoft.Xna.Framework.Color; #endregion namespace ScratchyXna { public class PlayScreen : Scene { public enum PlayScreenModes { Init, ShowingPlayerNumber, Playing, Finished }
/// <summary> /// Start the title screen /// This happens at the beginning of the game, and when you're done playing /// </summary> public override void StartScene() { Texts.Clear(); Sprites.Clear(); // Add the title text AddText(new Text { Value = "Space Invaders", Position = new Vector2(0f, 80f), Alignment = HorizontalAlignments.Center, AnimationType = TextAnimations.Typewriter, AnimationSeconds = 0.15, Scale = 1f, //Font = FancyFont, OnAnimationComplete = (Text text) => { // When the title text is done typing, show the high score HighScoreText = AddText(new Text { Value = "High Score:", Position = new Vector2(80f, 90f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Top, AnimationType = TextAnimations.SeeSaw, AnimationSeconds = 0.2, AnimationIntensity = 0.15, Scale = 0.4f, }); UfoSprite ufo = AddSprite <UfoSprite>(); ufo.X = -49; ufo.Y = 45; Wait(2.3f, () => { AlienSprite alien = AddSprite <AlienSprite>(); alien.X = -40; alien.Y = 13; alien.Setup(1); }); Wait(5.2f, () => { AlienSprite alien = AddSprite <AlienSprite>(); alien.X = -40; alien.Y = -13; alien.Setup(2); }); Wait(8.7, () => { AlienSprite alien = AddSprite <AlienSprite>(); alien.X = -40; alien.Y = -43; alien.Setup(3); }); AlienScoreText = AddText(new Text { Value = "= ? POINTS" + Text.NewLine + Text.NewLine + "= 10 POINTS" + Text.NewLine + Text.NewLine + "= 20 POINTS" + Text.NewLine + Text.NewLine + "= 30 POINTS", Position = new Vector2(0, 0), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, AnimationType = TextAnimations.Typewriter, AnimationSeconds = 0.2, Scale = 0.8f, Color = Color.White }); } }); // Add the 1p start key text Player1StartText = AddText(new Text { Value = "1 Player Start", Position = new Vector2(-65f, -85f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, AnimationType = TextAnimations.None, AnimationIntensity = 0.2, Scale = 0.6f, Color = Color.Lime }); // Add the 2p start key text Player2StartText = AddText(new Text { Value = "2 Player Start", Position = new Vector2(65f, -85f), Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, AnimationType = TextAnimations.None, AnimationIntensity = 0.2, Scale = 0.6f, Color = Color.Lime }); if (SpaceInvaders.NumberOfPlayers == 1) { Player1StartText.AnimationType = TextAnimations.Throb; Player1StartText.Scale = 0.6f; Player1StartText.Start(); } else { Player2StartText.AnimationType = TextAnimations.Throb; Player2StartText.Scale = 0.6f; Player2StartText.Start(); } }
/// <summary> /// Load the screen /// </summary> public override void Load() { BackgroundColor = Color.Black; FontName = "QuartzMS"; AddSound("shoot"); AddSound("ufo"); AddSound("UfoDeath"); AddSound("AlienDeath"); AddSound("AlienMove1"); AddSound("AlienMove2"); AddSound("AlienMove3"); AddSound("AlienMove4"); // Create our sprites ship = AddSprite <ShipSprite>(); barrier1 = AddSprite <BarrierSprite>(); barrier2 = AddSprite <BarrierSprite>(); barrier3 = AddSprite <BarrierSprite>(); barrier4 = AddSprite <BarrierSprite>(); missile = AddSprite <MissileSprite>(); ufo = AddSprite <UfoSprite>(); //line = AddSprite<LineSprite>(); // Position the barriers barrier1.X = -60; barrier2.X = -20; barrier3.X = 20; barrier4.X = 60; // Create our texts Player1ScoreText = AddText(new Text { Alignment = HorizontalAlignments.Left, VerticalAlign = VerticalAlignments.Top, Scale = 0.4f, Position = new Vector2(-100f, 100f), Color = Color.White, Value = "Player 1 Score: " + SpaceInvaders.Player1Score }); Player2ScoreText = AddText(new Text { Alignment = HorizontalAlignments.Right, VerticalAlign = VerticalAlignments.Top, Scale = 0.4f, Position = new Vector2(100f, 100f), Color = Color.White, Value = "Player 2 Score: " + SpaceInvaders.Player2Score }); HighScoreText = AddText(new Text { Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Top, Scale = .4f, Position = new Vector2(0, 100f), Color = Color.White }); PlayerNumberText = AddText(new Text { Alignment = HorizontalAlignments.Center, VerticalAlign = VerticalAlignments.Center, Scale = 1f, Position = new Vector2(0, 0), Color = Color.Lime, Visible = false }); LevelText = AddText(new Text { Alignment = HorizontalAlignments.Right, VerticalAlign = VerticalAlignments.Bottom, Scale = .4f, Position = new Vector2(100f, -100f), Color = Color.White }); shipStatusText = AddText(new Text { Alignment = HorizontalAlignments.Left, VerticalAlign = VerticalAlignments.Bottom, Scale = 0.5f, Position = new Vector2(-100f, -100f), Color = new Color(1.0f, .2f, .9f, .5f) }); DebugText = AddText(new Text { Alignment = HorizontalAlignments.Right, VerticalAlign = VerticalAlignments.Top, Scale = 0.4f, Position = new Vector2(100f, 100f), Color = Color.YellowGreen }); LivesText = AddText(new Text { Alignment = HorizontalAlignments.Left, VerticalAlign = VerticalAlignments.Bottom, Scale = .4f, Position = new Vector2(-100f, -100f), Color = Color.White, Value = "Lives: " }); }