Skip to content

Commit

Permalink
Merge pull request #34 from huhuhu0420/main
Browse files Browse the repository at this point in the history
add sidebar & solve mouse move detect error
  • Loading branch information
nonorze-VOXX authored Apr 6, 2023
2 parents 1edd592 + 679c8cc commit 24a12bc
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 13 deletions.
Binary file added Resources/map/easy/sidebar.bmp
Binary file not shown.
Binary file added Resources/map/hard/sidebar.bmp
Binary file not shown.
Binary file added Resources/map/medium/sidebar.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion Source/Game/BtdClass/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ namespace Btd
void GameManager::OnShow()
{
map->ShowBackground();
map->ShowFactoryButton();
map->ShowRoad();
map->ShowFactoryButton();
for (int i = 0; i < static_cast<int>(TowerFactory::TowerVector.size()); i++)
{
TowerFactory::TowerVector[i]->TowerShow();
Expand Down
18 changes: 9 additions & 9 deletions Source/Game/BtdClass/TowerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ void Btd::TowerFactory::MakeTower(TowerType attribute)
}
case ice:
{
shared_ptr<IceTower> ice = make_shared<IceTower>(IceTower());
ice->LoadBitmapByString({"resources/towers/ice/tower_ice.bmp"}, RGB(0, 0, 0));
ice->SetCenter(GetCursorPosX(), GetCursorPosY());
ice->SetIsMove(true);
ice->SetShootDeltaTime(3);
ice->SetActive(false);
ice->RangeCircle.LoadBitmapByString({"resources/towers/range.bmp", "resources/towers/range_red.bmp"}, RGB(0, 0, 0));
ice->RangeCircle.SetCenter(GetCursorPosX(), GetCursorPosY());
TowerVector.push_back(ice);
// shared_ptr<IceTower> ice = make_shared<IceTower>(IceTower());
// ice->LoadBitmapByString({"resources/towers/ice/tower_ice.bmp"}, RGB(0, 0, 0));
// ice->SetCenter(GetCursorPosX(), GetCursorPosY());
// ice->SetIsMove(true);
// ice->SetShootDeltaTime(3);
// ice->SetActive(false);
// ice->RangeCircle.LoadBitmapByString({"resources/towers/range.bmp", "resources/towers/range_red.bmp"}, RGB(0, 0, 0));
// ice->RangeCircle.SetCenter(GetCursorPosX(), GetCursorPosY());
// TowerVector.push_back(ice);
}
default:
break;
Expand Down
7 changes: 7 additions & 0 deletions Source/Game/BtdClass/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ namespace Btd
tmpRoad.SetTag("road");
_road.push_back(tmpRoad);
}
_sidebar.LoadBitmapByString({"resources/map/" + roadPath[type] + "/sidebar.bmp"});
_sidebar.SetTopLeft(732, 11);
}

void Map::ShowRoad()
Expand All @@ -109,6 +111,7 @@ namespace Btd
{
_road[i].ShowBitmap();
}
_sidebar.ShowBitmap();
}

void Map::InitBackground(MapType::MapType type)
Expand Down Expand Up @@ -200,6 +203,10 @@ namespace Btd
return true;
}
}
if (Btd::IsOverlap(_sidebar, target))
{
return true;
}
return false;
};

Expand Down
1 change: 1 addition & 0 deletions Source/Game/BtdClass/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace Btd
static vector<Vector2> _route;
static Vector2 _startPosition;
vector<vector<UnitRound>> _rounds;
GameObject _sidebar;
};
}

Expand Down
12 changes: 9 additions & 3 deletions Source/Game/mygame_initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ void CGameStateInit::OnLButtonDown(UINT nFlags, CPoint point)

void CGameStateInit::OnMouseMove(UINT nFlags, CPoint point)
{
for (int i = 0; i < 3; i++)
if (_mapButton[2].IsBitmapLoaded())
{
if (IsCursorInObj(static_cast<Btd::GameObject>(_mapButton[i])))
for (int i = 0; i < 3; i++)
{
map = selectedMaps[i];
if (IsCursorInObj(static_cast<Btd::GameObject>(_mapButton[i])))
{
if (Btd::IsCursorInObj(static_cast<Btd::GameObject>(_mapButton[i])))
{
map = selectedMaps[i];
}
}
}
}
}
Expand Down

0 comments on commit 24a12bc

Please sign in to comment.