- xnazunelevel_source.zip
- XnaZuneLevel
- AccelerometerTest
- AccelerometerTest.csproj
- AccelerometerTest.csproj.Debug.cachefile
- bin
- Zune
- Debug
- AccelerometerTest.exe
- Content
- Zegoe.xnb
- Release
- Content
- bin
- Content.contentproj
- obj
- Zune
- Zegoe.spritefont
- Game1.cs
- GameThumbnail.pdn
- GameThumbnail.png
- Level.png
- Program.cs
- Properties
- Assets
- BackArrow.design
- CircularLevel.design
- HorizontalLevel.design
- Level
- bin
- Zune
- Debug
- Content
- BackArrow.xnb
- BackgroundTexture.xnb
- Bubble.xnb
- HorizontalLevel.xnb
- MainFont.xnb
- RoundLevel.xnb
- smallBubble.xnb
- VerticalLevel.xnb
- Level.exe
- Release
- Content
- BackArrow.png
- BackgroundTexture.bmp
- bin
- Bubble.png
- Content.contentproj
- HorizontalLevel.png
- MainFont.spritefont
- obj
- Zune
- RoundLevel.png
- smallBubble.png
- VerticalLevel.png
- Game1.cs
- GameThumbnail.png
- Level.csproj
- Level.csproj.Debug.cachefile
- Program.cs
- Properties
- ZuneLevel.sln
|
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;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace AccelerometerTest
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteFont mainFont;
SpriteBatch spriteBatch;
AccelerometerState accelState;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
// Frame rate is 30 fps by default for Zune.
TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0);
AccelerometerCapabilities AccelCaps = Accelerometer.GetCapabilities();
if ((AccelCaps.IsConnected) && (AccelCaps.HasXAxis) && (AccelCaps.HasYAxis) && (AccelCaps.HasZAxis))
{
}
else
{
this.Exit();
}
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
mainFont = Content.Load<SpriteFont>("Zegoe");
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
accelState = Accelerometer.GetState();
if (accelState.IsConnected)
{
}
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
TouchCollection tc = TouchPanel.GetState();
if (tc.Count > 0)
{
this.Exit();
}
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
Vector2 XPosition = new Vector2(20, 10);
Vector2 YPosition = new Vector2(20, 60);
Vector2 ZPosition = new Vector2(20, 110);
Vector2 LogoPosition = new Vector2(20,250);
Vector2 RotationPosition = new Vector2(0.5f, 0.5f);
spriteBatch.Begin();
spriteBatch.DrawString(mainFont, "J2i.net", LogoPosition, Color.White, -270, RotationPosition, 2.5f, SpriteEffects.None, 0);
spriteBatch.DrawString(mainFont, String.Format("X:{0:0.00}",accelState.Acceleration.X), XPosition, Color.White);
spriteBatch.DrawString(mainFont, String.Format("Y:{0:0.00}",accelState.Acceleration.Y), YPosition, Color.White);
spriteBatch.DrawString(mainFont, String.Format("Z:{0:0.00}",accelState.Acceleration.Z), ZPosition, Color.White);
spriteBatch.End();
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.