Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.Graphics;
  8. using Microsoft.Xna.Framework.Input;
  9.  
  10. namespace ZombieSmackUpd
  11. {
  12.     class MouseControlFire : Stuff
  13.     {
  14.         Effect PointSpritesEffect;
  15.         VertexPositionColor[] Sprite;
  16.  
  17.         public MouseControlFire(string effect, string texture)
  18.         {
  19.             PointSpritesEffect = Content.Load<Effect>(effect);
  20.             PointSpritesEffect.Parameters["SpriteTexture"].SetValue(Content.Load<Texture2D>(texture));
  21.             Sprite = new VertexPositionColor[1];
  22.  
  23.             Sprite[0].Position = new Vector3(0f, 200f, 60f);
  24.             Sprite[0].Color = Color.TransparentBlack;
  25.         }
  26.  
  27.         public void MouseInput()
  28.         {
  29.             MouseState mouseState = Mouse.GetState();
  30.  
  31.  
  32.  
  33.             Sprite[0].Position.X = mouseState.X;
  34.             Sprite[0].Position.Y = mouseState.Y;
  35.  
  36.             Sprite[0].Position.Z = 60f;
  37.         }
  38.    
  39.         public void DrawSprite()
  40.         {
  41.             // Drawing code here.
  42.             device.RenderState.PointSpriteEnable = true;
  43.             device.RenderState.PointSize = 128.0f;
  44.             device.RenderState.AlphaBlendEnable = true;
  45.             device.RenderState.SourceBlend = Blend.SourceAlpha;
  46.             device.RenderState.DestinationBlend = Blend.One;
  47.             device.RenderState.DepthBufferWriteEnable = false;
  48.  
  49.             device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
  50.  
  51.             Matrix WVPMatrix = Matrix.Identity * viewMatrix * projectionMatrix;
  52.             PointSpritesEffect.Parameters["WVPMatrix"].SetValue(WVPMatrix);
  53.  
  54.             PointSpritesEffect.Begin();
  55.  
  56.             foreach (EffectPass pass in PointSpritesEffect.CurrentTechnique.Passes)
  57.             {
  58.                 pass.Begin();
  59.  
  60.                 device.DrawUserPrimitives<VertexPositionColor>(
  61.                     PrimitiveType.PointList,
  62.                     Sprite,
  63.                     0, 1);
  64.  
  65.                 pass.End();
  66.             }
  67.             PointSpritesEffect.End();
  68.  
  69.             device.RenderState.PointSpriteEnable = false;
  70.             device.RenderState.DepthBufferWriteEnable = true;
  71.             device.RenderState.SourceBlend = Blend.SourceAlpha;
  72.             device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement