From f4ecc68ea82bc157848cd7d328639b436b5db2f0 Mon Sep 17 00:00:00 2001 From: blub0 Date: Mon, 17 Mar 2008 21:16:27 +0000 Subject: [PATCH] changed tetris keypress detection, now also works when looking straight up or rotating over 90 degrees... git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3515 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/g_tetris.qc | 58 +++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/data/qcsrc/server/g_tetris.qc b/data/qcsrc/server/g_tetris.qc index 16a6cf688..d88c97a35 100644 --- a/data/qcsrc/server/g_tetris.qc +++ b/data/qcsrc/server/g_tetris.qc @@ -325,12 +325,14 @@ somewhat modified because we don't need all the fanciness Prydon Gate is capable */ -void(float c1, float c2, float c3, float c4, float c5, float c6) p6 = +// remove warnings by adding underscores, i hate warnings, warnings suck +// --blub +void(float _c1, float _c2, float _c3, float _c4, float c5, float c6) p6 = { - WriteChar(MSG_ONE, c1); - WriteChar(MSG_ONE, c2); - WriteChar(MSG_ONE, c3); - WriteChar(MSG_ONE, c4); + WriteChar(MSG_ONE, _c1); + WriteChar(MSG_ONE, _c2); + WriteChar(MSG_ONE, _c3); + WriteChar(MSG_ONE, _c4); WriteChar(MSG_ONE, c5); WriteChar(MSG_ONE, c6); }; @@ -375,11 +377,11 @@ void (float ln) DrawLine = void (float pc, float ln) DrawPiece = { - float x, d, piece_ln, color; + float x, d, piece_ln, pcolor; vector piece_dat; - color = pc & 3; - if (color == 0) // 4 - color = 1; + pcolor = pc & 3; + if (pcolor == 0) // 4 + pcolor = 1; WriteChar(MSG_ONE, TET_SPACE); // pad to 6 piece_dat = PieceShape(pc); @@ -389,7 +391,7 @@ void (float pc, float ln) DrawPiece = piece_ln = piece_dat_y; for (x = 1; x <= 4; x = x + 1) { - d = GetXBlock(x, piece_ln) * color; + d = GetXBlock(x, piece_ln) * pcolor; if (d) WriteChar(MSG_ONE, TET_BLOCKS + d); else @@ -541,15 +543,15 @@ void ClearPiece(float piece, float orgx, float orgy, float rot) = } void CementPiece(float piece, float orgx, float orgy, float rot) = { - float color; + float pcolor; float x, y; // why did I start counting from 1, damnit orgx = orgx - 1; orgy = orgy - 1; - color = piece & 3; - if (color == 0) // 4 - color = 1; + pcolor = piece & 3; + if (pcolor == 0) // 4 + pcolor = 1; for (y = 1; y < 5; y = y + 1) { @@ -557,7 +559,7 @@ void CementPiece(float piece, float orgx, float orgy, float rot) = { if (PieceMetric(x, y, rot, piece)) { - SetSquare(x + orgx, y + orgy, color); + SetSquare(x + orgx, y + orgy, pcolor); } } } @@ -720,22 +722,24 @@ float() TetrisPostFrame = if (!self.tetris_on) return 0; + if (self.origin != self.tet_org) { - mov = vectoangles(self.origin - self.tet_org); self.origin = self.tet_org; + makevectors(self.v_angle); + norm = self.velocity*v_forward; + if(norm < -0.1) + keysa |= TETKEY_DOWN; + else if(norm > 0.1) + keysa |= TETKEY_UP; + + norm = self.velocity*v_right; + if(norm < -0.1) + keysa |= TETKEY_LEFT; + else if(norm > 0.1) + keysa |= TETKEY_RIGHT; + self.velocity_x = self.velocity_y = self.velocity_z = 0; - - norm = angcompa(self.v_angle_y, mov_y); - - if (norm > -80 && norm < 80) - keysa = keysa | TETKEY_UP; - if (norm > 10 && norm < 170) - keysa = keysa | TETKEY_RIGHT; - if (norm > 100 || norm < -260) - keysa = keysa | TETKEY_DOWN; - if (norm > -170 && norm < -10) - keysa = keysa | TETKEY_LEFT; } if (self.button0) keysa = keysa | TETKEY_ROTRIGHT; -- 2.39.2