Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- 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 WindowsGame6
- {
- class Player
- {
- private float speed = 5.0f;
- private Vector2 position;
- public Vector2 Position
- {
- get { return position; }
- set { position = value; }
- }
- private Texture2D tex;
- public Texture2D Tex
- {
- get { return tex; }
- set { tex = value; }
- }
- //Makes Program More Efficient (one line comment)
- /*Multiline Comment*/
- public Player(Vector2 position, Texture2D tex)
- {
- this.position = position;
- this.tex = tex;
- }
- public void HandleInput(KeyboardState keyState, KeyboardState prevkeyState)
- {
- if (keyState.IsKeyDown(Keys.Up))
- {
- position += new Vector2(0, -1 * speed);
- }
- if (keyState.IsKeyDown(Keys.Down))
- {
- position += new Vector2(0, 1 * speed);
- }
- if (keyState.IsKeyDown(Keys.Left))
- {
- position += new Vector2(-1 * speed, 0);
- }
- if (keyState.IsKeyDown(Keys.Right))
- position += new Vector2(1 * speed, 0);
- }
- }
- public void Draw(SpriteBatch spritebatch)
- {
- spritebatch.Draw(tex, position, Color.White);
- }
- }
- }
Add Comment
Please, Sign In to add comment