Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Game1.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace Xbox360Game1
- {
- /// <summary>
- /// This is the main type for your game
- /// </summary>
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- public Ship ship;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- graphics.PreferredBackBufferWidth = 880;
- graphics.PreferredBackBufferHeight = 520;
- graphics.PreferMultiSampling = true;
- graphics.ApplyChanges();
- }
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- ship = new Ship();
- ship.ShipTexture = Content.Load<Texture2D>("RocketShip");
- ship.Rotation = 0.0f;
- ship.Position = new Vector2(
- graphics.GraphicsDevice.Viewport.Width / 2,
- graphics.GraphicsDevice.Viewport.Height / 2);
- }
- protected override void UnloadContent()
- {
- Content.Unload();
- Content.Dispose();
- }
- protected override void Update(GameTime gameTime)
- {
- // Allows the game to exit
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- // TODO: Add your update logic here
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- spriteBatch.Begin();
- spriteBatch.Draw(ship.ShipTexture, ship.Position, null, Color.White, ship.Rotation,
- new Vector2(
- ship.ShipTexture.Width / 2,
- ship.ShipTexture.Height / 2), 1.0f, SpriteEffects.None, 0);
- spriteBatch.End();
- base.Draw(gameTime);
- }
- }
- }
- //Ship.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework;
- namespace Xbox360Game1
- {
- class Ship
- {
- public Texture2D ShipTexture;
- public Vector2 Position;
- public Single Rotation;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement