-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabyrinthJeremyCyrusBela.pde
85 lines (73 loc) · 1.84 KB
/
LabyrinthJeremyCyrusBela.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
import processing.sound.*;
SoundFile file;
PImage img;
boolean gameStart = false;
boolean leaderboardUpdated = false;
boolean titleScreenOver = false;
void setup() {
// Initialize the game window and settings
frameRate(60);
size(1100, 800);
file = new SoundFile(this,"Royalty Free Game Music Pack Casual Action - Run and Jump.mp3");
file.play();
// Initialize game data
resetScore();
setupLeaderboard();
// Load assets
img = loadImage("Title.png");
}
void draw() {
// Handle title screen display and interactions
titleScreen();
if (titleScreenOver) {
if (!gameEnd) {
handleGamePlay();
} else if (!leaderboardUpdated) {
handleGameEnd();
}
// Update leaderboard file if needed
if (playerName != null && !updatedLeaderboardFile) {
updateLeaderboardFileIfNeeded();
}
// Start the game if the mouse is in the start area
if (mouseX < 60 && mouseX > 40 && mouseY < 160 && mouseY > 140) {
gameStart = true;
}
// Display the start screen if the game hasn't started yet
if (!gameStart) {
displayStart();
}
// Continue game if started
if (gameStart) {
if (!gameEnd) {
scoreManager();
}
detectEnd();
}
}
if (keyPressed && (key == 'R')) {
gameRestart();
}
if (collision) {
image(loadImage("PlayerDmg.png"), circleX - circleRadius, circleY - circleRadius, Diameter, Diameter);
}
}
// Function to handle game play
void handleGamePlay() {
circleMovement();
isDeadCheck();
}
// Function to handle game end
void handleGameEnd() {
updateLeaderboard();
displayEnd();
displayLeaderboard();
leaderboardUpdated = true;
}
// Function to update the leaderboard file if needed
void updateLeaderboardFileIfNeeded() {
for (int i = 0; i < 1; i++) {
updateLeaderboardFile();
displayLeaderboard();
}
}