mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-31 22:12:59 +00:00 
			
		
		
		
	3d::racing:: 3d racing (partial)
This commit is contained in:
		| @@ -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; | ||||
|     } | ||||
|      | ||||
|   | ||||
							
								
								
									
										17
									
								
								racing.cpp
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								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; cleaner<a*.75; cleaner += .2) for(int dir=-1; dir<=1; dir+=2) { | ||||
|   if(DIM == 2) for(ld cleaner=0; cleaner<a*.75; cleaner += .2) for(int dir=-1; dir<=1; dir+=2) { | ||||
|     transmatrix T = straight * parabolic1(cleaner * dir); | ||||
|     cell *at = s; | ||||
|     virtualRebase(at, T,  true); | ||||
| @@ -469,7 +469,10 @@ void generate_track() { | ||||
|     // this is intentionally not hrand | ||||
|      | ||||
|     for(int j=0; j<100; j++) { | ||||
|       who->at = 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; i<multi::players; i++) { | ||||
|   if(guiding && DIM == 2) for(int i=0; i<multi::players; i++) { | ||||
|     shmup::monster *m = shmup::pc[i]; | ||||
|     if(!m) continue; | ||||
|     for(int j=0; j<5; j++) | ||||
|       queueline(m->pat * 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; | ||||
|   | ||||
							
								
								
									
										52
									
								
								shmup.cpp
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								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; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ?
					?