Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
CollisionType.h
Go to the documentation of this file.
1
2#pragma once
3
12{
13
14public:
15
17 CollisionType() { m_value = 0; }
18 virtual ~CollisionType() { }
19
20
21 static const CollisionType None;
22
23 static const CollisionType Player;
24 static const CollisionType Enemy;
25
26 static const CollisionType Ship;
28
30 {
31 m_value = type.m_value;
32 return *this;
33 }
34
36 {
37 return m_value == type.m_value;
38 }
39
41 {
42 return m_value != type.m_value;
43 }
44
46 {
47 return m_value < type.m_value;
48 }
49
51 {
52 return m_value > type.m_value;
53 }
54
55 const CollisionType operator|(const CollisionType &type) const
56 {
57 return (CollisionType)(m_value | type.m_value);
58 }
59
61 {
62 m_value |= type.m_value;
63
64 return *this;
65 }
66
67 const CollisionType operator&(const CollisionType &type) const
68 {
69 return (CollisionType)(m_value & type.m_value);
70 }
71
73 {
74 m_value &= type.m_value;
75
76 return *this;
77 }
78
79 const CollisionType operator^(const CollisionType &type) const
80 {
81 return (CollisionType)(m_value ^ type.m_value);
82 }
83
85 {
86 m_value ^= type.m_value;
87
88 return *this;
89 }
90
94 bool Contains(const CollisionType &type) const
95 {
96 return (m_value & type.m_value) > 0;
97 }
98
99
100protected:
101
104 CollisionType(const unsigned short value) { m_value = value; }
105
106
107private:
108
109 unsigned short m_value;
110
111};
Represents a type of collision.
static const CollisionType Projectile
CollisionType & operator^=(const CollisionType &type)
const CollisionType operator^(const CollisionType &type) const
CollisionType & operator|=(const CollisionType &type)
CollisionType()
Instantiate a collision type object.
const CollisionType operator|(const CollisionType &type) const
CollisionType & operator=(const CollisionType &type)
bool operator>(const CollisionType &type) const
bool Contains(const CollisionType &type) const
Check if the collision type contains a specific type.
bool operator==(const CollisionType &type) const
bool operator<(const CollisionType &type) const
const CollisionType operator&(const CollisionType &type) const
static const CollisionType Ship
static const CollisionType None
CollisionType & operator&=(const CollisionType &type)
CollisionType(const unsigned short value)
Instantiate a collision type object with a specific value.
virtual ~CollisionType()
bool operator!=(const CollisionType &type) const
static const CollisionType Enemy
static const CollisionType Player