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;
16 namespace SuperPolarity
19 /// This is the main type for your game
21 public class SuperPolarity : Game
23 public GraphicsDeviceManager graphics;
24 SpriteBatch spriteBatch;
26 public static int OutlierBounds;
32 protected Song TitleSong;
33 protected Song GameSong;
34 protected SoundEffect GameOverSound;
36 public SuperPolarity()
39 graphics = new GraphicsDeviceManager(this);
40 Components.Add(new GamerServicesComponent(this));
42 graphics.PreferMultiSampling = true;
43 graphics.PreferredBackBufferWidth = 1280;
44 graphics.PreferredBackBufferHeight = 720;
45 //graphics.ToggleFullScreen();
47 Content.RootDirectory = "Content";
48 ActorFactory.SetGame(this);
49 ParticleEffectFactory.SetGame(this);
50 ActorManager.SetGame(this);
51 ScreenManager.SetGame(this);
53 EntryScreen = (Screen)new TitleScreen(this);
57 /// Allows the game to perform any initialization it needs to before starting to run.
58 /// This is where it can query for any required services and load any non-graphic
59 /// related content. Calling base.Initialize will enumerate through any components
60 /// and initialize them as well.
62 protected override void Initialize()
66 InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
67 InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
69 EntryScreen.Initialize();
74 protected void HandleFullScreenToggle(float value)
76 graphics.ToggleFullScreen();
77 graphics.ApplyChanges();
81 /// LoadContent will be called once per game and is the place to load
82 /// all of your content.
84 protected override void LoadContent()
87 MediaPlayer.IsRepeating = true;
88 GameSong = Content.Load<Song>("Sound\\polaritytheme.wav");
89 GameOverSound = Content.Load<SoundEffect>("Sound\\gameover");
91 // Create a new SpriteBatch, which can be used to draw textures.
92 spriteBatch = new SpriteBatch(GraphicsDevice);
94 ScreenManager.Push(EntryScreen);
96 Player = new Player(this);
100 /// UnloadContent will be called once per game and is the place to unload
103 protected override void UnloadContent()
105 // TODO: Unload any non ContentManager content here
109 /// Allows the game to run logic such as updating the world,
110 /// checking for collisions, gathering input, and playing audio.
112 /// <param name="gameTime">Provides a snapshot of timing values.</param>
113 protected override void Update(GameTime gameTime)
115 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
118 ScreenManager.Update(gameTime);
122 base.Update(gameTime);
126 /// This is called when the game should draw itself.
128 /// <param name="gameTime">Provides a snapshot of timing values.</param>
129 protected override void Draw(GameTime gameTime)
131 GraphicsDevice.Clear(Color.White);
135 ScreenManager.Draw(spriteBatch);
142 public void PlaySong(string songName)
144 // temp stuff before media manager is in
145 if (songName == "game")
147 MediaPlayer.Play(GameSong);
151 public void GameOver()
153 var scoreScreen = new ScoreScreen(this);
154 scoreScreen.Initialize();
157 GameOverSound.Play();
159 ScreenManager.Push(scoreScreen);