1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-10-18 06:30:41 +00:00

nilrider:: triangles should work with multiple sublevels

This commit is contained in:
Zeno Rogue 2024-08-18 21:21:18 +02:00
parent 9d680953e2
commit aa174d92c8
3 changed files with 13 additions and 6 deletions

View File

@ -374,6 +374,7 @@ void level::init() {
d.where = h;
d.x = x;
d.y = y;
d.which = this;
for(int i=0; i<7; i++)
d.colors[i] = gradient(0xFFD500FF, 0xFF, 0, i, 8);
d.colors[6] = d.colors[0];
@ -420,7 +421,11 @@ void level::init() {
init_plan();
for(auto s: sublevels) s->init();
for(auto s: sublevels) {
s->init();
for(auto& t: s->triangles) triangles.push_back(t);
s->triangles.clear();
}
}
xy_float level::get_xy_f(hyperpoint h) {

View File

@ -68,6 +68,7 @@ struct statue {
struct triangledata {
int x, y;
hyperpoint where;
level *which;
array<color_t, 7> colors;
};

View File

@ -89,12 +89,13 @@ bool timestamp::out_of_surface(level *lev) {
}
bool timestamp::collect(level *lev) {
auto xy = lev->get_xy_i(where);
char ch = lev->mapchar(xy);
auto xy = on_surface->get_xy_i(where);
char ch = on_surface->mapchar(xy);
if(ch == 'r') return false;
if(ch == '*') {
for(int i=0; i<isize(lev->triangles); i++) {
auto& t = lev->triangles[i];
if(t.which != on_surface) continue;
if(t.x == xy.first && t.y == xy.second) collected_triangles |= (1<<i);
}
}
@ -160,7 +161,7 @@ bool timestamp::tick(level *lev, ld time_left) {
hyperpoint wnext = where;
wnext[0] += cos(heading_angle) * eps;
wnext[1] += sin(heading_angle) * eps;
wnext[2] = lev->surface(wnext);
wnext[2] = on_surface->surface(wnext);
wnext = gpushxto0(where) * wnext;
slope = atan(wnext[2] / eps);
@ -187,7 +188,7 @@ bool timestamp::tick(level *lev, ld time_left) {
auto mvel = (vel + ovel) / 2;
where[0] += cos(heading_angle) * mvel * cos(slope) * time_left;
where[1] += sin(heading_angle) * mvel * cos(slope) * time_left;
where[2] = lev->surface(where);
where[2] = on_surface->surface(where);
circvel = mvel / whrad;
}
@ -336,7 +337,7 @@ void timestamp::centerview(level *lev) {
for(int i=0; i<8; i++) {
shift_view(ztangent(whdist * lev->scale / 8.));
hyperpoint p = inverse(View) * C0;
ld room = p[2] - lev->surface(p);
ld room = p[2] - on_surface->surface(p);
if(room < .1 * lev->scale) return true;
for(hyperpoint h: {point3(0,0,0), point3(.001,0,0), point3(-.001,0,0), point3(0,-0.001,0), point3(0,0.001,0)})
if(lev->mapchar(p+h) == 'r') return true;