-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.cs
More file actions
126 lines (114 loc) · 3.39 KB
/
Circle.cs
File metadata and controls
126 lines (114 loc) · 3.39 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace ZuneGame1
{
class Circle
{
Color circleColour;
Vector2 destLocXY;
Vector2 locXY;
Vector2 velocity;
Rectangle drawRect;
TreeNode node;
int diameter;
public Circle(TreeNode tNode, Color upperColor, Vector2 upperLoc, int upperDia, int no)
{
circleColour = upperColor;
diameter = upperDia / 2;
node = tNode;
if (no == 0)
{
locXY = upperLoc;
destLocXY = locXY;
diameter *= 2;
}
else
{
/*
1 2
3 4
*/
locXY = new Vector2(upperLoc.X + diameter / 2, upperLoc.Y + diameter / 2);
destLocXY = new Vector2();
switch (no)
{
case 1:
destLocXY.X = upperLoc.X;
destLocXY.Y = upperLoc.Y;
break;
case 2:
destLocXY.X = upperLoc.X + diameter;
destLocXY.Y = upperLoc.Y;
break;
case 3:
destLocXY.X = upperLoc.X;
destLocXY.Y = upperLoc.Y + diameter;
break;
case 4:
destLocXY.X = upperLoc.X + diameter;
destLocXY.Y = upperLoc.Y + diameter;
break;
}
locXY = (destLocXY - locXY) / 2 + locXY;
}
velocity = new Vector2();
velocity.X = (destLocXY.X - locXY.X) / 16;
velocity.Y = (destLocXY.Y - locXY.Y) / 16;
drawRect = new Rectangle((int)locXY.X, (int)locXY.Y, diameter, diameter);
}
public Color getColour()
{
return circleColour;
}
public void setColour(Color newCol)
{
circleColour = newCol;
}
public int getDia()
{
return diameter;
}
public void setDia(int dia)
{
diameter = dia;
}
public Vector2 getLocXY()
{
return locXY;
}
public void randColour()
{
circleColour = Main.getRandomColour();
}
public bool updateLoc()
{
if (destLocXY.Equals(locXY))
{
velocity = Main.O;
destLocXY = Main.O;
drawRect.X = (int)locXY.X;
drawRect.Y = (int)locXY.Y;
node.erase();
node.readyToSplit();
return true;
}
locXY += velocity;
drawRect.X = (int)locXY.X;
drawRect.Y = (int)locXY.Y;
return false;
}
public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
spriteBatch.Draw(Main.circle, drawRect, circleColour);
}
}
}