From 0d795e60bfa031c7931aaee6cfdfb0a28ee0f322 Mon Sep 17 00:00:00 2001 From: ? Date: Wed, 27 Feb 2019 13:34:52 +0100 Subject: [PATCH] 3d::racing:: 3d racing (partial) --- hypgraph.cpp | 1 + racing.cpp | 17 +++++++++++------ shmup.cpp | 52 ++++++++++++++++++++++++++++++++++------------------ 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/hypgraph.cpp b/hypgraph.cpp index 6d9939c3..2ff0b1ac 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1042,6 +1042,7 @@ void centerpc(ld aspd) { if(shmup::on && DIM == 3 && vid.sspeed > -5) { transmatrix at = ggmatrix(shmup::pc[0]->base) * shmup::pc[0]->at * cpush(2, -vid.yshift); View = inverse(at) * View; + if(racing::on) racing::set_view(); return; } diff --git a/racing.cpp b/racing.cpp index 128e2d11..5fc4b730 100644 --- a/racing.cpp +++ b/racing.cpp @@ -426,19 +426,19 @@ void generate_track() { for(cell *sc: track) { straight = calc_relative_matrix(sc, track[0], C0); - if(straight[2][2] > 1e8) break; + if(straight[DIM][DIM] > 1e8) break; } straight = rspintox(straight * C0); ld& a = start_line_width; - for(a=0; a<10; a += .1) { + if(DIM == 2) for(a=0; a<10; a += .1) { hyperpoint h = straight * parabolic1(a) * C0; cell *at = s; virtualRebase(at, h, true); if(!rti_id.count(at) || get_info(at).from_track >= TWIDTH) break; } - for(ld cleaner=0; cleanerat = straight * parabolic1(start_line_width * (rand() % 20000 - 10000) / 40000) * spin(rand() % 360); + if(DIM == 3) + who->at = Id; // straight * cspin(0, 2, rand() % 360) * cspin(1, 2, rand() % 360); + else + who->at = straight * parabolic1(start_line_width * (rand() % 20000 - 10000) / 40000) * spin(rand() % 360); who->base = s; bool ok = true; for(const transmatrix& t: forbidden) if(hdist(t*C0, who->at * C0) < 10. / (j+10)) ok = false; @@ -638,6 +641,7 @@ int current_player; void set_view() { if(race_start_tick == 0) race_start_tick = ticks + 5000; + if(DIM == 3) return; if(subscreen_split(set_view)) return; @@ -1247,6 +1251,7 @@ void draw_ghost_state(ghost& ghost) { void drawStats() { if(!racing::on) return; + if(DIM == 3) return; initquickqueue(); @@ -1272,13 +1277,13 @@ void drawStats() { void markers() { if(!racing::on) return; - if(guiding) for(int i=0; ipat * xpush0(j), m->pat * xpush0(j+1), multi::scs[i].uicolor, 2); } - if(racing::player_relative || racing::standard_centering) { + if(racing::player_relative || racing::standard_centering || DIM == 3) { using namespace racing; cell *goal = NULL; for(cell *c: track) if(inscreenrange(c)) goal = c; diff --git a/shmup.cpp b/shmup.cpp index 4c0a4934..923b8cb2 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1648,11 +1648,13 @@ void movePlayer(monster *m, int delta) { #if CAP_RACING if(racing::on) { - if(abs(mdy) > abs(mgo)) mgo = -mdy; - if(abs(mdx) > abs(mturn)) mturn = -mdx; - mdx = mdy = 0; + if(DIM == 2) { + if(abs(mdy) > abs(mgo)) mgo = -mdy; + if(abs(mdx) > abs(mturn)) mturn = -mdx; + mdx = mdy = 0; + } facemouse = shotkey = dropgreen = false; - if(ticks < racing::race_start_tick || !racing::race_start_tick) mgo = 0; + if(ticks < racing::race_start_tick || !racing::race_start_tick) (DIM == 2 ? mgo : mdy) = 0; } #endif @@ -1702,24 +1704,38 @@ void movePlayer(monster *m, int delta) { if(rosedist(m->base) == 1) roseCurrents(nat, m, delta); - if(mgo > 1) mgo = 1; - if(mgo < -1) mgo = -1; if(!canmove) mgo = 0; - if(racing::on) { - // braking is more efficient - if(m->vel * mgo < 0) mgo *= 3; - m->vel += mgo * delta / 600; - playergo[cpid] = m->vel * SCALE * delta / 600; + if(DIM == 2) { + if(mgo > 1) mgo = 1; + if(mgo < -1) mgo = -1; + if(racing::on) { + // braking is more efficient + if(m->vel * mgo < 0) mgo *= 3; + m->vel += mgo * delta / 600; + playergo[cpid] = m->vel * SCALE * delta / 600; + } + + else { + playergo[cpid] = mgo * SCALE * delta / 600; + } } - else { - playergo[cpid] = mgo * SCALE * delta / 600; - } - - if(DIM == 3) { - playergo[cpid] = -mdy * SCALE * delta / 600; - playerstrafe[cpid] = mdx * SCALE * delta / 600; + else if(DIM == 3) { + if(mdy > 1) mdy = 1; + if(mdy < -1) mdy = -1; + if(mdx > 1) mdx = 1; + if(mdx < -1) mdx = -1; + if(racing::on) { + if(m->vel * -mdy < 0) mdy *= 3; + m->vel += -mdy * delta / 600; + playergo[cpid] = m->vel * SCALE * delta / 600; + playerstrafe[cpid] = m->vel * mdx * SCALE * delta / 600; + } + else { + playergo[cpid] = -mdy * SCALE * delta / 600; + playerstrafe[cpid] = mdx * SCALE * delta / 600; + } playerturn[cpid] = mgo * SCALE * delta / 200; playerturny[cpid] = mturn * SCALE * delta / 200;