Guest User

Untitled

a guest
May 22nd, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 KB | None | 0 0
  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 PlanetMovementTest
  13. {
  14.    
  15.     public class Game1 : Microsoft.Xna.Framework.Game
  16.     {
  17.         GraphicsDeviceManager graphics;
  18.         SpriteBatch spriteBatch;
  19.  
  20.         Planet p;
  21.  
  22.         public Game1()
  23.         {
  24.             graphics = new GraphicsDeviceManager(this);
  25.             Content.RootDirectory = "Content";
  26.         }
  27.  
  28.        
  29.         protected override void Initialize()
  30.         {
  31.             // TODO: Add your initialization logic here
  32.  
  33.             p = new Planet(100, 10);
  34.  
  35.             base.Initialize();
  36.         }
  37.  
  38.  
  39.         protected override void LoadContent()
  40.         {
  41.             // Create a new SpriteBatch, which can be used to draw textures.
  42.             spriteBatch = new SpriteBatch(GraphicsDevice);
  43.  
  44.             // TODO: use this.Content to load your game content here
  45.         }
  46.  
  47.  
  48.         protected override void UnloadContent()
  49.         {
  50.             // TODO: Unload any non ContentManager content here
  51.         }
  52.  
  53.  
  54.         protected override void Update(GameTime gameTime)
  55.         {
  56.             // Allows the game to exit
  57.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  58.                 this.Exit();
  59.  
  60.             p.currentTrip += p.speed;
  61.             if (p.currentTrip >= p.maxTrip)
  62.                 p.currentTrip = 0;
  63.             p.increment = p.currentTrip / p.maxTrip;
  64.  
  65.             // Increment the angle
  66.             p.angle = 360 * p.increment;
  67.  
  68.             Console.WriteLine(p.angle);
  69.             Console.WriteLine("-------");
  70.             Console.WriteLine(p.increment);
  71.  
  72.             base.Update(gameTime);
  73.         }
  74.  
  75.         /// <summary>
  76.         /// This is called when the game should draw itself.
  77.         /// </summary>
  78.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  79.         protected override void Draw(GameTime gameTime)
  80.         {
  81.             GraphicsDevice.Clear(Color.CornflowerBlue);
  82.  
  83.             // TODO: Add your drawing code here
  84.  
  85.             base.Draw(gameTime);
  86.         }
  87.     }
  88.     public class Planet
  89.     {
  90.         public float position, currentTrip, increment, angle, maxTrip, speed;
  91.  
  92.         public Planet(int distance, int speed)
  93.         {
  94.             position = 0;
  95.             currentTrip = 0;
  96.             increment = 0;
  97.             angle = 0;
  98.             maxTrip = distance * distance;
  99.             this.speed = speed;
  100.         }
  101.  
  102.     }
  103. }
Add Comment
Please, Sign In to add comment