-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoal.cs
More file actions
74 lines (66 loc) · 1.72 KB
/
Goal.cs
File metadata and controls
74 lines (66 loc) · 1.72 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace ezkiv
{
class Goal : GameObject
{
string name;
Texture2D spr;
Vector2 locXY;
Rectangle limits;
Random rand;
float rad;
public Goal(Rectangle Limits, Texture2D objSpr, String objName)
{
limits = Limits;
spr = objSpr;
name = objName;
rand = new Random();
locXY = new Vector2();
rad = 7.5f;
resetLoc();
}
public Vector2 getLocXY()
{
return locXY;
}
void resetLoc()
{
locXY.X = rand.Next(limits.Width) + limits.X;
locXY.Y = rand.Next(limits.Height) + limits.Y;
}
public void setLocXY(Vector2 newLoc/*dummy*/)
{
resetLoc();
}
public int collide(GameObject obj)
{
Vector2 temp = obj.getLocXY();
temp = locXY + new Vector2(rad,rad) - temp - new Vector2(15,15);
if (temp.Length() <= rad + 15f)
{
resetLoc();
return 1;
}
return 0;
}
public string getName()
{
return name;
}
public void update()
{
}
public void Draw(SpriteBatch spriteBatch)
{
Rectangle drawRect = new Rectangle(0, 0, 15, 15);
drawRect.X = (int)locXY.X;
drawRect.Y = (int)locXY.Y;
spriteBatch.Draw(spr, drawRect, Color.Yellow);
}
}
}