Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 PlanetMovementTest
- {
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- Planet p;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- p = new Planet(100, 10);
- base.Initialize();
- }
- protected override void LoadContent()
- {
- // Create a new SpriteBatch, which can be used to draw textures.
- spriteBatch = new SpriteBatch(GraphicsDevice);
- // TODO: use this.Content to load your game content here
- }
- protected override void UnloadContent()
- {
- // TODO: Unload any non ContentManager content here
- }
- protected override void Update(GameTime gameTime)
- {
- // Allows the game to exit
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- p.currentTrip += p.speed;
- if (p.currentTrip >= p.maxTrip)
- p.currentTrip = 0;
- p.increment = p.currentTrip / p.maxTrip;
- // Increment the angle
- p.angle = 360 * p.increment;
- Console.WriteLine(p.angle);
- Console.WriteLine("-------");
- Console.WriteLine(p.increment);
- 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.CornflowerBlue);
- // TODO: Add your drawing code here
- base.Draw(gameTime);
- }
- }
- public class Planet
- {
- public float position, currentTrip, increment, angle, maxTrip, speed;
- public Planet(int distance, int speed)
- {
- position = 0;
- currentTrip = 0;
- increment = 0;
- angle = 0;
- maxTrip = distance * distance;
- this.speed = speed;
- }
- }
- }
Add Comment
Please, Sign In to add comment