1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using Microsoft.Xna.Framework; |
---|
5 | using Microsoft.Xna.Framework.Audio; |
---|
6 | using Microsoft.Xna.Framework.Content; |
---|
7 | using Microsoft.Xna.Framework.GamerServices; |
---|
8 | using Microsoft.Xna.Framework.Graphics; |
---|
9 | using Microsoft.Xna.Framework.Input; |
---|
10 | using Microsoft.Xna.Framework.Media; |
---|
11 | |
---|
12 | namespace XnaGame |
---|
13 | { |
---|
14 | /// <summary> |
---|
15 | /// This is the main type for your game |
---|
16 | /// </summary> |
---|
17 | public class Game1 : Microsoft.Xna.Framework.Game |
---|
18 | { |
---|
19 | GraphicsDeviceManager graphics; |
---|
20 | SpriteBatch spriteBatch; |
---|
21 | |
---|
22 | public Game1() |
---|
23 | { |
---|
24 | graphics = new GraphicsDeviceManager(this); |
---|
25 | Content.RootDirectory = "Content"; |
---|
26 | } |
---|
27 | |
---|
28 | /// <summary> |
---|
29 | /// Allows the game to perform any initialization it needs to before starting to run. |
---|
30 | /// This is where it can query for any required services and load any non-graphic |
---|
31 | /// related content. Calling base.Initialize will enumerate through any components |
---|
32 | /// and initialize them as well. |
---|
33 | /// </summary> |
---|
34 | protected override void Initialize() |
---|
35 | { |
---|
36 | // TODO: Add your initialization logic here |
---|
37 | |
---|
38 | base.Initialize(); |
---|
39 | } |
---|
40 | |
---|
41 | /// <summary> |
---|
42 | /// LoadContent will be called once per game and is the place to load |
---|
43 | /// all of your content. |
---|
44 | /// </summary> |
---|
45 | protected override void LoadContent() |
---|
46 | { |
---|
47 | // Create a new SpriteBatch, which can be used to draw textures. |
---|
48 | spriteBatch = new SpriteBatch(GraphicsDevice); |
---|
49 | |
---|
50 | // TODO: use this.Content to load your game content here |
---|
51 | } |
---|
52 | |
---|
53 | /// <summary> |
---|
54 | /// UnloadContent will be called once per game and is the place to unload |
---|
55 | /// all content. |
---|
56 | /// </summary> |
---|
57 | protected override void UnloadContent() |
---|
58 | { |
---|
59 | // TODO: Unload any non ContentManager content here |
---|
60 | } |
---|
61 | |
---|
62 | /// <summary> |
---|
63 | /// Allows the game to run logic such as updating the world, |
---|
64 | /// checking for collisions, gathering input, and playing audio. |
---|
65 | /// </summary> |
---|
66 | /// <param name="gameTime">Provides a snapshot of timing values.</param> |
---|
67 | protected override void Update(GameTime gameTime) |
---|
68 | { |
---|
69 | // Allows the game to exit |
---|
70 | if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) |
---|
71 | this.Exit(); |
---|
72 | |
---|
73 | // TODO: Add your update logic here |
---|
74 | |
---|
75 | base.Update(gameTime); |
---|
76 | } |
---|
77 | |
---|
78 | /// <summary> |
---|
79 | /// This is called when the game should draw itself. |
---|
80 | /// </summary> |
---|
81 | /// <param name="gameTime">Provides a snapshot of timing values.</param> |
---|
82 | protected override void Draw(GameTime gameTime) |
---|
83 | { |
---|
84 | GraphicsDevice.Clear(Color.CornflowerBlue); |
---|
85 | |
---|
86 | // TODO: Add your drawing code here |
---|
87 | |
---|
88 | base.Draw(gameTime); |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|