1 #region Using Statements
3 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Graphics;
7 using Microsoft.Xna.Framework.Input;
8 using Microsoft.Xna.Framework.Storage;
9 using Microsoft.Xna.Framework.GamerServices;
10 using Microsoft.Xna.Framework.Media;
11 using Microsoft.Xna.Framework.Audio;
15 namespace SuperPolarity
18 /// This is the main type for your game
20 public class SuperPolarity : Game
22 public GraphicsDeviceManager graphics;
23 SpriteBatch spriteBatch;
25 public static int OutlierBounds;
31 protected Song TitleSong;
32 protected Song GameSong;
33 protected SoundEffect GameOverSound;
35 public SuperPolarity()
38 graphics = new GraphicsDeviceManager(this);
39 graphics.PreferMultiSampling = true;
40 graphics.PreferredBackBufferWidth = 1280;
41 graphics.PreferredBackBufferHeight = 720;
42 graphics.ToggleFullScreen();
44 Content.RootDirectory = "Content";
45 ActorFactory.SetGame(this);
46 ParticleEffectFactory.SetGame(this);
47 ActorManager.SetGame(this);
48 ScreenManager.SetGame(this);
50 EntryScreen = (Screen)new TitleScreen(this);
54 /// Allows the game to perform any initialization it needs to before starting to run.
55 /// This is where it can query for any required services and load any non-graphic
56 /// related content. Calling base.Initialize will enumerate through any components
57 /// and initialize them as well.
59 protected override void Initialize()
63 InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
64 InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
66 EntryScreen.Initialize();
71 protected void HandleFullScreenToggle(float value)
73 graphics.ToggleFullScreen();
74 graphics.ApplyChanges();
78 /// LoadContent will be called once per game and is the place to load
79 /// all of your content.
81 protected override void LoadContent()
84 MediaPlayer.IsRepeating = true;
85 GameSong = Content.Load<Song>("Sound\\polaritytheme.wav");
86 GameOverSound = Content.Load<SoundEffect>("Sound\\gameover");
88 // Create a new SpriteBatch, which can be used to draw textures.
89 spriteBatch = new SpriteBatch(GraphicsDevice);
91 ScreenManager.Push(EntryScreen);
93 Player = new Player(this);
97 /// UnloadContent will be called once per game and is the place to unload
100 protected override void UnloadContent()
102 // TODO: Unload any non ContentManager content here
106 /// Allows the game to run logic such as updating the world,
107 /// checking for collisions, gathering input, and playing audio.
109 /// <param name="gameTime">Provides a snapshot of timing values.</param>
110 protected override void Update(GameTime gameTime)
112 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
115 ScreenManager.Update(gameTime);
119 base.Update(gameTime);
123 /// This is called when the game should draw itself.
125 /// <param name="gameTime">Provides a snapshot of timing values.</param>
126 protected override void Draw(GameTime gameTime)
128 GraphicsDevice.Clear(Color.White);
132 ScreenManager.Draw(spriteBatch);
139 public void PlaySong(string songName)
141 // temp stuff before media manager is in
142 if (songName == "game")
144 MediaPlayer.Play(GameSong);
148 public void GameOver()
151 GameOverSound.Play();