-
Notifications
You must be signed in to change notification settings - Fork 0
/
Object.pde
48 lines (42 loc) · 1.15 KB
/
Object.pde
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
/**
* Base for all objects on a scene.
* Every object contains some behaviours that it can update annd somehow link together.
* You can search for some behaviour in a given object.
* Also scene can search for objects with a given behaviour.
*/
class Object {
Scene m_scene;
//final String typeName;
PVector coor;
ArrayList<Behaviour> behaviours = new ArrayList<Behaviour>();
Object( Scene sc, String name, PVector c ) {
m_scene = sc;
coor = c;
}
Object( Scene sc, float x, float y ) {
m_scene = sc;
//typeName = name;
coor = new PVector( x, y );
}
void addBehaviour( Behaviour b ) {
if ( !behaviours.contains(b) ) behaviours.add( b );
}
boolean hasBehaviour( BehaviourType t ) {
for ( int i = 0; i < behaviours.size(); i++ ) {
if ( behaviours.get(i).type == t ) return true;
}
return false;
}
Behaviour getBehaviour( BehaviourType t ) {
for ( int i = 0; i < behaviours.size(); i++ ) {
if ( behaviours.get(i).type == t ) return behaviours.get(i);
}
return null;
}
void update() {
verbose( "object is updating" );
}
void draw() {
verbose( "object is drawing" );
}
}