Skip to content

Commit

Permalink
Merge branch 'dev' into collider-change-heal-ring
Browse files Browse the repository at this point in the history
  • Loading branch information
junweic01 committed Jun 7, 2024
2 parents 430a967 + 9f32694 commit 5a60dac
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 30 deletions.
7 changes: 3 additions & 4 deletions _common/include/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ class Player : public Entity {

// I = 73, J = 74, K = 75, L = 76
std::vector<int> attack1 = {J, J, J, J};
std::vector<int> attack2 = {J, K, L, I};
std::vector<int> heal = {K, K, K, K};
std::vector<int> revive = {L, L, L, L};
std::vector<int> speedBoost = {I, I, I, I};
std::vector<int> heal = {J, K, L, I};
std::vector<int> revive = {I, K, J, L};
std::vector<int> speedBoost = {J, J, I, I};

int32_t TypeID() const override { return PLAYER; }

Expand Down
Binary file added assets/HUD/music-note3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions client/include/HUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class HUDs : public States, public IComponent {
void update(float dt);
std::string ToString() override;
void setComboCount(int count);
void setComboType(int type);
// private:
TeamInfo* teamInfo;
Metronome* metronome;
Expand All @@ -24,7 +25,7 @@ class HUDs : public States, public IComponent {
Quad* text;
std::vector<Quad*> musicNotes;
HealthBar* bossHealth;
Quad* hitText;
Quad* attackTypeText;
Quad* bearIcon;

private:
Expand All @@ -37,4 +38,12 @@ class HUDs : public States, public IComponent {
int comboCount = 0;
float hitOpacity = 0.0f;
bool isComboHit = false;
};

};
/*
playerCombat->AddCombo(attack1, 1);
playerCombat->AddCombo(attack2, 2);
playerCombat->AddCombo(heal, 3);
playerCombat->AddCombo(revive, 4);
playerCombat->AddCombo(speedBoost, 5);
*/
12 changes: 5 additions & 7 deletions client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,18 @@ int main(int argc, char** argv) {
// Create the GLFW window.
float width = 1366;
float height = 768;

// set up camera
GameManager::instance().cam = new Camera();
GameManager::instance().cam->SetAspect(float(width) / float(height));
GLFWwindow* window = Window::createWindow(width, height);
if (!window)
exit(EXIT_FAILURE);


printf(YLW "Loading...\n" RST);
GameManager::instance().Init();
printf(YLW "Done loading!n" RST);


// Print OpenGL and GLSL versions.
print_versions();
// Setup callbacks.
Expand All @@ -106,10 +104,10 @@ int main(int argc, char** argv) {
[&, params]() { GameManager::instance().handle_packet(params); });
});

AudioManager::instance().AddNote("../assets/audio/Fsharp.wav", 'i');
AudioManager::instance().AddNote("../assets/audio/Gsharp.wav", 'j');
AudioManager::instance().AddNote("../assets/audio/A.wav", 'k');
AudioManager::instance().AddNote("../assets/audio/Csharp.wav", 'l');
AudioManager::instance().AddNote("../assets/audio/Fsharp.wav", 'j');
AudioManager::instance().AddNote("../assets/audio/Gsharp.wav", 'k');
AudioManager::instance().AddNote("../assets/audio/A.wav", 'l');
AudioManager::instance().AddNote("../assets/audio/Csharp.wav", 'i');

AudioManager::instance().AddHit("../assets/audio/playertakedamage.wav");

Expand Down
49 changes: 35 additions & 14 deletions client/src/HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ HUDs::HUDs(GameObject* owner) : IComponent(owner) {
text->setTexture("miss.png", "../assets/HUD/text");
text->enableState(VISIBLE);
text->setOpacity(opacity);
hitText = new Quad(glm::vec3(0.0f, 0.3f, 0.0f), 0.2f);
hitText->setTexture("hit.png", "../assets/HUD/text");
hitText->setTexture("heal.png", "../assets/HUD/text");
hitText->setTexture("revive.png", "../assets/HUD/text");
hitText->setTexture("speed.png", "../assets/HUD/text");
hitText->enableState(VISIBLE);
hitText->setOpacity(opacity);
attackTypeText = new Quad(glm::vec3(0.0f, 0.3f, 0.0f), 0.2f);
attackTypeText->setTexture("hit.png", "../assets/HUD/text");
attackTypeText->setTexture("heal.png", "../assets/HUD/text");
attackTypeText->setTexture("revive.png", "../assets/HUD/text");
attackTypeText->setTexture("speed.png", "../assets/HUD/text");
attackTypeText->enableState(VISIBLE);
attackTypeText->setOpacity(opacity);
float dy = 0.0f;
for (int i = 0; i < 4; i++) {
musicNotes.push_back(
new Quad(glm::vec3(0.9f, -0.5f + dy, 0.0f), 0.07f));
musicNotes[i]->setTexture("music-note2.png", "../assets/HUD");
new Quad(glm::vec3(0.9f, -0.5f + dy, 0.0f), 0.09f));
musicNotes[i]->setTexture("music-note3.png", "../assets/HUD");
musicNotes[i]->enableState(VISIBLE);
musicNotes[i]->setOpacity(0.2);
dy += 0.2f;
Expand All @@ -52,7 +52,7 @@ HUDs::HUDs(GameObject* owner) : IComponent(owner) {

bearIcon->update();
text->update();
hitText->update();
attackTypeText->update();
}

void HUDs::draw(float aspectRatio) {
Expand All @@ -62,7 +62,7 @@ void HUDs::draw(float aspectRatio) {
teamInfo->draw(aspectRatio);
metronome->draw(aspectRatio);
text->draw(aspectRatio);
hitText->draw(aspectRatio);
attackTypeText->draw(aspectRatio);
bearIcon->draw(aspectRatio);
endgame->draw(aspectRatio);
for (int i = 0; i < musicNotes.size(); i++) {
Expand Down Expand Up @@ -112,13 +112,13 @@ void HUDs::update(float dt) {
}

// hitText->setPosition(glm::vec3(0.0f, hitY, 0.0f));
hitText->setOpacity(hitOpacity);
attackTypeText->setOpacity(hitOpacity);

healthBar->update();
teamInfo->update();
metronome->update();
text->update();
hitText->update();
attackTypeText->update();
bossHealth->update();
bearIcon->update();

Expand Down Expand Up @@ -154,7 +154,28 @@ void HUDs::setComboCount(int count) { comboCount = count; }

void HUDs::triggleHitText(int comboType) {
isComboHit = true;
hitText->activateTexture(comboType <= 2 ? 0 : comboType - 2);
attackTypeText->activateTexture(comboType <= 2 ? 0 : comboType - 2);
hitY = 0.1f;
hitOpacity = 1.0f;
}

void HUDs::setComboType(int type) {
isComboHit = true;
switch(type){
case 1:
case 2:
attackTypeText->activateTexture(0);
break;
case 3:
attackTypeText->activateTexture(1);
break;
case 4:
attackTypeText->activateTexture(2);
break;
case 5:
attackTypeText->activateTexture(3);
break;
}
hitY = 0.1f;
hitOpacity = 1.0f;
}
3 changes: 1 addition & 2 deletions server/src/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ void NetworkManager::process_input() {
if (!comboSeq.empty()) {
printf(YLW "COMBO HIT\n" RST);

if (comboSeq == clients[client_id]->p->attack1 ||
comboSeq == clients[client_id]->p->attack2) {
if (comboSeq == clients[client_id]->p->attack1) {
AttackManager::instance().newPlayerAttack(
clients[client_id]->p);
}
Expand Down
1 change: 0 additions & 1 deletion server/src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Player::Player(glm::vec3 position, int clientId) : Entity() {
// I = 73, J = 74, K = 75, L = 76
// TODO make player-specific combos
playerCombat->AddCombo(attack1, 1);
playerCombat->AddCombo(attack2, 2);
playerCombat->AddCombo(heal, 3);
playerCombat->AddCombo(revive, 4);
playerCombat->AddCombo(speedBoost, 5);
Expand Down

0 comments on commit 5a60dac

Please sign in to comment.