1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 09:00:34 +00:00

more options in line animation

This commit is contained in:
Zeno Rogue 2019-04-03 20:27:45 +02:00
parent 44495852ad
commit 4284831069
5 changed files with 44 additions and 22 deletions

View File

@ -288,6 +288,8 @@ namespace conformal {
bool dospiral = true;
ld extra_line_steps = 0;
vector<cell*> path_for_lineanimation;
void clear() {
on = false;
@ -295,31 +297,31 @@ namespace conformal {
for(int i=0; i<N; i++) delete v[i];
v.resize(0);
}
void create() {
if(celldist(cwt.at) == 0) {
void create(cell *start, cell *target) {
if(target == start) {
addMessage("Must go a distance from the starting point");
return;
}
on = true;
cell *c = cwt.at;
while(true) {
if(!quotient) try {
path_for_lineanimation = build_shortest_path(start, target);
}
catch(hr_shortest_path_exception&) {
addMessage("Error: could not build a path");
return;
}
for(cell *c: path_for_lineanimation) {
shmup::monster *m = new shmup::monster;
m->at = Id;
m->base = c;
v.push_back(m);
if(c == currentmap->gamestart()) break;
for(int i=0; i<c->type; i++)
if(celldist(c->move(i)) < celldist(c)) {
c = c->move(i);
break;
}
}
reverse(v.begin(), v.end());
int Q = isize(v)-1;
// virtualRebase(v[0], false);
// virtualRebase(v[Q], false);
@ -352,6 +354,14 @@ namespace conformal {
llv = ticks;
phase = 0;
}
void create_playerpath() {
create(currentmap->gamestart(), cwt.at);
}
void create_recenter_to_view() {
create(path_for_lineanimation[0], centerover.at ? centerover.at : cwt.at);
}
void movetophase() {
@ -448,6 +458,11 @@ namespace conformal {
spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]);
}
if(centerover.at && !on)
if(isize(path_for_lineanimation) == 0 || (quotient && path_for_lineanimation.back() != centerover.at)) {
path_for_lineanimation.push_back(centerover.at);
}
band_shift = 0;
}
@ -1026,8 +1041,10 @@ namespace conformal {
dialog::addSelItem(XLAT("projection"), current_proj_name(), 'm');
if(!bounded && !euclid) dialog::addBoolItem(XLAT("prepare the line animation"), (on), 'e');
dialog::addBoolItem(XLAT("animate from start to current player position"), (on), 'e');
dialog::addBoolItem(XLAT("animate from last recenter to current view"), (on), 'E');
if(on) dialog::addSelItem(XLAT("animation speed"), fts(lvspeed), 'a');
else dialog::addBreak(100);
dialog::addSelItem(XLAT("extend the ends"), fts(extra_line_steps), 'p');
#if CAP_SDL
@ -1053,7 +1070,7 @@ namespace conformal {
void handleKeyC(int sym, int uni) {
dialog::handleNavigation(sym, uni);
if(uni == 'e') {
if(uni == 'e' || uni == 'E') {
if(on) clear();
else {
if(canmove && !cheater) {
@ -1061,7 +1078,8 @@ namespace conformal {
return;
}
if(canmove && cheater) cheater++;
create();
if(uni == 'E') create_recenter_to_view();
else create_playerpath();
}
}
else if(uni == 'o')
@ -1148,7 +1166,7 @@ namespace conformal {
bool ih = includeHistory;
includeHistory = autobandhistory;
pmodel = mdBand;
create();
create_playerpath();
createImage(dospiral);
clear();
pmodel = spm;
@ -1253,6 +1271,7 @@ namespace conformal {
conformal::killhistory.clear();
conformal::findhistory.clear();
conformal::movehistory.clear();
conformal::path_for_lineanimation.clear();
conformal::includeHistory = false;
});

View File

@ -1443,7 +1443,9 @@ namespace conformal {
extern int bandhalf;
extern ld extra_line_steps;
void create();
void create(cell *start, cell *target);
void create_playerpath();
void create_recenter_to_view();
void clear();
void model_menu();
void history_menu();

View File

@ -1237,6 +1237,7 @@ void panning(hyperpoint hf, hyperpoint ht) {
int cells_drawn;
void fullcenter() {
conformal::path_for_lineanimation.clear();
if(playerfound && false) centerpc(INF);
else {
bfs();

View File

@ -216,7 +216,7 @@ hint hints[] = {
bool h = conformal::includeHistory;
conformal::rotation = 0;
conformal::includeHistory = true;
conformal::create();
conformal::create_playerpath();
cancel = [m,r,h] () {
conformal::clear(); pmodel = m;
conformal::rotation = r;

View File

@ -735,7 +735,7 @@ slide default_slides[] = {
"memory.",
[] (presmode mode) {
static int smart;
if(mode == 1) pmodel = mdBand, conformal::create(), conformal::rotation = 0,
if(mode == 1) pmodel = mdBand, conformal::create_playerpath(), conformal::rotation = 0,
smart = vid.use_smart_range, vid.use_smart_range = 2;
if(mode == 3) {
conformal::clear(), pmodel = mdDisk;
@ -748,7 +748,7 @@ slide default_slides[] = {
#if CAP_SDL
slidecommand = "render spiral";
if(mode == 4) conformal::createImage(true);
if(mode == 11) conformal::create();
if(mode == 11) conformal::create_playerpath();
if(mode == 13) conformal::clear();
#endif
}