nilrider:: collecting triangles

This commit is contained in:
Zeno Rogue 2022-04-30 12:01:18 +02:00
parent a234a76d20
commit 59b11a74ad
4 changed files with 63 additions and 11 deletions

View File

@ -223,6 +223,18 @@ void level::init() {
hyperpoint h = mappt(x+.5, y+.5, 1);
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();
// println(hlog, shFloor[i].s, " to ", shFloor[i].e);
@ -276,11 +288,11 @@ void level::init_plan() {
timer = 0;
}
ld level::safe_alt(hyperpoint h, ld mul) {
ld level::safe_alt(hyperpoint h, ld mul, ld mulx) {
ld maxv = 0;
for(int x: {-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;
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) {
if(false) for(int i=0; i<6; i++) {
auto &poly = queuepoly(V * rgpushxto0(start.where) * cpush(2, 0.3 + 0.3 * sin(ticks / 500.)), shMini[i], 0xFFFF00FF);
poly.tinf = &floor_texture_vertices[cgi.shFloor.id];
ensure_vertex_number(*poly.tinf, poly.cnt);
int id = 0;
for(auto& t: triangles) {
bool gotit = current.collected_triangles & Flag(id);
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) {

View File

@ -274,13 +274,13 @@ level rotplane(
"ggggggfffgggggg!",
"ggggggfffgggggg!",
"gggg|ggggg|gggg!",
"ggg-+-----+-ggg!",
"ggg-*-----*-ggg!",
"gggg|ggggf|gggg!",
"ggGg|g+ggg|grgG!",
"gGgg|g|xgo|gggg!",
"ggGg|g|ggg|grgg!",
"gggg|g|ggg|gggg!",
"gg--+-+---+--gg!",
"gg--*-+---*--gg!",
"gggg|ggggg|gggg!",
"gggggggGGgggggg!",
"ggggggggggggggg!",
@ -297,8 +297,8 @@ level longtrack(
0*dft_block, +2.5*dft_block, 64*dft_block, -1.5*dft_block,
{
"gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg",
"gggggggrgggggggrggggggggrGggggggggGGggggGGGgggggGGGGggggggggggGG",
"g+------------------------------------------------------------+G",
"ggggggggrggggggrggggggggrGggggggggGGggggGGGgggggGGGGggggggggggGG",
"g+------------------------------------------------------------*G",
"gggggfffffggggggggggggggggggggggggggggggggggggggggggggggggggggGG"
},
0, 1,

View File

@ -13,11 +13,17 @@ struct timestamp {
ld circpos; /**< controls the wheel graphics */
ld slope; /**< the current slope */
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 */
void centerview(level*);
void draw_unilcycle(const shiftmatrix&);
void draw_instruments(ld t);
ld energy_in_squares();
bool collect(level*);
};
struct planpoint {
@ -34,6 +40,12 @@ struct statue {
color_t color;
};
struct triangledata {
int x, y;
hyperpoint where;
array<color_t, 7> colors;
};
struct level {
string name;
char hotkey;
@ -59,6 +71,7 @@ struct level {
hpcshape shCastle; /**< the 3D model of the 'castle' */
vector<statue> statues;
vector<triangledata> triangles;
/** the texture data used for the ground */
texture::texture_data *unil_texture;
@ -90,7 +103,7 @@ struct level {
hyperpoint get_spline(ld t);
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();
bool handle_planning(int sym, int uni);
};

View File

@ -70,8 +70,28 @@ void timestamp::draw_unilcycle(const shiftmatrix& V) {
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) {
if(!collect(lev)) return false;
const ld eps = slope_eps;
hyperpoint wnext = where;