日期:2014-05-17 浏览次数:20850 次
public class MoveableObject
{
public static PointF Center;
public Image Image { get; set; }
public float Speed { get; set; }
public PointF Location { get; set; }
private float angle;
public float Angle
{
get { return angle; }
}
private float radius;
public float Radius { get { return radius; } }
public MoveableObject(Image image, PointF location, float speed)
{
this.Image = image;
this.Location = location;
this.Speed = speed;
float dx = location.X + Image.Width / 2 - Center.X;
float dy = location.Y + Image.Height / 2 - Center.Y;
radius = (float)Math.Sqrt(dx * dx + dy * dy);
angle = (float)(Math.Asin(dy / radius) * 180 / Math.PI);
}
public void Render(Graphics g)
{
g.DrawImage(Image, Location.X + Image.Width / 2, Location.Y + Image.Height / 2);
}
&nbs