1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

ready draft

This commit is contained in:
Michael
2023-08-26 21:29:24 +02:00
committed by GitHub
parent 2286e0c7b1
commit e57e9e8e9f

View File

@@ -129,7 +129,9 @@ void MapView::onMapSwiped(const Point & viewPosition)
}
void MapView::postSwipe(uint32_t msPassed) {
if(!actions->dragActive && swipeHistory.size() > 0)
if(!actions->dragActive)
{
if(swipeHistory.size() > 1)
{
Point diff = Point(0, 0);
for (auto & x : swipeHistory)
@@ -139,16 +141,13 @@ void MapView::postSwipe(uint32_t msPassed) {
postSwipeAngle = diff.angle();
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
std::cout << postSwipeAngle << " " << postSwipeSpeed << " " << diff.x << "x" << diff.y << " " << timediff << "\n";
}
swipeHistory.clear();
}
if(postSwipeSpeed > 0.1) {
double len = postSwipeSpeed * static_cast<double>(msPassed);
Point delta = Point(len * cos(postSwipeAngle), len * sin(postSwipeAngle));
std::cout << len << " " << delta.x << "x" << delta.y << "\n";
controller->setViewCenter(model->getMapViewCenter() + delta, model->getLevel());
postSwipeSpeed /= 1.1;