Browse Source

Changes to get VectorRumble to at least show something on the screen. Matrix.CreateOthograicOfCenter needs to be looked at. Still more work required.

CartBlanche 13 years ago
parent
commit
84fa24fcb6

+ 2 - 0
StarterKits/MacOS/VectorRumble/AudioManager.cs

@@ -89,11 +89,13 @@ namespace VectorRumble
         /// <param name="cueName">The name of the music cue to play.</param>
         /// <param name="cueName">The name of the music cue to play.</param>
         public void PlayMusic(string cueName)
         public void PlayMusic(string cueName)
         {
         {
+#if AUDIO
             // if music is already playing, stop it
             // if music is already playing, stop it
             StopMusic();
             StopMusic();
             // start the new music cue
             // start the new music cue
             musicCue = GetCue(cueName);
             musicCue = GetCue(cueName);
             musicCue.Play();
             musicCue.Play();
+#endif
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 1 - 0
StarterKits/MacOS/VectorRumble/Content/Effects/BloomCombine.fsh

@@ -0,0 +1 @@
+

+ 32 - 0
StarterKits/MacOS/VectorRumble/Content/Effects/BloomExtract.fsh

@@ -0,0 +1,32 @@
+uniform sampler2D bgl_RenderedTexture;
+
+void main()
+{
+   vec4 sum = vec4(0);
+   vec2 texcoord = vec2(gl_TexCoord[0]);
+   int j;
+   int i;
+
+   for( i= -4 ;i < 4; i++)
+   {
+        for (j = -3; j < 3; j++)
+        {
+            sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * 0.25;
+        }
+   }
+       if (texture2D(bgl_RenderedTexture, texcoord).r < 0.3)
+    {
+       gl_FragColor = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
+    }
+    else
+    {
+        if (texture2D(bgl_RenderedTexture, texcoord).r < 0.5)
+        {
+            gl_FragColor = sum*sum*0.009 + texture2D(bgl_RenderedTexture, texcoord);
+        }
+        else
+        {
+            gl_FragColor = sum*sum*0.0075 + texture2D(bgl_RenderedTexture, texcoord);
+        }
+    }
+}

+ 1 - 0
StarterKits/MacOS/VectorRumble/Content/Effects/GaussianBlur.fsh

@@ -0,0 +1 @@
+

+ 4 - 3
StarterKits/MacOS/VectorRumble/Game.cs

@@ -41,9 +41,10 @@ namespace VectorRumble
             graphics = new GraphicsDeviceManager(this);
             graphics = new GraphicsDeviceManager(this);
             Content.RootDirectory = "Content";
             Content.RootDirectory = "Content";
 			
 			
-#if IOS || ANDROID
-            graphics.PreferredBackBufferWidth = 640;
-            graphics.PreferredBackBufferHeight = 480;
+#if IOS || ANDROID // iPad or Tablets only
+            graphics.PreferredBackBufferWidth = 1024;
+            graphics.PreferredBackBufferHeight = 748;
+			//graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
 #else
 #else
 			graphics.PreferredBackBufferWidth = 1280;
 			graphics.PreferredBackBufferWidth = 1280;
             graphics.PreferredBackBufferHeight = 720;
             graphics.PreferredBackBufferHeight = 720;

+ 1 - 4
StarterKits/MacOS/VectorRumble/Rendering/LineBatch.cs

@@ -78,7 +78,7 @@ namespace VectorRumble
             }
             }
             this.graphicsDevice = graphicsDevice;
             this.graphicsDevice = graphicsDevice;
 			
 			
-#if !IOS && !MONOMAC && !ANDROID
+
             // create and configure the effect
             // create and configure the effect
             this.effect = new BasicEffect(graphicsDevice, null);
             this.effect = new BasicEffect(graphicsDevice, null);
             this.effect.VertexColorEnabled = true;
             this.effect.VertexColorEnabled = true;
@@ -88,7 +88,6 @@ namespace VectorRumble
             this.effect.World = Matrix.Identity;
             this.effect.World = Matrix.Identity;
             this.effect.View = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward,
             this.effect.View = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward,
                 Vector3.Up);
                 Vector3.Up);
