-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGather.pde
99 lines (77 loc) · 2.14 KB
/
Gather.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
import java.util.List;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map;
static final boolean DEBUG = false;
static final int SCREEN_WIDTH = 640;
static final int SCREEN_HEIGHT = 480;
static final int FPS = 60;
static final int ENEMY_SPAWN_RATE = 2;
static final float BASE_ENEMY_SPAWN_CHANCE = 0.1;
static final float ENEMY_SPAWN_CHANCE_MINUTE_STEP = 0.15;
static final int POWERUP_SPAWN_CAP = 16;
static final float POWERUP_SPAWN_CHANCE = 0.6;
static final int WIN_TIMER_FRAMES = (int) (1.5 * FPS);
static final int TUTORIAL_CUTOFF = 400;
static final float SNOWFLAKE_SPAWN_CHANCE = 0.6;
Screen screen;
Player player;
int counter;
int winTimer = WIN_TIMER_FRAMES;
float healthBarTop;
boolean hideTutorial;
static Gather instance;
void settings() {
size(SCREEN_WIDTH, SCREEN_HEIGHT);
}
void setup() {
frameRate(FPS);
Gather.instance = this;
initialize();
}
void initialize() {
Graphics.configure(this);
Audio.configure(this);
Input.configure(this);
changeAppIcon("artifact0.png");
screen = new TitleScreen();
hideTutorial = false;
}
void reset() {
Level.configure(this);
screen = new GameScreen();
counter = 0;
spawnPowerups();
Artifact artifact = new Artifact();
artifact.spawn();
Level.addEntity(artifact);
player = new Player(30, 100);
healthBarTop = (float) player.health / Player.MAX_HP;
Level.addEntity(player);
spawnInitialSnow();
Audio.play("ambient1.mp3", true);
}
void draw() {
textFont(Graphics.getFont());
if (screen instanceof GameScreen) {
if (DEBUG && Input.pressKey('w')) {
Level.addEntity(Level.setRandomSpawnPosition(getRandomPowerup(0, 0), player));
}
if (!hideTutorial && player.x > TUTORIAL_CUTOFF) {
hideTutorial = true;
}
if (player.health <= 0) {
screen = new DeathScreen();
player.hidden = true;
}
else if (player.hasArtifact && (player.x == 0 || player.x + player.width == Level.mapWidth())) {
screen = new WinScreen();
player.hidden = true;
}
}
screen.draw();
}
void changeAppIcon(String filename) {
PImage image = Graphics.fetchImage(filename);
surface.setIcon(image);
}