Skip to content

Commit

Permalink
Merge branch 'main' into lastlastfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jonylu7 authored Jun 18, 2024
2 parents f9f0783 + 440a237 commit 4729a41
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Purpose

讓我認識到....不要選一個系統太複雜的遊戲
# Goal

# Methodology

## Packages used
1. openGL version 4.1
2. PTSD game Engine
3. SDL2
4. Imgui
肝、血和淚
4 changes: 4 additions & 0 deletions include/Map/Map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class MapClass : public Core::Drawable {
return NullPos;
}


int getWidth() { return m_MapWdith; }
int getHeight() { return m_MapHeight; }

protected:
void InitGrid();

Expand Down
2 changes: 2 additions & 0 deletions include/Map/Tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class TileClass {
m_Avatars.erase(it);
i--;


// if (m_Avatars.size() < 4 && m_TerrainBuildable) {
// setWalkable(true);
// }

if (m_Avatars.size() == 0) {
setBuildable(true);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Mechanics/AvatarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ void AvatarManager::assignOrderToMyAvatar(std::shared_ptr<Avatar> avatar) {

auto destcell = MapUtil::GlobalCoordToCellCoord(
MapUtil::ScreenToGlobalCoord(Util::Input::GetCursorPosition()));
if (destcell.x < 0 || destcell.y < 0 ||
destcell.x > m_Map->getWidth() / 2 - 1 ||
destcell.y > m_Map->getHeight() / 2 - 1) {
return;
}

assignMoveOrderToAvatar(avatar, destcell);
assignAttackOrderToAvatar(avatar, destcell);
Expand Down
9 changes: 8 additions & 1 deletion src/Mechanics/AvatarNavigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
std::deque<MoveDirection> AvatarNavigator::findPath(glm::vec2 currentcell,
glm::vec2 destinationcell) {
glm::vec2 ogcell = currentcell;

std::vector<std::deque<MoveDirection>> dirQueComp = {
std::deque<MoveDirection>(), std::deque<MoveDirection>()};

if (m_Map->getTileByCellPosition(destinationcell)->getWalkable() == false) {
return dirQueComp[0];
}


for (int s = 0; s < 2; s++) {
Side whichSideToTouchObstacle = static_cast<Side>(s);
int count = 0;
Expand Down Expand Up @@ -53,6 +56,7 @@ std::deque<MoveDirection> AvatarNavigator::findPath(glm::vec2 currentcell,
dirQueComp[s].push_back(i);
currentcell =
PathUtility::getNextCellByCurrent(i, currentcell);

}
}
}
Expand All @@ -69,6 +73,7 @@ std::vector<MoveDirection>
AvatarNavigator::moveAlongsideObstacle(Side side, glm::vec2 currentcell,
MoveDirection currentdir,
glm::vec2 destinationcell) {
glm::vec2 ogcell = currentcell;

std::vector<MoveDirection> path;
while (!(canResumeWalkingStraight(currentcell, destinationcell) ||
Expand All @@ -87,7 +92,9 @@ AvatarNavigator::moveAlongsideObstacle(Side side, glm::vec2 currentcell,
path.push_back(currentdir);
currentcell =
PathUtility::getNextCellByCurrent(currentdir, currentcell);
if (path.size() > 15) {

if (path.size() > 30 || ogcell == currentcell) {

return path;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Scene/TutorialScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void TutorialScene::stageStart() {
m_PlayerObjectivesText->SetVisible(true);
m_PlayerObjectivesText->setMovingRelativeToCamera(false);
Util::Transform trans;
trans.translation = {40, 5};

trans.translation = {540, 5};
trans.scale = {0.7, 0.7};
m_PlayerObjectivesText->SetTransform(trans);

Expand Down

0 comments on commit 4729a41

Please sign in to comment.