1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

replaced loop_multiplier and loop_shift with more general -animformula

This commit is contained in:
Zeno Rogue 2022-04-21 12:33:37 +02:00
parent 7e8ae4262f
commit 6e0960bb58
3 changed files with 17 additions and 9 deletions

View File

@ -96,7 +96,7 @@ void nil_screen(presmode mode, int id) {
ld t = 1e-3; ld t = 1e-3;
if(id == 2) { if(id == 2) {
t = inHighQual ? ticks * anims::loop_multiplier * 4. / anims::period : ticks / 1000.; t = inHighQual ? ticks * 4. / anims::period : ticks / 1000.;
if(t - floor(t) > .5) t = ceil(t); if(t - floor(t) > .5) t = ceil(t);
else t = floor(t) + 2 * (t - floor(t)); else t = floor(t) + 2 * (t - floor(t));
t -= floor(t/4)*4; t -= floor(t/4)*4;

View File

@ -378,7 +378,7 @@ void enable() {
rogueviz::rv_hook(anims::hooks_anim, 100, [] { rogueviz::rv_hook(anims::hooks_anim, 100, [] {
if(!animation) return; if(!animation) return;
ld t = ticks * 1. * anims::loop_multiplier / anims::period; ld t = ticks * 1. / anims::period;
t *= isize(path); t *= isize(path);
hyperpoint at = interp(t); hyperpoint at = interp(t);

View File

@ -1121,8 +1121,8 @@ EX int noframes = 30;
EX ld cycle_length = 2 * M_PI; EX ld cycle_length = 2 * M_PI;
EX ld parabolic_length = 1; EX ld parabolic_length = 1;
EX ld skiprope_rotation; EX ld skiprope_rotation;
EX ld loop_multiplier = 1;
EX ld loop_shift = 0; EX string time_formula = "-";
int lastticks, bak_turncount; int lastticks, bak_turncount;
@ -1394,6 +1394,17 @@ EX bool record_animation_of(reaction_t content) {
printf("%d/%d\n", i, noframes); printf("%d/%d\n", i, noframes);
callhooks(hooks_record_anim, i, noframes); callhooks(hooks_record_anim, i, noframes);
int newticks = i * period / noframes; int newticks = i * period / noframes;
if(time_formula != "-") {
dynamicval<int> t(ticks, newticks);
exp_parser ep;
ep.s = time_formula;
try {
newticks = ep.iparse();
}
catch(hr_parse_exception&) {
println(hlog, "warning: failed to parse time_formula");
}
}
cmode = (env_shmup ? sm::NORMAL : 0); cmode = (env_shmup ? sm::NORMAL : 0);
while(ticks < newticks) shmup::turn(1), ticks++; while(ticks < newticks) shmup::turn(1), ticks++;
if(cheater && numturns) { if(cheater && numturns) {
@ -1736,11 +1747,8 @@ int readArgs() {
else if(argis("-animperiod")) { else if(argis("-animperiod")) {
PHASEFROM(2); shift_arg_formula(period); PHASEFROM(2); shift_arg_formula(period);
} }
else if(argis("-animloop")) { else if(argis("-animformula")) {
PHASEFROM(2); shift_arg_formula(loop_multiplier); PHASEFROM(2); shift(); time_formula = args();
}
else if(argis("-animloopshift")) {
PHASEFROM(2); shift_arg_formula(loop_shift);
} }
#if CAP_SHOT #if CAP_SHOT
else if(argis("-animrecordf")) { else if(argis("-animrecordf")) {