Skip to content

Commit

Permalink
merge and run
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 committed Mar 30, 2024
1 parent fabeadd commit 82d7fd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
26 changes: 14 additions & 12 deletions include/Unit/Avatar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

#ifndef PRACTICALTOOLSFORSIMPLEDESIGN_DUMMY_HPP
#define PRACTICALTOOLSFORSIMPLEDESIGN_DUMMY_HPP
#include "Map/MapUtility.hpp"
#include "Unit/AttackAndDamageUnit.hpp"
#include "Unit/FindValidPathToDest.hpp"
#include "Unit/PathfindingUnit.hpp"

enum class UnitMode { DEAD, MOVE, IDLE, MOVE_ATTACK, ALIVE };
class Avatar : public PathfindingUnit, public AttackAndDamageUnit {

enum class UnitMode { DEAD, MOVE, IDLE, MOVE_ATTACK };


protected:
std::shared_ptr<Util::Image> m_Image;

Expand All @@ -28,8 +25,7 @@ class Avatar : public PathfindingUnit, public AttackAndDamageUnit {
virtual void Start(glm::vec2 destination) { // destination = Barrack's
// waypointLocation
// setCurrentCell() //CurrentCell = Structure's Location
this->SetDrawable(
customizeImage());
this->SetDrawable(customizeImage());
SetVisible(true);
m_grid.SetActivate(true);
setCurrentCell(destination);
Expand All @@ -53,8 +49,10 @@ class Avatar : public PathfindingUnit, public AttackAndDamageUnit {
cursorSetNewDest();
printf("-----------------------------\n");
}
virtual void customizeUpdate(){}
virtual std::shared_ptr<Util::Image> customizeImage(){ return std::make_unique<Util::Image>("../assets/sprites/capybara.png");}
virtual void customizeUpdate() {}
virtual std::shared_ptr<Util::Image> customizeImage() {
return std::make_unique<Util::Image>("../assets/sprites/capybara.png");
}
virtual void Update() override {
switch (m_currentMode) {
case (UnitMode::DEAD): {
Expand All @@ -81,11 +79,15 @@ class Avatar : public PathfindingUnit, public AttackAndDamageUnit {
Util::Input::GetCursorPosition())));
}
}
float getDistance(glm::vec2 cell){
return sqrt(pow(cell.x-getCurrentCell().x,2)+pow(cell.y-getCurrentCell().y,2));
float getDistance(glm::vec2 cell) {
return sqrt(pow(cell.x - getCurrentCell().x, 2) +
pow(cell.y - getCurrentCell().y, 2));
}

void DEBUG_printCurrentMoveDirection(MoveDirection Dir){
UnitMode getUnitMode() { return m_currentMode; }
void setUnitMode(UnitMode mode) { m_currentMode = mode; }

void DEBUG_printCurrentMoveDirection(MoveDirection Dir) {
switch (Dir) {
case MoveDirection::RIGHT: {
printf("(DEBUG)Avatar DIR:Right\n");
Expand Down
3 changes: 0 additions & 3 deletions include/Unit/PathfindingUnit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define PRACTICALTOOLSFORSIMPLEDESIGN_PATHFINDINGUNIT_HPP
#include "Grid.hpp"
#include "Line.hpp"

#include "Map/Tile.hpp"
#include "Util/GameObject.hpp"
#include "Util/Transform.hpp"
Expand Down Expand Up @@ -53,8 +52,6 @@ class PathfindingUnit : public Util::GameObject {
};
virtual ~PathfindingUnit(){};

//
UnitMode getUnitMode(){return m_currentMode;}
void setDestinationCell(int x, int y) {
this->m_destinationCell = {glm::vec2(x, y)};
}
Expand Down
8 changes: 4 additions & 4 deletions src/Scene/DefaultScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ void DefaultScene::Start() {

m_Player->setTotalCurrency(5000);

// m_hunter->setCurrentCell({20,10});
// m_runner->setCurrentCell({10,10});
m_hunter->Start({20,9},m_Map);
m_runner->Start({9,10},m_Map);
// m_hunter->setCurrentCell({20,10});
// m_runner->setCurrentCell({10,10});
m_hunter->Start({20, 9});
m_runner->Start({9, 10});
m_hunter->setTarget(m_runner);
m_runner->setBeingChase(m_hunter);
}
Expand Down

0 comments on commit 82d7fd0

Please sign in to comment.