mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-09-27 21:58:13 +00:00
nilrider:: collecting triangles
This commit is contained in:
parent
a234a76d20
commit
59b11a74ad
@ -223,6 +223,18 @@ void level::init() {
|
|||||||
hyperpoint h = mappt(x+.5, y+.5, 1);
|
hyperpoint h = mappt(x+.5, y+.5, 1);
|
||||||
statues.emplace_back(statue{rgpushxto0(h), &shGeostatue, 0xFFFFFFFF});
|
statues.emplace_back(statue{rgpushxto0(h), &shGeostatue, 0xFFFFFFFF});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bmch == '*') {
|
||||||
|
hyperpoint h = mappt(x+.5, y+.5, 1);
|
||||||
|
h[2] += safe_alt(h, .5, .85);
|
||||||
|
triangledata d;
|
||||||
|
d.where = h;
|
||||||
|
d.x = x;
|
||||||
|
d.y = y;
|
||||||
|
for(int i=0; i<7; i++)
|
||||||
|
d.colors[i] = gradient(0xFFD500FF, 0xFF, 0, i, 8);
|
||||||
|
triangles.emplace_back(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cgi.finishshape();
|
cgi.finishshape();
|
||||||
// println(hlog, shFloor[i].s, " to ", shFloor[i].e);
|
// println(hlog, shFloor[i].s, " to ", shFloor[i].e);
|
||||||
@ -276,11 +288,11 @@ void level::init_plan() {
|
|||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ld level::safe_alt(hyperpoint h, ld mul) {
|
ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
|
||||||
ld maxv = 0;
|
ld maxv = 0;
|
||||||
for(int x: {-1, 0, 1})
|
for(int x: {-1, 0, 1})
|
||||||
for(int y: {-1, 0, 1}) {
|
for(int y: {-1, 0, 1}) {
|
||||||
hyperpoint c = sym_to_heis(point31(x*.5*scale, y*.5*scale, 0));
|
hyperpoint c = sym_to_heis(point31(x*.5*scale*mulx, y*.5*scale*mulx, 0));
|
||||||
hyperpoint j = rgpushxto0(h) * c;
|
hyperpoint j = rgpushxto0(h) * c;
|
||||||
maxv = max(maxv, mul * (surface(j) - j[2]));
|
maxv = max(maxv, mul * (surface(j) - j[2]));
|
||||||
}
|
}
|
||||||
@ -288,10 +300,17 @@ ld level::safe_alt(hyperpoint h, ld mul) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void level::draw_level(const shiftmatrix& V) {
|
void level::draw_level(const shiftmatrix& V) {
|
||||||
if(false) for(int i=0; i<6; i++) {
|
int id = 0;
|
||||||
auto &poly = queuepoly(V * rgpushxto0(start.where) * cpush(2, 0.3 + 0.3 * sin(ticks / 500.)), shMini[i], 0xFFFF00FF);
|
for(auto& t: triangles) {
|
||||||
poly.tinf = &floor_texture_vertices[cgi.shFloor.id];
|
bool gotit = current.collected_triangles & Flag(id);
|
||||||
ensure_vertex_number(*poly.tinf, poly.cnt);
|
id++;
|
||||||
|
if(!gotit) {
|
||||||
|
for(int i=0; i<6; i++) {
|
||||||
|
auto &poly = queuepoly(V * rgpushxto0(t.where) * cpush(2, abs(0.2 * sin(timer * 5))), shMini[i], t.colors[i]);
|
||||||
|
poly.tinf = &floor_texture_vertices[cgi.shFloor.id];
|
||||||
|
ensure_vertex_number(*poly.tinf, poly.cnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(true) {
|
if(true) {
|
||||||
|
@ -274,13 +274,13 @@ level rotplane(
|
|||||||
"ggggggfffgggggg!",
|
"ggggggfffgggggg!",
|
||||||
"ggggggfffgggggg!",
|
"ggggggfffgggggg!",
|
||||||
"gggg|ggggg|gggg!",
|
"gggg|ggggg|gggg!",
|
||||||
"ggg-+-----+-ggg!",
|
"ggg-*-----*-ggg!",
|
||||||
"gggg|ggggf|gggg!",
|
"gggg|ggggf|gggg!",
|
||||||
"ggGg|g+ggg|grgG!",
|
"ggGg|g+ggg|grgG!",
|
||||||
"gGgg|g|xgo|gggg!",
|
"gGgg|g|xgo|gggg!",
|
||||||
"ggGg|g|ggg|grgg!",
|
"ggGg|g|ggg|grgg!",
|
||||||
"gggg|g|ggg|gggg!",
|
"gggg|g|ggg|gggg!",
|
||||||
"gg--+-+---+--gg!",
|
"gg--*-+---*--gg!",
|
||||||
"gggg|ggggg|gggg!",
|
"gggg|ggggg|gggg!",
|
||||||
"gggggggGGgggggg!",
|
"gggggggGGgggggg!",
|
||||||
"ggggggggggggggg!",
|
"ggggggggggggggg!",
|
||||||
@ -297,8 +297,8 @@ level longtrack(
|
|||||||
0*dft_block, +2.5*dft_block, 64*dft_block, -1.5*dft_block,
|
0*dft_block, +2.5*dft_block, 64*dft_block, -1.5*dft_block,
|
||||||
{
|
{
|
||||||
"gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
|
"gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
|
||||||
"gggggggrgggggggrggggggggrGggggggggGGggggGGGgggggGGGGggggggggggGG",
|
"ggggggggrggggggrggggggggrGggggggggGGggggGGGgggggGGGGggggggggggGG",
|
||||||
"g+------------------------------------------------------------+G",
|
"g+------------------------------------------------------------*G",
|
||||||
"gggggfffffggggggggggggggggggggggggggggggggggggggggggggggggggggGG"
|
"gggggfffffggggggggggggggggggggggggggggggggggggggggggggggggggggGG"
|
||||||
},
|
},
|
||||||
0, 1,
|
0, 1,
|
||||||
|
@ -13,11 +13,17 @@ struct timestamp {
|
|||||||
ld circpos; /**< controls the wheel graphics */
|
ld circpos; /**< controls the wheel graphics */
|
||||||
ld slope; /**< the current slope */
|
ld slope; /**< the current slope */
|
||||||
ld t; /**< planning spline parameter */
|
ld t; /**< planning spline parameter */
|
||||||
|
|
||||||
|
flagtype collected_triangles; /**< a bitset which shows which triangles are collected */
|
||||||
|
flagtype achievements; /**< a bitset which shows which achievements are complete */
|
||||||
|
flagtype achflags; /**< a bitset which marks failed conducts, etc. */
|
||||||
|
|
||||||
bool tick(level*);/**< one tick of the simulation -- returns false if the unicycle has stopped or crashed */
|
bool tick(level*);/**< one tick of the simulation -- returns false if the unicycle has stopped or crashed */
|
||||||
void centerview(level*);
|
void centerview(level*);
|
||||||
void draw_unilcycle(const shiftmatrix&);
|
void draw_unilcycle(const shiftmatrix&);
|
||||||
void draw_instruments(ld t);
|
void draw_instruments(ld t);
|
||||||
ld energy_in_squares();
|
ld energy_in_squares();
|
||||||
|
bool collect(level*);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct planpoint {
|
struct planpoint {
|
||||||
@ -34,6 +40,12 @@ struct statue {
|
|||||||
color_t color;
|
color_t color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct triangledata {
|
||||||
|
int x, y;
|
||||||
|
hyperpoint where;
|
||||||
|
array<color_t, 7> colors;
|
||||||
|
};
|
||||||
|
|
||||||
struct level {
|
struct level {
|
||||||
string name;
|
string name;
|
||||||
char hotkey;
|
char hotkey;
|
||||||
@ -59,6 +71,7 @@ struct level {
|
|||||||
hpcshape shCastle; /**< the 3D model of the 'castle' */
|
hpcshape shCastle; /**< the 3D model of the 'castle' */
|
||||||
|
|
||||||
vector<statue> statues;
|
vector<statue> statues;
|
||||||
|
vector<triangledata> triangles;
|
||||||
|
|
||||||
/** the texture data used for the ground */
|
/** the texture data used for the ground */
|
||||||
texture::texture_data *unil_texture;
|
texture::texture_data *unil_texture;
|
||||||
@ -90,7 +103,7 @@ struct level {
|
|||||||
|
|
||||||
hyperpoint get_spline(ld t);
|
hyperpoint get_spline(ld t);
|
||||||
hyperpoint mappt(ld x, ld y, int s);
|
hyperpoint mappt(ld x, ld y, int s);
|
||||||
ld safe_alt(hyperpoint h, ld mul = 1);
|
ld safe_alt(hyperpoint h, ld mul = 1, ld mulx = 1);
|
||||||
void compute_plan_transform();
|
void compute_plan_transform();
|
||||||
bool handle_planning(int sym, int uni);
|
bool handle_planning(int sym, int uni);
|
||||||
};
|
};
|
||||||
|
@ -70,8 +70,28 @@ void timestamp::draw_unilcycle(const shiftmatrix& V) {
|
|||||||
|
|
||||||
bool tick_debug = false;
|
bool tick_debug = false;
|
||||||
|
|
||||||
|
bool timestamp::collect(level *lev) {
|
||||||
|
int tY = isize(lev->map_tiles);
|
||||||
|
int tX = isize(lev->map_tiles[0]);
|
||||||
|
// println(hlog, where, tie(lev->minx, lev->miny), tie(lev->maxx, lev->maxy));
|
||||||
|
int x = floor(ilerp(lev->minx, lev->maxx, where[0]) * tX);
|
||||||
|
int y = floor(ilerp(lev->miny, lev->maxy, where[1]) * tY);
|
||||||
|
if(x < 0 || y < 0 || x >= tX || y >= tY)
|
||||||
|
return false;
|
||||||
|
char ch = lev->map_tiles[y][x];
|
||||||
|
if(ch == 'r' || ch == '!') return false;
|
||||||
|
if(ch == '*') {
|
||||||
|
for(int i=0; i<isize(lev->triangles); i++) {
|
||||||
|
auto& t = lev->triangles[i];
|
||||||
|
if(t.x == x && t.y == y) collected_triangles |= (1<<i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool timestamp::tick(level *lev) {
|
bool timestamp::tick(level *lev) {
|
||||||
|
|
||||||
|
if(!collect(lev)) return false;
|
||||||
const ld eps = slope_eps;
|
const ld eps = slope_eps;
|
||||||
|
|
||||||
hyperpoint wnext = where;
|
hyperpoint wnext = where;
|
||||||
|
Loading…
Reference in New Issue
Block a user