mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
angle calc
This commit is contained in:
parent
bd0f9bb280
commit
fe6d96f4a0
@ -129,8 +129,14 @@ void MapView::onMapSwiped(const Point & viewPosition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MapView::postSwipe(uint32_t msPassed) {
|
void MapView::postSwipe(uint32_t msPassed) {
|
||||||
if(!actions->dragActive)
|
if(!actions->dragActive && swipeHistory.size() > 0)
|
||||||
|
{
|
||||||
|
Point diff = swipeHistory.end()->second - swipeHistory.begin()->second;
|
||||||
|
double angle = diff.angle();
|
||||||
|
|
||||||
|
std::cout << angle;
|
||||||
swipeHistory.clear();
|
swipeHistory.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::onCenteredTile(const int3 & tile)
|
void MapView::onCenteredTile(const int3 & tile)
|
||||||
|
@ -50,6 +50,8 @@ class MapView : public BasicMapView
|
|||||||
std::shared_ptr<MapViewActions> actions;
|
std::shared_ptr<MapViewActions> actions;
|
||||||
|
|
||||||
std::map<uint64_t, Point> swipeHistory;
|
std::map<uint64_t, Point> swipeHistory;
|
||||||
|
double postSwipeAngle;
|
||||||
|
double postSwipeSpeed;
|
||||||
|
|
||||||
void postSwipe(uint32_t msPassed);
|
void postSwipe(uint32_t msPassed);
|
||||||
|
|
||||||
|
@ -116,6 +116,11 @@ public:
|
|||||||
return std::sqrt(lengthSquared());
|
return std::sqrt(lengthSquared());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double angle() const
|
||||||
|
{
|
||||||
|
return std::atan2(y, x) * 180.0 / M_PI;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
void serialize(Handler &h, const int version)
|
void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user