PGR Copakond OpenGL Engine - Bowling
Loading...
Searching...
No Matches
bowlingGame.h
Go to the documentation of this file.
1#ifndef PGR_SEM_COPAKOND_BOWLINGGAME_H
2#define PGR_SEM_COPAKOND_BOWLINGGAME_H
3
4#include "collisionPin.h"
5#include <vector>
6
7#define TOTAL_ROUNDS 3
8
9namespace copakond {
10 class Light;
11 class Camera;
12 class RigidSphere;
13 class RigidBody;
14 class Mesh;
15 class TextLabel;
16 class ImageSequenceLabel;
17 class ImageSequence;
19 enum class BowlingLightMode { NORMAL, OFF, DISCO };
20
23 glm::vec3 originalDiffuse;
24 glm::vec3 targetDiffuse;
25 };
26
29 private:
30 int videoPlayingALleyId = 0;
31 float timeToDespawnBowlingBall = 0.0f;
32 float videoTimeout = 999.0f;
33 bool rollingBowlingBallNow = false;
34
35 int score1[TOTAL_ROUNDS*2+1] = {0,0,0,0,0,0,0};
36 int score2[TOTAL_ROUNDS*2+1] = {0,0,0,0,0,0,0};
37 int score3[TOTAL_ROUNDS*2+1] = {0,0,0,0,0,0,0};
38 int score4[TOTAL_ROUNDS*2+1] = {0,0,0,0,0,0,0};
39
40 bool bowlingAlleyOpened1 = false;
41 bool bowlingAlleyOpened2 = false;
42 bool bowlingAlleyOpened3 = false;
43 bool bowlingAlleyOpened4 = false;
44
45 float offsetDoor1 = 0.0f;
46 float offsetDoor2 = 0.0f;
47 float offsetDoor3 = 0.0f;
48 float offsetDoor4 = 0.0f;
49
50 bool canBeUsed1 = true;
51 bool canBeUsed2 = true;
52 bool canBeUsed3 = true;
53 bool canBeUsed4 = true;
54
55
56 Mesh *selectedBowlingBall = nullptr;
57 Camera *camera;
58 glm::vec3 plrThrowPos = glm::vec3(0.0f);
59
60 int currentSubround[4] = {0, 0, 0, 0};
61 float gameOverTimer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
62 bool isGameOver[4] = {false, false, false, false};
63
64 int getClosestAlleyToBowlingBall();
65 int resetBowlingBall(); // also returning the number of pins down
66 bool checkIfBowlingBallHitTheWall() const;
67 void renderText(int alley);
68 void playVideo(BowlingVideoEvent event, int alley);
69
70 void evaluateScore(int alley, int pinsKnocked);
71 void resetPinsForAlley(int alley);
72 void resetGameForAlley(int alley);
73
74 // for light modes
75 float discoTimer = 0.0f;
76 void updateArenaLights(float deltaTime);
77
78 public:
79 BowlingGame(Camera *camera) : camera(camera) {};
80
82 void update(float deltaTime);
83
85 void pickBowlingBall(Mesh* bowlingBall, float power = 2.0f);
86
88 void throwBall(float power = 2.0f);
89
90 void toggleDoor1();
91 void toggleDoor2();
92 void toggleDoor3();
93 void toggleDoor4();
94
95 void turnOffAllLights();
96 void resetLights();
97 void setDiscoMode();
98
99 RigidBody *player = nullptr;
100
101 Mesh *door1 = nullptr;
102 Mesh *door2 = nullptr;
103 Mesh *door3 = nullptr;
104 Mesh *door4 = nullptr;
105
106 std::vector<CollisionPin*> pins;
108
113
119
124
125 std::vector<BowlingLightData> arenaLights;
127 };
128}
129
130#endif //PGR_SEM_COPAKOND_BOWLINGGAME_H
#define TOTAL_ROUNDS
Definition bowlingGame.h:7
TextLabel * scoreLabel2
Definition bowlingGame.h:110
TextLabel * scoreLabel1
Definition bowlingGame.h:109
void toggleDoor3()
Definition bowlingGame.cpp:234
ImageSequenceLabel * videoIdle1
Definition bowlingGame.h:120
void turnOffAllLights()
Definition bowlingGame.cpp:421
BowlingGame(Camera *camera)
Definition bowlingGame.h:79
std::vector< BowlingLightData > arenaLights
Definition bowlingGame.h:125
ImageSequenceLabel * videoMiss4
Definition bowlingGame.h:117
ImageSequenceLabel * videoIdle3
Definition bowlingGame.h:122
Mesh * door3
Definition bowlingGame.h:103
void throwBall(float power=2.0f)
Releases ball with current velocity and direction.
Definition bowlingGame.cpp:182
Mesh * door4
Definition bowlingGame.h:104
void pickBowlingBall(Mesh *bowlingBall, float power=2.0f)
Attaches ball to player and prepares for throw.
Definition bowlingGame.cpp:207
Mesh * door1
Definition bowlingGame.h:101
void update(float deltaTime)
Evaluates pin states and manages game progression.
Definition bowlingGame.cpp:81
void toggleDoor1()
Definition bowlingGame.cpp:214
void setDiscoMode()
Definition bowlingGame.cpp:435
TextLabel * scoreLabel3
Definition bowlingGame.h:111
ImageSequenceLabel * videoEnd5
Definition bowlingGame.h:118
void toggleDoor2()
Definition bowlingGame.cpp:224
void resetLights()
Definition bowlingGame.cpp:428
ImageSequenceLabel * videoSplit1
Definition bowlingGame.h:114
ImageSequenceLabel * videoStrike3
Definition bowlingGame.h:116
RigidSphere * bowlingBall
Definition bowlingGame.h:107
BowlingLightMode lightMode
Definition bowlingGame.h:126
Mesh * door2
Definition bowlingGame.h:102
ImageSequenceLabel * videoSpare2
Definition bowlingGame.h:115
std::vector< CollisionPin * > pins
Definition bowlingGame.h:106
RigidBody * player
Definition bowlingGame.h:99
TextLabel * scoreLabel4
Definition bowlingGame.h:112
void toggleDoor4()
Definition bowlingGame.cpp:244
ImageSequenceLabel * videoIdle4
Definition bowlingGame.h:123
ImageSequenceLabel * videoIdle2
Definition bowlingGame.h:121
Camera for generating view and projection matrices.
Definition camera.h:20
2D plane that plays an animation by cycling through a sprite sheet texture
Definition imageSequenceLabel.h:8
Base class for scene lighting calculations.
Definition light.h:23
Base drawable 3D object containing geometry and material data.
Definition mesh.h:19
Kinematic object affected by gravity, friction, and collision resolution.
Definition rigidBody.h:7
Kinematic sphere that automatically rolls based on its horizontal velocity.
Definition rigidSphere.h:7
Dynamically generates 2D geometry to render text using a bitmap font atlas.
Definition textLabel.h:9
PGR Semestral work with sample scenes and bowling. doxygen was generated with a help of LLM.
Definition bezier.cpp:3
BowlingVideoEvent
Definition bowlingGame.h:18
@ SPARE
Definition bowlingGame.h:18
@ STRIKE
Definition bowlingGame.h:18
@ MISS
Definition bowlingGame.h:18
@ SPLIT
Definition bowlingGame.h:18
@ END
Definition bowlingGame.h:18
BowlingLightMode
Definition bowlingGame.h:19
@ DISCO
Definition bowlingGame.h:19
@ NORMAL
Definition bowlingGame.h:19
@ OFF
Definition bowlingGame.h:19
Definition bowlingGame.h:21
glm::vec3 originalDiffuse
Definition bowlingGame.h:23
Light * light
Definition bowlingGame.h:22
glm::vec3 targetDiffuse
Definition bowlingGame.h:24