Advertisement
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 Pokemon_Vs
- {
- class Player
- {
- Matrix world;
- Model lickitung;
- public Vector3 position;
- BoundingBox boundingBoxP;
- Vector3 angle = Vector3.Zero;
- //GraphicsDevice device;
- public Player()
- {
- //this.device = device;
- position = new Vector3(0, -3, -20);
- this.world = Matrix.Identity;
- this.world *= Matrix.CreateScale(0.5f);
- this.world *= Matrix.CreateTranslation(position);
- this.world *= Matrix.CreateRotationX(180);
- this.boundingBoxP = new BoundingBox();
- //this.UpdateBoundingBox();
- }
- public void LoadContent(ContentManager Content)
- {
- this.lickitung = Content.Load<Model>(@"Models\Lickitung");
- }
- public void Update(_Camera camera, GameTime gameTime)
- {
- //this.world *= Matrix.CreateRotationX(180);
- //position.X = camera.position.X;
- //position.Y = camera.position.Y - 3.5f;
- //position.Z = camera.position.Z - 27;
- //angle.Z++;
- this.world = Matrix.CreateScale(0.001f);
- this.world *= Matrix.CreateTranslation(position);
- //world *= Matrix.CreateRotationY(-0.10f);
- if (Keyboard.GetState().IsKeyDown(Keys.A))
- {
- position.X += 5;
- this.angle.Z += 100 * gameTime.ElapsedGameTime.Milliseconds * 0.001f;
- //this.UpdateBoundingBox();
- }
- if (Keyboard.GetState().IsKeyDown(Keys.D))
- {
- position.X -= 5;
- //this.angle.Z -= 100 * gameTime.ElapsedGameTime.Milliseconds * 0.001f;
- //this.UpdateBoundingBox();
- }
- if (Keyboard.GetState().IsKeyDown(Keys.W))
- {
- position.Z -= 5;
- //this.world *= Matrix.CreateRotationY(180);
- //this.UpdateBoundingBox();
- }
- if (Keyboard.GetState().IsKeyDown(Keys.S))
- {
- position.Z += 5;
- //this.UpdateBoundingBox();
- }
- //this.world *= Matrix.CreateRotationX(MathHelper.ToRadians(this.angle.X));
- //this.world *= Matrix.CreateRotationY(MathHelper.ToRadians(this.angle.Y));
- //this.world *= Matrix.CreateRotationZ(MathHelper.ToRadians(this.angle.Z));
- this.world *= Matrix.CreateRotationY(50);
- this.world = Matrix.CreateTranslation(position);
- //this.world = Matrix.CreateRotationY(MathHelper.ToRadians(camera.angleY));
- this.UpdateBoundingBox();
- }
- public void Draw(_Camera camera)
- {
- //device.SamplerStates[0] = SamplerState.LinearClamp;
- foreach (ModelMesh mesh in this.lickitung.Meshes)
- {
- foreach (BasicEffect effect in mesh.Effects)
- {
- effect.EnableDefaultLighting();
- //effect.PreferPerPixelLighting = true;
- effect.World = this.world;//Matrix.CreateRotationY((float)Math.PI / 2f) * Matrix.CreateTranslation(1,1,1);
- // *mesh.ParentBone.Transform;
- effect.View = camera.GetView();
- effect.Projection = camera.GetProjection();
- }
- mesh.Draw();
- }
- }
- void UpdateBoundingBox()
- {
- this.boundingBoxP.Min = this.position - Vector3.One;
- this.boundingBoxP.Max = this.position + Vector3.One;
- }
- public BoundingBox GetBoundingBox()
- {
- return this.boundingBoxP;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement