mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-23 23:47:00 +00:00
nilrider:: triangles should work with multiple sublevels
This commit is contained in:
parent
9d680953e2
commit
aa174d92c8
@ -374,6 +374,7 @@ void level::init() {
|
|||||||
d.where = h;
|
d.where = h;
|
||||||
d.x = x;
|
d.x = x;
|
||||||
d.y = y;
|
d.y = y;
|
||||||
|
d.which = this;
|
||||||
for(int i=0; i<7; i++)
|
for(int i=0; i<7; i++)
|
||||||
d.colors[i] = gradient(0xFFD500FF, 0xFF, 0, i, 8);
|
d.colors[i] = gradient(0xFFD500FF, 0xFF, 0, i, 8);
|
||||||
d.colors[6] = d.colors[0];
|
d.colors[6] = d.colors[0];
|
||||||
@ -420,7 +421,11 @@ void level::init() {
|
|||||||
|
|
||||||
init_plan();
|
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) {
|
xy_float level::get_xy_f(hyperpoint h) {
|
||||||
|
@ -68,6 +68,7 @@ struct statue {
|
|||||||
struct triangledata {
|
struct triangledata {
|
||||||
int x, y;
|
int x, y;
|
||||||
hyperpoint where;
|
hyperpoint where;
|
||||||
|
level *which;
|
||||||
array<color_t, 7> colors;
|
array<color_t, 7> colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,12 +89,13 @@ bool timestamp::out_of_surface(level *lev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool timestamp::collect(level *lev) {
|
bool timestamp::collect(level *lev) {
|
||||||
auto xy = lev->get_xy_i(where);
|
auto xy = on_surface->get_xy_i(where);
|
||||||
char ch = lev->mapchar(xy);
|
char ch = on_surface->mapchar(xy);
|
||||||
if(ch == 'r') return false;
|
if(ch == 'r') return false;
|
||||||
if(ch == '*') {
|
if(ch == '*') {
|
||||||
for(int i=0; i<isize(lev->triangles); i++) {
|
for(int i=0; i<isize(lev->triangles); i++) {
|
||||||
auto& t = 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);
|
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;
|
hyperpoint wnext = where;
|
||||||
wnext[0] += cos(heading_angle) * eps;
|
wnext[0] += cos(heading_angle) * eps;
|
||||||
wnext[1] += sin(heading_angle) * eps;
|
wnext[1] += sin(heading_angle) * eps;
|
||||||
wnext[2] = lev->surface(wnext);
|
wnext[2] = on_surface->surface(wnext);
|
||||||
|
|
||||||
wnext = gpushxto0(where) * wnext;
|
wnext = gpushxto0(where) * wnext;
|
||||||
slope = atan(wnext[2] / eps);
|
slope = atan(wnext[2] / eps);
|
||||||
@ -187,7 +188,7 @@ bool timestamp::tick(level *lev, ld time_left) {
|
|||||||
auto mvel = (vel + ovel) / 2;
|
auto mvel = (vel + ovel) / 2;
|
||||||
where[0] += cos(heading_angle) * mvel * cos(slope) * time_left;
|
where[0] += cos(heading_angle) * mvel * cos(slope) * time_left;
|
||||||
where[1] += sin(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;
|
circvel = mvel / whrad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +337,7 @@ void timestamp::centerview(level *lev) {
|
|||||||
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
||||||
shift_view(ztangent(whdist * lev->scale / 8.));
|
shift_view(ztangent(whdist * lev->scale / 8.));
|
||||||
hyperpoint p = inverse(View) * C0;
|
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;
|
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)})
|
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;
|
if(lev->mapchar(p+h) == 'r') return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user