source: 2011/23/sijoseha/Fera Proelia/Fera Proelia/Fera Proelia/Fera_Proelia.cs @ 2079

Revision 2079, 4.4 KB checked in by sijoseha, 9 years ago (diff)

Initial commit

Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Microsoft.Xna.Framework;
5using Microsoft.Xna.Framework.Audio;
6using Microsoft.Xna.Framework.Content;
7using Microsoft.Xna.Framework.GamerServices;
8using Microsoft.Xna.Framework.Graphics;
9using Microsoft.Xna.Framework.Input;
10using Microsoft.Xna.Framework.Input.Touch;
11using Microsoft.Xna.Framework.Media;
12
13namespace Fera_Proelia
14{
15    /// <summary>
16    /// This is the main type for your game
17    /// </summary>
18    public class Fera_Proelia : Microsoft.Xna.Framework.Game
19    {
20        GraphicsDeviceManager graphics;
21        SpriteBatch spriteBatch;
22
23        private Viewport gameView, hudView;
24        Beast beast;
25
26        public Fera_Proelia()
27        {
28            graphics = new GraphicsDeviceManager(this);
29            Content.RootDirectory = "Content";
30
31            // Frame rate is 30 fps by default for Windows Phone.
32            TargetElapsedTime = TimeSpan.FromTicks(333333);
33        }
34
35        /// <summary>
36        /// Allows the game to perform any initialization it needs to before starting to run.
37        /// This is where it can query for any required services and load any non-graphic
38        /// related content.  Calling base.Initialize will enumerate through any components
39        /// and initialize them as well.
40        /// </summary>
41        protected override void Initialize()
42        {
43            // TODO: Add your initialization logic here
44            graphics.IsFullScreen = true;
45            graphics.SupportedOrientations = DisplayOrientation.Portrait;
46            graphics.PreferredBackBufferWidth = 480;
47            graphics.PreferredBackBufferHeight = 800;
48            graphics.ApplyChanges();
49            base.Initialize();
50        }
51
52        /// <summary>
53        /// LoadContent will be called once per game and is the place to load
54        /// all of your content.
55        /// </summary>
56        protected override void LoadContent()
57        {
58            // Create a new SpriteBatch, which can be used to draw textures.
59            spriteBatch = new SpriteBatch(GraphicsDevice);
60           
61            gameView = new Viewport(new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height - 200));
62            hudView = new Viewport(new Rectangle(0, Window.ClientBounds.Height - 200, Window.ClientBounds.Width, 200));
63
64            beast = new Beast(new Vector2(0, 0), 32, 32);
65            beast.Image = Content.Load<Texture2D>("debugImage");
66            // TODO: use this.Content to load your game content here
67        }
68
69        /// <summary>
70        /// UnloadContent will be called once per game and is the place to unload
71        /// all content.
72        /// </summary>
73        protected override void UnloadContent()
74        {
75            // TODO: Unload any non ContentManager content here
76        }
77
78        /// <summary>
79        /// Allows the game to run logic such as updating the world,
80        /// checking for collisions, gathering input, and playing audio.
81        /// </summary>
82        /// <param name="gameTime">Provides a snapshot of timing values.</param>
83        protected override void Update(GameTime gameTime)
84        {
85            // Allows the game to exit
86            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
87                this.Exit();
88
89            // TODO: Add your update logic here
90
91            base.Update(gameTime);
92        }
93
94        /// <summary>
95        /// This is called when the game should draw itself.
96        /// </summary>
97        /// <param name="gameTime">Provides a snapshot of timing values.</param>
98        protected override void Draw(GameTime gameTime)
99        {
100            GraphicsDevice.Clear(Color.CornflowerBlue);
101            GraphicsDevice.Viewport = gameView;
102            spriteBatch.Begin();
103            spriteBatch.Draw(beast.Image, beast.Position, Color.White);
104            spriteBatch.End();
105            GraphicsDevice.Viewport = hudView;
106            spriteBatch.Begin();
107            spriteBatch.Draw(beast.Image, beast.Position, Color.White);
108            spriteBatch.Draw(beast.Image, new Vector2(50,100), Color.White);
109            spriteBatch.Draw(beast.Image, new Vector2(70, 100), Color.White);
110            spriteBatch.End();
111            // TODO: Add your drawing code here
112
113            base.Draw(gameTime);
114        }
115    }
116}
Note: See TracBrowser for help on using the repository browser.