mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-26 00:47:00 +00:00
rv::pentaroll:: improved
This commit is contained in:
parent
5b280f4198
commit
02940f0276
@ -10,20 +10,12 @@
|
|||||||
|
|
||||||
namespace hr {
|
namespace hr {
|
||||||
|
|
||||||
|
namespace pentaroll {
|
||||||
|
|
||||||
bool animated;
|
bool animated;
|
||||||
|
|
||||||
int args() {
|
void create_pentaroll() {
|
||||||
using namespace arg;
|
|
||||||
|
|
||||||
if(0) ;
|
|
||||||
|
|
||||||
else if(argis("-pentaroll")) {
|
|
||||||
PHASEFROM(3);
|
|
||||||
start_game();
|
start_game();
|
||||||
|
|
||||||
/* 1 = animated, 0 = not animated */
|
|
||||||
shift(); animated = argi();
|
|
||||||
|
|
||||||
/* get the list of all close cells */
|
/* get the list of all close cells */
|
||||||
cell *c0 = currentmap->gamestart();
|
cell *c0 = currentmap->gamestart();
|
||||||
celllister cl(c0, 4, 1000, nullptr);
|
celllister cl(c0, 4, 1000, nullptr);
|
||||||
@ -64,12 +56,32 @@ int args() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int args() {
|
||||||
|
using namespace arg;
|
||||||
|
|
||||||
|
if(0) ;
|
||||||
|
|
||||||
|
else if(argis("-pentaroll")) {
|
||||||
|
PHASEFROM(3);
|
||||||
|
|
||||||
|
/* 1 = animated, 0 = not animated */
|
||||||
|
shift(); animated = argi();
|
||||||
|
}
|
||||||
|
|
||||||
else return 1;
|
else return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* currently not configurable */
|
||||||
|
|
||||||
|
/* if <1, stay closer to the center */
|
||||||
|
ld how_far = 1;
|
||||||
|
ld orig_distance = 1;
|
||||||
|
ld far_distance = 1;
|
||||||
|
|
||||||
auto hooks =
|
auto hooks =
|
||||||
addHook(hooks_args, 100, args)
|
addHook(hooks_args, 100, args)
|
||||||
|
+ addHook(hooks_clearmemory, 40, [] () { animated = false; })
|
||||||
+ addHook(anims::hooks_anim, 100, [] {
|
+ addHook(anims::hooks_anim, 100, [] {
|
||||||
|
|
||||||
if(!animated) return;
|
if(!animated) return;
|
||||||
@ -79,9 +91,31 @@ auto hooks =
|
|||||||
|
|
||||||
int tb = int(t) % cgi.face;
|
int tb = int(t) % cgi.face;
|
||||||
|
|
||||||
hyperpoint h1 = normalize(cgi.vertices_only[tb]);
|
hyperpoint m;
|
||||||
hyperpoint h2 = normalize(cgi.vertices_only[(tb+1) % cgi.face]);
|
for(int i=0; i<cgi.face; i++) m += cgi.vertices_only[i];
|
||||||
hyperpoint h3 = normalize(cgi.vertices_only[(tb+2) % cgi.face]);
|
m /= cgi.face;
|
||||||
|
|
||||||
|
auto normm = [&] (hyperpoint h) {
|
||||||
|
return normalize(lerp(m, h, how_far));
|
||||||
|
};
|
||||||
|
|
||||||
|
hyperpoint h1 = normm(cgi.vertices_only[tb]);
|
||||||
|
hyperpoint h2 = normm(cgi.vertices_only[(tb+1) % cgi.face]);
|
||||||
|
hyperpoint h3 = normm(cgi.vertices_only[(tb+2) % cgi.face]);
|
||||||
|
|
||||||
|
hyperpoint a = gpushxto0(h2) * h1;
|
||||||
|
hyperpoint b = gpushxto0(h2) * h3;
|
||||||
|
b = spintox(a) * b;
|
||||||
|
a = spintox(a) * a;
|
||||||
|
b[3] = 0;
|
||||||
|
println(hlog, "a = ", a);
|
||||||
|
println(hlog, "b = ", b);
|
||||||
|
|
||||||
|
b /= hypot_d(3, b);
|
||||||
|
ld angle = acos(b[0]);
|
||||||
|
|
||||||
|
println(hlog, "b = ", b);
|
||||||
|
println(hlog, "angle = ", angle / degree, " deg");
|
||||||
|
|
||||||
ld tf = t - floor(t);
|
ld tf = t - floor(t);
|
||||||
|
|
||||||
@ -100,13 +134,15 @@ auto hooks =
|
|||||||
|
|
||||||
/* we move the camera backward */
|
/* we move the camera backward */
|
||||||
|
|
||||||
View = zpush(1) * View;
|
View = zpush(lerp(orig_distance, far_distance, frac(ticks * 1. / anims::period))) * View;
|
||||||
|
|
||||||
/* we also need to rotate the view to make it smooth */
|
/* we also need to rotate the view to make it smooth */
|
||||||
|
|
||||||
View = spin(-(cgi.face == 4 ? 117 : 90) * degree * int(t)) * View;
|
View = spin((angle-M_PI) * int(t)) * View;
|
||||||
|
|
||||||
anims::moved();
|
anims::moved();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user