Guest User

Sanae player script - shot class

a guest
Sep 9th, 2010
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using SFML.Audio;
  7. using SFML.Graphics;
  8. using SFML.Window;
  9. using DanmakufuDotNet;
  10.  
  11. public class TemplatePlayerShot : Entity
  12. {
  13.     public float Angle
  14.     {
  15.         set { _angle = Helper.AngleNormalize(Helper.AngleToRadians(value)); }
  16.         get { return Helper.AngleToDegrees(_angle); }
  17.     }
  18.     public float Speed { get; set; }
  19.     public float MaxSpeed { get; set; }
  20.     public float Curve { get; set; }
  21.     public int Delay { get; set; }
  22.     public float Acceleration { get; set; }    
  23.  
  24.     private float _angle;
  25.  
  26.     public override void Update()
  27.     {
  28.         if (Delay == 0)
  29.         {
  30.             X += Speed * (float)Math.Cos(_angle);
  31.             Y += Speed * (float)Math.Sin(_angle);
  32.             Angle += Curve;
  33.             Sprite.Rotation = 360 - Angle;
  34.  
  35.             if (Acceleration != 0)
  36.             {
  37.                 if (Acceleration > 0 && Speed < MaxSpeed)
  38.                 {
  39.                     Speed += Acceleration;
  40.                 }
  41.                 else if (Acceleration < 0 && Speed > MaxSpeed)
  42.                 {
  43.                     Speed -= Acceleration;
  44.                 }
  45.             }
  46.         }
  47.         else
  48.         {
  49.             Delay--;
  50.         }
  51.  
  52.         if (!Game.Playfield.IsInPlayfield(X, Y))
  53.         {
  54.             Destroy();
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment