-
Notifications
You must be signed in to change notification settings - Fork 0
/
Obj.pde
60 lines (46 loc) · 1021 Bytes
/
Obj.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
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Abstract class for objects that will be drawn to the screen
*/
public abstract class Obj {
protected Assets a;
protected Snap m;
protected boolean shouldUpdate = true;
public Obj(Snap app) {
this.a = app.a;
this.m = app;
}
public void setup() {
// Do sone setup
preSetup();
_setup();
postSetup();
}
protected void preSetup() {
// Should be used for super classes to setup variables
}
protected void postSetup() {
// Should be used for super classes to ovveride variables
}
protected void _setup() {
// Does nothing
// Should be overiden by a super class and called in the setup method if needed
}
/**
* Draws and updates the object
* Should not be overeiden by a super class
*/
public void update() {
preUpdate();
if (shouldUpdate) {
_update();
}
postUpdate();
}
abstract protected void _update();
protected void preUpdate() {
push();
}
protected void postUpdate() {
pop();
}
}