]> git.r.bdr.sh - rbdr/super-polarity/blob - Super Polarity/SuperPolarity.cs
e5f565bd23d874bde0f6bb02e82b683e70f6cda3
[rbdr/super-polarity] / Super Polarity / SuperPolarity.cs
1 #region Using Statements
2 using System;
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 SuperPolarity;
11 #endregion
12
13 namespace SuperPolarity
14 {
15 /// <summary>
16 /// This is the main type for your game
17 /// </summary>
18 public class SuperPolarity : Game
19 {
20 public static GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
22
23 public SuperPolarity()
24 : base()
25 {
26 SuperPolarity.graphics = new GraphicsDeviceManager(this);
27 SuperPolarity.graphics.PreferMultiSampling = true;
28 Content.RootDirectory = "Content";
29 ActorFactory.SetContentManager(Content);
30 }
31
32 /// <summary>
33 /// Allows the game to perform any initialization it needs to before starting to run.
34 /// This is where it can query for any required services and load any non-graphic
35 /// related content. Calling base.Initialize will enumerate through any components
36 /// and initialize them as well.
37 /// </summary>
38 protected override void Initialize()
39 {
40 base.Initialize();
41 }
42
43 /// <summary>
44 /// LoadContent will be called once per game and is the place to load
45 /// all of your content.
46 /// </summary>
47 protected override void LoadContent()
48 {
49 // Create a new SpriteBatch, which can be used to draw textures.
50 spriteBatch = new SpriteBatch(GraphicsDevice);
51
52 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
53
54 ActorFactory.CreateMainShip(playerPosition);
55 }
56
57 /// <summary>
58 /// UnloadContent will be called once per game and is the place to unload
59 /// all content.
60 /// </summary>
61 protected override void UnloadContent()
62 {
63 // TODO: Unload any non ContentManager content here
64 }
65
66 /// <summary>
67 /// Allows the game to run logic such as updating the world,
68 /// checking for collisions, gathering input, and playing audio.
69 /// </summary>
70 /// <param name="gameTime">Provides a snapshot of timing values.</param>
71 protected override void Update(GameTime gameTime)
72 {
73 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
74 Exit();
75
76 // TODO: Add your update logic here
77
78 InputController.UpdateInput();
79 ActorManager.Update(gameTime);
80
81 base.Update(gameTime);
82 }
83
84 /// <summary>
85 /// This is called when the game should draw itself.
86 /// </summary>
87 /// <param name="gameTime">Provides a snapshot of timing values.</param>
88 protected override void Draw(GameTime gameTime)
89 {
90 GraphicsDevice.Clear(Color.White);
91
92 spriteBatch.Begin();
93
94 ActorManager.Draw(spriteBatch);
95
96 spriteBatch.End();
97
98 base.Draw(gameTime);
99 }
100 }
101 }