-#endif
             
             
 			var vd = VertexPositionColor.VertexDeclaration.GetVertexElements();
 			var vd = VertexPositionColor.VertexDeclaration.GetVertexElements();
             // create the vertex declaration
             // create the vertex declaration
@@ -239,13 +238,11 @@ namespace VectorRumble
             graphicsDevice.BlendState = LineBlendState;
             graphicsDevice.BlendState = LineBlendState;
 
 
             // run the effect
             // run the effect
-#if !IOS && !MONOMAC && !ANDROID
 			foreach (EffectPass pass in effect.CurrentTechnique.Passes)
 			foreach (EffectPass pass in effect.CurrentTechnique.Passes)
 			{
 			{
 				pass.Apply();
 				pass.Apply();
 				graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, lineCount);
 				graphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, lineCount);
 			}
 			}
-#endif
         }
         }
         #endregion
         #endregion
 
 

+ 5 - 0
StarterKits/MacOS/VectorRumble/Screens/BackgroundScreen.cs

@@ -72,8 +72,13 @@ namespace VectorRumble
             int viewportHeight = ScreenManager.GraphicsDevice.Viewport.Height;
             int viewportHeight = ScreenManager.GraphicsDevice.Viewport.Height;
 
 
             // update the projection in the line-batch
             // update the projection in the line-batch
+#if ORIGINAL
             lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f,
             lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f,
                 viewportWidth, viewportHeight, 0.0f, 0.0f, 1.0f));
                 viewportWidth, viewportHeight, 0.0f, 0.0f, 1.0f));
+#else
+			lineBatch.SetProjection(Matrix.CreateOrthographic(
+                viewportWidth, viewportHeight, 0.0f, 1.0f));
+#endif
 
 
             // recreate the particle systems
             // recreate the particle systems
             particleSystems.Clear();
             particleSystems.Clear();

+ 9 - 3
StarterKits/MacOS/VectorRumble/Screens/GameplayScreen.cs

@@ -72,10 +72,10 @@ namespace VectorRumble
             audio = (AudioManager)ScreenManager.Game.Services.GetService(
             audio = (AudioManager)ScreenManager.Game.Services.GetService(
                 typeof(AudioManager));
                 typeof(AudioManager));
             world.AudioManager = audio;
             world.AudioManager = audio;
-            // start up the music
-#if AUDIO
+            
+			// start up the music
             audio.PlayMusic("gameMusic");
             audio.PlayMusic("gameMusic");
-#endif
+			
             // start up the game
             // start up the game
             world.StartNewGame();
             world.StartNewGame();
             gameOver = false;
             gameOver = false;
@@ -97,9 +97,15 @@ namespace VectorRumble
             starTexture = content.Load<Texture2D>("Textures/blank");
             starTexture = content.Load<Texture2D>("Textures/blank");
 
 
             // update the projection in the line-batch
             // update the projection in the line-batch
+#if ORIGINAL
             lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f,
             lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f,
                 ScreenManager.GraphicsDevice.Viewport.Width, 
                 ScreenManager.GraphicsDevice.Viewport.Width, 
                 ScreenManager.GraphicsDevice.Viewport.Height, 0.0f, 0.0f, 1.0f));
                 ScreenManager.GraphicsDevice.Viewport.Height, 0.0f, 0.0f, 1.0f));
+#else
+			lineBatch.SetProjection(Matrix.CreateOrthographic(
+                ScreenManager.GraphicsDevice.Viewport.Width, 
+                ScreenManager.GraphicsDevice.Viewport.Height, 0.0f, 1.0f));
+#endif
         }
         }
 
 
 
 

+ 231 - 233
StarterKits/MacOS/VectorRumble/Screens/MenuScreen.cs

