-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreeballz.pde
157 lines (140 loc) · 4.39 KB
/
freeballz.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
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* os-balls.pde
*
* Main game file for OS-Balls
*
* Created on: December 23, 2019
* Author: Sean LaPlante
*/
void settings() {
/*
* Builtin method that runs before setup
* and allows us to f-around with size and
* fullScreen methods unlike in setup where
* they need to be the first line
*/
IS_ANDROID_MODE = isAndroidMode();
if (IS_ANDROID_MODE) {
println("Android mode detected");
fullScreen();
SAVE_LOCATION = "freeballz-mobile.json";
} else {
println("Java mode detected");
size(600, 1233);
SAVE_LOCATION = "data/freeballz-desktop.json";
}
}
void setup() {
/*
* Builtin method provided by Processing. This is
* always called first.
*/
SHOT_SPEED = 8 * getDisplayDensity();
DEFAULT_TEXT_SIZE = 42 * getDisplayDensity();
SMALL_TEXT_SIZE = 28 * getDisplayDensity();
EXPLODE_PART_BWIDTH = 12 * getDisplayDensity();
SLIDE_VELOCITY = 5 * getDisplayDensity();
EXPLODE_PART_MAX_SPEED = 3 * getDisplayDensity();
EXPLODE_PART_MIN_SPEED = -3 * getDisplayDensity();
EXPLODE_PART_RADIUS = 10.0 * getDisplayDensity();
BLOCK_RADIUS = 3 * getDisplayDensity();
BUTTON_RADIUS = 10.0 * getDisplayDensity();
BALL_RADIUS = width * 0.02;
PICKUP_BALL_RADIUS = BALL_RADIUS * 1.75;
COIN_RADIUS = BALL_RADIUS * 1.5;
BLOCK_COLUMNS = 7;
BLOCK_WIDTH = width / BLOCK_COLUMNS;
BLOCK_XY_SPACING = BLOCK_WIDTH * 0.07;
EXPLODE_PART_COUNT = 35;
EXPLODE_ALPHA_CHANGE = 10;
HUD_TOP_SIZE_PERCENT = 8.0;
HUD_BOTTOM_SIZE_PERCENT = 15.0;
if (IS_ANDROID_MODE) {
androidSetup(); // Do the android specific bits
}
//
// Finish setup
//
frameRate(FRAME_RATE); // Bump framerate to 90 FPS (default 60)
startGame();
//
// Print some debugging info
//
println("freeballz!setup: Complete");
println("\tBALL_RADIUS: ", BALL_RADIUS);
println("\tSHOT_SPEED: ", SHOT_SPEED);
println("\tSMALL_TEXT_SIZE: ", SMALL_TEXT_SIZE);
println("\tBLOCK_COLUMNS: ", BLOCK_COLUMNS);
println("\tBLOCK_WIDTH: ", BLOCK_WIDTH);
println("\tBLOCK_RADIUS: ", BLOCK_RADIUS);
println("\tBLOCK_XY_SPACING: ", BLOCK_XY_SPACING);
println("\tDEFAULT_TEXT_SIZE: ", DEFAULT_TEXT_SIZE);
println("\tEXPLODE_PART_COUNT: ", EXPLODE_PART_COUNT);
println("\tEXPLODE_PART_BWIDTH: ", EXPLODE_PART_BWIDTH);
println("\tEXPLODE_PART_MAX_SPEED: ", EXPLODE_PART_MAX_SPEED);
println("\tEXPLODE_PART_MIN_SPEED: ", EXPLODE_PART_MIN_SPEED);
println("\tEXPLODE_PART_RADIUS: ", EXPLODE_PART_RADIUS);
println("\tEXPLODE_ALPHA_CHANGE: ", EXPLODE_ALPHA_CHANGE);
println("\tHUD_TOP_SIZE_PERCENT: ", HUD_TOP_SIZE_PERCENT);
println("\tHUD_BOTTOM_SIZE_PERCENT: ", HUD_BOTTOM_SIZE_PERCENT);
println("\tSLIDE_VELOCITY: ", SLIDE_VELOCITY);
println("\tBUTTON_RADIUS: ", BUTTON_RADIUS);
println("freeballz!setup: Screen stats");
println("\tScreen Width: ", width);
println("\tScreen Height: ", height);
println("\tDisplay density: ", getDisplayDensity());
}
void draw() {
/*
* Builtin method provided by Processing. This is
* called on each frame.
*/
background(60); // Set background to black
switch(currentState) {
case START_SCREEN:
startScreen.display();
break;
case PLAYING:
ENGINE.display();
break;
}
}
void mousePressed() {
/*
* Called when the mouse or touch is pressed
*/
switch(currentState) {
case START_SCREEN:
startScreen.handleInput(InputType.TOUCH_START);
break;
case PLAYING:
ENGINE.handleInput(InputType.TOUCH_START);
break;
}
}
void mouseReleased() {
/*
* Called when the mouse or touch is released
*/
switch(currentState) {
case START_SCREEN:
startScreen.handleInput(InputType.TOUCH_END);
break;
case PLAYING:
ENGINE.handleInput(InputType.TOUCH_END);
break;
}
}
void mouseMoved() {
/*
* Called when the mouse or touch is moved
*/
switch(currentState) {
case START_SCREEN:
startScreen.handleInput(InputType.TOUCH_MOVE);
break;
case PLAYING:
ENGINE.handleInput(InputType.TOUCH_MOVE);
break;
}
}