mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +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) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void MapView::onCenteredTile(const int3 & tile)
|
||||
|
@ -50,6 +50,8 @@ class MapView : public BasicMapView
|
||||
std::shared_ptr<MapViewActions> actions;
|
||||
|
||||
std::map<uint64_t, Point> swipeHistory;
|
||||
double postSwipeAngle;
|
||||
double postSwipeSpeed;
|
||||
|
||||
void postSwipe(uint32_t msPassed);
|
||||
|
||||
|
@ -116,6 +116,11 @@ public:
|
||||
return std::sqrt(lengthSquared());
|
||||
}
|
||||
|
||||
double angle() const
|
||||
{
|
||||
return std::atan2(y, x) * 180.0 / M_PI;
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user