-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneralGameItem.cs
99 lines (87 loc) · 2.69 KB
/
generalGameItem.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace CastleOfPain
{
//superclass
class generalGameItem
{
//superclass variables
protected Texture2D sprite;
protected Rectangle rect;
protected Color color;
//constructor
public generalGameItem(Texture2D aSprite, Rectangle aRect, Color aColor)
{
//constructs these 3 variables for use
setSprite(aSprite);
setRect(aRect);
setColor(aColor);
}
//getter for the sprite
public Texture2D getSprite()
{
//returns value of the sprite in this class
return sprite;
}
//setter for the sprite
public void setSprite(Texture2D someSprite)
{
//assigns the value of the sprite to whatever the user assigns the sprite as
sprite = someSprite;
}
//getter for the rectangle
public Rectangle getRect()
{
//returns value of the rectangle in this class
return rect;
}
//setter for the rectangle
public void setRect(Rectangle someRect)
{
//assigns the value of the rectangle to whatever the user assigns the rectangle as
rect = someRect;
}
//getter for the color
public Color getColor()
{
//returns value of the color in this class
return color;
}
//setter for the color
public void setColor(Color someColor)
{
//assigns the value of the color to whatever the user assigns the color as
color = someColor;
}
//universal draw method
public virtual void Draw(SpriteBatch spriteBatch)
{
//draws a general game item
spriteBatch.Draw(sprite, rect, color);
}
//universal hit test
public virtual bool hitTest(Rectangle otherRect)
{
//if this rectangle intersects the other rectangle
if (this.rect.Intersects(otherRect))
{
//return true
return true;
}
//else it did not intersect
else
{
//return false
return false;
}
}
}
}