-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSprite.cs
More file actions
50 lines (42 loc) · 1.37 KB
/
Sprite.cs
File metadata and controls
50 lines (42 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Drawing;
using AsteroidsGdiApp.GameObjects;
namespace AsteroidsGdiApp.Core
{
public class Sprite
{
public Sprite()
{
Polygon = new[]{new Point(0,0), new Point(0, 0), new Point(0, 0), };
}
public Point[] Polygon { get; set; }
public float Speed { get; set; }
public double TravelDirectionInDegrees { get; set; }
public double DirectionOfSprite { get; set; }
public double DeltaX { get; set; }
public double DeltaY { get; set; }
public bool IsPointWithin(Point point)
{
return Polygon.IsPointInPolygon(point);
}
internal bool CollidesWith(Sprite sprite)
{
return sprite.Polygon.CollidesWith(this.Polygon);
}
public List<Line> ToLineList()
{
List<Line> lines = new List<Line>();
for(int i = 0; i < Polygon.Length-1; i++)
{
lines.Add(
new Line
{
StartPoint = new Point(Polygon[i].X, Polygon[i].Y),
EndPoint = new Point(Polygon[i + 1].X, Polygon[i + 1].Y)
});
}
return lines;
}
}
}