-
Notifications
You must be signed in to change notification settings - Fork 0
/
TangibleGame.pde
144 lines (117 loc) · 3.22 KB
/
TangibleGame.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
PGraphics gameSurface; //<>//
PGraphics scoreBoard;
PGraphics topView;
PGraphics barChart;
Mover playable_sphere;
Cylinder cylinder;
ParticleSystem particle_system;
HScrollbar hs_scroll_bar;
ImageProcessing imgproc;
ArrayList<PVector> cylindersPosition = new ArrayList<PVector>();
ArrayList<Float> scores = new ArrayList<Float>();
void settings() {
size(window_size_x, window_size_y, P3D);
}
void setup() {
//has to be in the main game process
//********Merge with ImgProcessing********
imgproc = new ImageProcessing();
String []args = {"Image processing window"};
PApplet.runSketch(args, imgproc);
//********Merge with ImgProcessing********
noStroke();
frameRate(fps);
playable_sphere = new Mover();
cylinder = new Cylinder(defaultCylinderColour);
particle_system = new ParticleSystem();
gameSurface = createGraphics(width, height - score_graphic, P3D);
scoreBoard = createGraphics(square_for_score, square_for_score, P2D);
topView = createGraphics(square_for_score, square_for_score, P2D);
barChart = createGraphics(width - 2*square_for_score - 20, square_for_score, P2D);
hs_scroll_bar = new HScrollbar(2*score_graphic, height-25, score_graphic*3/4, 15);
}
void draw() {
//has to be in the main game process
//********Merge with ImgProcessing********
PVector rotation = imgproc.getRotation();
changeAngleForRotation(rotation);
//********Merge with ImgProcessing********
background(bottomColor);
drawGame();
image(gameSurface, 0, 0);
drawScoreBoard();
image(scoreBoard, 150, height-score_graphic+5);
drawTopView();
image(topView, 5, height-score_graphic+5);
drawBarChart();
image(barChart, 2*square_for_score+10+5, height-score_graphic+5);
hs_scroll_bar.update();
hs_scroll_bar.display();
}
void changeAngleForRotation(PVector rotation)
{
if (!shiftPressed) {
thetaX = rotation.x;
thetaZ = rotation.z;
if (thetaX <= -PI/3) thetaX = -PI/3;
else if (thetaX >= PI/3) thetaX = PI/3;
if (thetaZ <= -PI/3) thetaZ = -PI/3;
else if (thetaZ >= PI/3) thetaZ = PI/3;
}
}
void mouseWheel(MouseEvent evenement) {
float e = evenement.getCount();
if (e < 1 ) {
angularSpeed+=0.1;
} else {
angularSpeed-=0.1;
}
if (angularSpeed >= 1.5) {
angularSpeed = 1.5;
} else if (angularSpeed <= 0.3) {
angularSpeed = 0.3;
}
}
void mousePressed() {
if (shiftPressed) {
addCenterOfVillain();
}
}
void keyPressed() {
if (key == CODED && keyCode == SHIFT) {
shiftPressed = true;
oldThetaX = thetaX;
oldThetaY = thetaY;
oldThetaZ = thetaZ;
thetaX = -PI/2;
thetaY = 0;
thetaZ = 0;
pauseGame();
}
}
void keyReleased() {
if (key == CODED && keyCode == SHIFT ) {
shiftPressed = false;
thetaX = oldThetaX;
thetaY = oldThetaY;
thetaZ = oldThetaZ;
resumeGame();
}
}
void pauseGame() {
gamePaused = true;
}
void resumeGame() {
gamePaused = false;
}
//#############################################
// Getters for points & previousPoints variables
//#############################################
float getPoints() {
if (particle_system == null) return 0;
return particle_system.points;
}
float getLastPoints() {
if (particle_system == null) return 0;
return particle_system.previousPoints;
}