]> git.r.bdr.sh - rbdr/super-polarity/blob - Super Polarity/SuperPolarity.cs
40f147779419046afa82f9efe9ee23f226826168
[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 GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
22
23 MainShip player;
24
25 public SuperPolarity()
26 : base()
27 {
28 graphics = new GraphicsDeviceManager(this);
29 Content.RootDirectory = "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 player = new MainShip();
41
42 base.Initialize();
43 }
44
45 /// <summary>
46 /// LoadContent will be called once per game and is the place to load
47 /// all of your content.
48 /// </summary>
49 protected override void LoadContent()
50 {
51 // Create a new SpriteBatch, which can be used to draw textures.
52 spriteBatch = new SpriteBatch(GraphicsDevice);
53
54 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
55
56 player.Initialize(Content.Load<Texture2D>("Graphics\\player"), playerPosition);
57 }
58
59 /// <summary>
60 /// UnloadContent will be called once per game and is the place to unload
61 /// all content.
62 /// </summary>
63 protected override void UnloadContent()
64 {
65 // TODO: Unload any non ContentManager content here
66 }
67
68 /// <summary>
69 /// Allows the game to run logic such as updating the world,
70 /// checking for collisions, gathering input, and playing audio.
71 /// </summary>
72 /// <param name="gameTime">Provides a snapshot of timing values.</param>
73 protected override void Update(GameTime gameTime)
74 {
75 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
76 Exit();
77
78 // TODO: Add your update logic here
79
80 base.Update(gameTime);
81 }
82
83 /// <summary>
84 /// This is called when the game should draw itself.
85 /// </summary>
86 /// <param name="gameTime">Provides a snapshot of timing values.</param>
87 protected override void Draw(GameTime gameTime)
88 {
89 GraphicsDevice.Clear(Color.CornflowerBlue);
90
91 spriteBatch.Begin();
92
93 player.Draw(spriteBatch);
94
95 spriteBatch.End();
96
97 base.Draw(gameTime);
98 }
99 }
100 }