@@ -1,233 +1,231 @@
-#region File Description
-//-----------------------------------------------------------------------------
-// MenuScreen.cs
-//
-// XNA Community Game Platform
-// Copyright (C) Microsoft Corporation. All rights reserved.
-//-----------------------------------------------------------------------------
-#endregion
-
-#region Using Statements
-using System;
-using System.Collections.Generic;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-#endregion
-
-namespace VectorRumble
-{
-    /// <summary>
-    /// Base class for screens that contain a menu of options. The user can
-    /// move up and down to select an entry, or cancel to back out of the screen.
-    /// </summary>
-    /// <remarks>Based on a class in the Game State Management sample.</remarks>
-    abstract class MenuScreen : GameScreen
-    {
-        #region Fields
-
-        List<MenuEntry> menuEntries = new List<MenuEntry>();
-        int selectedEntry = 0;
-        AudioManager audioManager;
-
-        #endregion
-
-        #region Properties
-
-
-        /// <summary>
-        /// Gets the list of menu entries, so derived classes can add
-        /// or change the menu contents.
-        /// </summary>
-        protected IList<MenuEntry> MenuEntries
-        {
-            get { return menuEntries; }
-        }
-
-
-        #endregion
-
-        #region Initialization
-
-
-        /// <summary>
-        /// Constructor.
-        /// </summary>
-        public MenuScreen()
-        {
-            TransitionOnTime = TimeSpan.FromSeconds(1.0);
-            TransitionOffTime = TimeSpan.FromSeconds(1.0);
-
-        }
-
-
-        /// <summary>
-        /// Load all content.
-        /// </summary>
-        public override void LoadContent()
-        {
-            // retrieve the audio manager, done here in lieu of Initialize
-            audioManager = (AudioManager)ScreenManager.Game.Services.GetService(
-                                                                typeof(AudioManager));
-            base.LoadContent();
-        }
-
-
-        #endregion
-
-        #region Handle Input
-
-
-        /// <summary>
-        /// Responds to user input, changing the selected entry and accepting
-        /// or cancelling the menu.
-        /// </summary>
-        public override void HandleInput(InputState input)
-        {
-            // Move to the previous menu entry?
-            if (input.MenuUp)
-            {
-                selectedEntry--;
-
-                if (selectedEntry < 0)
-                    selectedEntry = menuEntries.Count - 1;
-
-                audioManager.PlayCue("menuMove");
-            }
-
-            // Move to the next menu entry?
-            if (input.MenuDown)
-            {
-                selectedEntry++;
-
-                if (selectedEntry >= menuEntries.Count)
-                    selectedEntry = 0;
-
-                audioManager.PlayCue("menuMove");
-            }
-			
-			OnSelectEntry(selectedEntry);
-			
-            // Accept or cancel the menu?
-            if (input.MenuSelect)
-            {
-                OnSelectEntry(selectedEntry);
-
-                audioManager.PlayCue("menuSelect");
-            }
-            else if (input.MenuCancel)
-            {
-                OnCancel();
-            }
-        }
-
-
-        /// <summary>
-        /// Handler for when the user has chosen a menu entry.
-        /// </summary>
-        protected virtual void OnSelectEntry(int entryIndex)
-        {
-            menuEntries[selectedEntry].OnSelectEntry();
-        }
-
-
-        /// <summary>
-        /// Handler for when the user has cancelled the menu.
-        /// </summary>
-        protected virtual void OnCancel()
-        {
-            ExitScreen();
-        }
-
-
-        /// <summary>
-        /// Helper overload makes it easy to use OnCancel as a MenuEntry event handler.
-        /// </summary>
-        protected void OnCancel(object sender, EventArgs e)
-        {
-            OnCancel();
-        }
-
-
-        #endregion
-
-        #region Update and Draw
-
-
-        /// <summary>
-        /// Updates the menu.
-        /// </summary>
-        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
-                                                       bool coveredByOtherScreen)
-        {
-            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
-
-            // Update each nested MenuEntry object.
-            for (int i = 0; i < menuEntries.Count; i++)
-            {
-                bool isSelected = IsActive && (i == selectedEntry);
-
-                menuEntries[i].Update(this, isSelected, gameTime);
-            }
-        }
-
-
-        /// <summary>
-        /// Draws the menu.
-        /// </summary>
-        public override void Draw(GameTime gameTime)
-        {
-            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
-            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
-            Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
-
-            Vector2 position = new Vector2(0f, viewportSize.Y * 0.55f);
-
-            // Make the menu slide into place during transitions, using a
-            // power curve to make things look more interesting (this makes
-            // the movement slow down as it nears the end).
-            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);
-
-            if (ScreenState == ScreenState.TransitionOn)
-                position.Y += transitionOffset * 256;
-            else
-                position.Y += transitionOffset * 512;
-
-            // Draw each menu entry in turn.
-            spriteBatch.Begin();
-
-            for (int i = 0; i < menuEntries.Count; i++)
-            {
-                Color color = Color.White;
-                float scale = 1.0f;
-
-                if (IsActive && (i == selectedEntry))
-                {
-                    // The selected entry is yellow, and has an animating size.
-                    double time = gameTime.TotalGameTime.TotalSeconds;
-                    float pulsate = (float)Math.Sin(time * 6f) + 1f;
-
-                    color = Color.Orange;
-                    scale += pulsate * 0.05f;
-                }
-
-                // Modify the alpha to fade text out during transitions.
-                color = new Color(color.R, color.G, color.B, TransitionAlpha);
-
-                // Draw text, centered on the middle of each line.
-                Vector2 origin = new Vector2(0, ScreenManager.Font.LineSpacing / 2);
-                Vector2 size = ScreenManager.Font.MeasureString(menuEntries[i].Text);
-                position.X = viewportSize.X / 2f - size.X / 2f * scale;
-                spriteBatch.DrawString(ScreenManager.Font, menuEntries[i].Text,
-                                                     position, color, 0, origin, scale,
-                                                     SpriteEffects.None, 0);
-
-                position.Y += ScreenManager.Font.LineSpacing;
-            }
-
-            spriteBatch.End();
-        }
-
-
-        #endregion
-    }
-}
+#region File Description
+//-----------------------------------------------------------------------------
+// MenuScreen.cs
+//
+// XNA Community Game Platform
+// Copyright (C) Microsoft Corporation. All rights reserved.
+//-----------------------------------------------------------------------------
+#endregion
+
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+#endregion
+
+namespace VectorRumble
+{
+    /// <summary>
+    /// Base class for screens that contain a menu of options. The user can
+    /// move up and down to select an entry, or cancel to back out of the screen.
+    /// </summary>
+    /// <remarks>Based on a class in the Game State Management sample.</remarks>
+    abstract class MenuScreen : GameScreen
+    {
+        #region Fields
+
+        List<MenuEntry> menuEntries = new List<MenuEntry>();
+        int selectedEntry = 0;
+        AudioManager audioManager;
+
+        #endregion
+
+        #region Properties
+
+
+        /// <summary>
+        /// Gets the list of menu entries, so derived classes can add
+        /// or change the menu contents.
+        /// </summary>
+        protected IList<MenuEntry> MenuEntries
+        {
+            get { return menuEntries; }
+        }
+
+
+        #endregion
+
+        #region Initialization
+
+
+        /// <summary>
+        /// Constructor.
+        /// </summary>
+        public MenuScreen()
+        {
+            TransitionOnTime = TimeSpan.FromSeconds(1.0);
+            TransitionOffTime = TimeSpan.FromSeconds(1.0);
+
+        }
+
+
+        /// <summary>
+        /// Load all content.
+        /// </summary>
+        public override void LoadContent()
+        {
+            // retrieve the audio manager, done here in lieu of Initialize
+            audioManager = (AudioManager)ScreenManager.Game.Services.GetService(
+                                                                typeof(AudioManager));
+            base.LoadContent();
+        }
+
+
+        #endregion
+
+        #region Handle Input
+
+
+        /// <summary>
+        /// Responds to user input, changing the selected entry and accepting
+        /// or cancelling the menu.
+        /// </summary>
+        public override void HandleInput(InputState input)
+        {
+            // Move to the previous menu entry?
+            if (input.MenuUp)
+            {
+                selectedEntry--;
+
+                if (selectedEntry < 0)
+                    selectedEntry = menuEntries.Count - 1;
+
+                audioManager.PlayCue("menuMove");
+            }
+
+            // Move to the next menu entry?
+            if (input.MenuDown)
+            {
+                selectedEntry++;
+
+                if (selectedEntry >= menuEntries.Count)
+                    selectedEntry = 0;
+
+                audioManager.PlayCue("menuMove");
+            }
+			
+            // Accept or cancel the menu?
+            if (input.MenuSelect)
+            {
+                OnSelectEntry(selectedEntry);
+
+                audioManager.PlayCue("menuSelect");
+            }
+            else if (input.MenuCancel)
+            {
+                OnCancel();
+            }
+        }
+
+
+        /// <summary>
+        /// Handler for when the user has chosen a menu entry.
+        /// </summary>
+        protected virtual void OnSelectEntry(int entryIndex)
+        {
+            menuEntries[selectedEntry].OnSelectEntry();
+        }
+
+
+        /// <summary>
+        /// Handler for when the user has cancelled the menu.
+        /// </summary>
+        protected virtual void OnCancel()
+        {
+            ExitScreen();
+        }
+
+
+        /// <summary>
+        /// Helper overload makes it easy to use OnCancel as a MenuEntry event handler.
+        /// </summary>
+        protected void OnCancel(object sender, EventArgs e)
+        {
+            OnCancel();
+        }
+
+
+        #endregion
+
+        #region Update and Draw
+
+
+        /// <summary>
+        /// Updates the menu.
+        /// </summary>
+        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
+                                                       bool coveredByOtherScreen)
+        {
+            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
+
+            // Update each nested MenuEntry object.
+            for (int i = 0; i < menuEntries.Count; i++)
+            {
+                bool isSelected = IsActive && (i == selectedEntry);
+
+                menuEntries[i].Update(this, isSelected, gameTime);
+            }
+        }
+
+
+        /// <summary>
+        /// Draws the menu.
+        /// </summary>
+        public override void Draw(GameTime gameTime)
+        {
+            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
+            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
+            Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height);
+
+            Vector2 position = new Vector2(0f, viewportSize.Y * 0.55f);
+
+            // Make the menu slide into place during transitions, using a
+            // power curve to make things look more interesting (this makes
+            // the movement slow down as it nears the end).
+            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);
+
+            if (ScreenState == ScreenState.TransitionOn)
+                position.Y += transitionOffset * 256;
+            else
+                position.Y += transitionOffset * 512;
+
+            // Draw each menu entry in turn.
+            spriteBatch.Begin();
+
+            for (int i = 0; i < menuEntries.Count; i++)
+            {
+                Color color = Color.White;
+                float scale = 1.0f;
+
+                if (IsActive && (i == selectedEntry))
+                {
+                    // The selected entry is yellow, and has an animating size.
+                    double time = gameTime.TotalGameTime.TotalSeconds;
+                    float pulsate = (float)Math.Sin(time * 6f) + 1f;
+
+                    color = Color.Orange;
+                    scale += pulsate * 0.05f;
+                }
+
+                // Modify the alpha to fade text out during transitions.
+                color = new Color(color.R, color.G, color.B, TransitionAlpha);
+
+                // Draw text, centered on the middle of each line.
+                Vector2 origin = new Vector2(0, ScreenManager.Font.LineSpacing / 2);
+                Vector2 size = ScreenManager.Font.MeasureString(menuEntries[i].Text);
+                position.X = viewportSize.X / 2f - size.X / 2f * scale;
+                spriteBatch.DrawString(ScreenManager.Font, menuEntries[i].Text,
+                                                     position, color, 0, origin, scale,
+                                                     SpriteEffects.None, 0);
+
+                position.Y += ScreenManager.Font.LineSpacing;
+            }
+
+            spriteBatch.End();
+        }
+
+
+        #endregion
+    }
+}

+ 4 - 1
StarterKits/MacOS/VectorRumble/VectorRumble.csproj

@@ -16,7 +16,7 @@
     <DebugType>full</DebugType>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug</OutputPath>
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG;MONOMAC</DefineConstants>
+    <DefineConstants>DEBUG;MONOMAC;SHADER_EFFECTS</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
     <ConsolePause>false</ConsolePause>
@@ -118,6 +118,9 @@
     <Content Include="Content\Textures\title.png" />
     <Content Include="Content\Textures\title.png" />
     <Content Include="Content\Fonts\retroMedium.xnb" />
     <Content Include="Content\Fonts\retroMedium.xnb" />
     <Content Include="Content\Fonts\retroSmall.xnb" />
     <Content Include="Content\Fonts\retroSmall.xnb" />
+    <Content Include="Content\Effects\BloomCombine.fsh" />
+    <Content Include="Content\Effects\BloomExtract.fsh" />
+    <Content Include="Content\Effects\GaussianBlur.fsh" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.MacOS.csproj">
     <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.MacOS.csproj">