11 float autocvar_g_bastet;
14 float tet_vs_current_id;
15 float tet_vs_current_timeout;
16 .float tet_vs_id, tet_vs_addlines;
17 .float tet_highest_line;
18 .float tetris_on, tet_gameovertime, tet_drawtime, tet_autodown;
20 .float piece_type, next_piece, tet_score, tet_lines;
21 .float tet_piece_bucket;
26 // 3 = waiting for VS players
28 var float tet_high_score = 0;
30 vector TET_START_PIECE_POS = '5 1 0';
32 float TET_DISPLAY_LINES = 20;
35 float TET_BORDER = 139;
36 float TET_BLOCK = 133;
37 float TET_SPACE = 160; // blankness
42 float TETKEY_DOWN = 2;
43 float TETKEY_LEFT = 4;
44 float TETKEY_RIGHT = 8;
45 float TETKEY_ROTLEFT = 16;
46 float TETKEY_ROTRIGHT = 32;
47 float TETKEY_DROP = 64;
48 string TET_PADDING_RIGHT = "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0"; // get away from crosshair
52 .float line1, line2, line3, line4, line5, line6, line7,
53 line8, line9, line10, line11, line12, line13, line14, line15,
54 line16, line17, line18, line19, line20, line21, line22;
57 float SVC_CENTERPRINTa = 26;
61 return ((floor((self.tet_lines / 10)) + 1));
64 void tetsnd(string snd)
66 play2(self, strcat("sounds/tetris/", snd));
70 *********************************
74 *********************************
76 void SetLine(float ln, float vl)
124 float GetLine(float ln)
174 float GetXBlock(float x, float dat)
179 return (dat & 12) / 4;
181 return (dat & 48) / 16;
183 return (dat & 192) / 64;
185 return (dat & 768) / 256;
187 return (dat & 3072) / 1024;
189 return (dat & 12288) / 4096;
191 return (dat & 49152) / 16384;
193 return (dat & 196608) / 65536;
195 return (dat & 786432) / 262144;
200 float SetXBlock(float x, float dat, float new)
203 return (dat - (dat & 3)) | new;
205 return (dat - (dat & 12)) | (new*4);
207 return (dat - (dat & 48)) | (new*16);
209 return (dat - (dat & 192)) | (new*64);
211 return (dat - (dat & 768)) | (new*256);
213 return (dat - (dat & 3072)) | (new*1024);
215 return (dat - (dat & 12288)) | (new*4096);
217 return (dat - (dat & 49152)) | (new*16384);
219 return (dat - (dat & 196608)) | (new*65536);
221 return (dat - (dat & 786432)) | (new*262144);
227 float GetSquare(float x, float y)
229 return GetXBlock(x, GetLine(y));
232 void SetSquare(float x, float y, float val)
237 dat = SetXBlock(x, dat, val & 3);
241 vector PieceShape(float pc)
244 return '20 20 0'; // O
246 return '1 21 0'; // J
248 return '16 21 0'; // L
250 return '85 0 0'; // I
252 return '5 20 0'; // Z
254 return '20 5 0'; // S
256 return '4 21 0'; // T
261 vector PieceCenter(float pc)
264 return '2.5 1.5 0'; // O
270 return '2.5 1.5 0'; // I
281 // do x 1..4 and y 1..4 in case of rotation
282 float PieceMetric(float x, float y, float rot, float pc)
288 // return bits of a piece
289 wid = piece_dat_z + 1;
290 piece_dat = PieceCenter(pc);
291 if (rot == 1) // 90 degrees
293 // x+cx, y+cy -> -y+cx, x+cy
294 // X, Y -> -Y+cy+cx, X-cx+cy
298 y = x - piece_dat_x + piece_dat_y;
299 x = -t + piece_dat_x + piece_dat_y;
301 else if (rot == 2)//180
303 x = 2 * piece_dat_x - x;
304 y = 2 * piece_dat_y - y;
306 else if (rot == 3) // 270
308 // x+cx, y+cy -> y+cx, -x+cy
309 // X, Y -> Y-cy+cx, -X+cx+cy
313 y = -x + piece_dat_y + piece_dat_x;
314 x = t - piece_dat_y + piece_dat_x;
316 if (x < 1 || y < 1 || x > 4 || y > 2)
318 piece_dat = PieceShape(pc);
320 return GetXBlock(x, piece_dat_x); // first row
322 return GetXBlock(x, piece_dat_y); // second row
324 return 0; // illegal parms
327 *********************************
331 *********************************
335 /* some prydon gate functions to make life easier....
337 somewhat modified because we don't need all the fanciness Prydon Gate is capable of
341 void WriteTetrisString(string s)
343 WriteUnterminatedString(MSG_ONE, strconv(0, 2, 2, s));
346 float pnum(float num, float dig)
351 WriteChar(MSG_ONE, 173);
355 num = num - (f * 10);
357 dig = pnum(f, dig+1);
361 for (i = 0; i < (5 - dig); i = i + 1)
362 WriteChar(MSG_ONE, TET_SPACE);
364 WriteChar(MSG_ONE, 176 + num);
368 void DrawLine(float ln)
371 WriteChar(MSG_ONE, TET_BORDER);
373 for (x = 1; x <= TET_WIDTH; x = x + 1)
375 d = GetSquare(x, ln + TET_LINES - TET_DISPLAY_LINES);
378 WriteChar(MSG_ONE, '^');
379 WriteChar(MSG_ONE, d * d - 2 * d + 50); // 1, 2, 5
380 WriteChar(MSG_ONE, TET_BLOCK);
383 WriteChar(MSG_ONE, TET_SPACE);
385 WriteChar(MSG_ONE, '^');
386 WriteChar(MSG_ONE, '7');
387 WriteChar(MSG_ONE, TET_BORDER);
390 void DrawPiece(float pc, float ln)
392 float x, d, piece_ln, pcolor;
394 pcolor = mod(pc, 3) + 1;
395 WriteChar(MSG_ONE, TET_SPACE); // pad to 6
397 piece_dat = PieceShape(pc);
399 piece_ln = piece_dat_x;
401 piece_ln = piece_dat_y;
402 for (x = 1; x <= 4; x = x + 1)
404 d = GetXBlock(x, piece_ln) * pcolor;
407 WriteChar(MSG_ONE, '^');
408 WriteChar(MSG_ONE, d * d - 2 * d + 50); // 1, 2, 5
409 WriteChar(MSG_ONE, TET_BLOCK);
412 WriteChar(MSG_ONE, TET_SPACE);
414 WriteChar(MSG_ONE, TET_SPACE); // pad to 6
421 WriteChar(MSG_ONE, SVC_CENTERPRINTa);
422 if(autocvar_g_bastet)
424 WriteTetrisString("NEVER GONNA GIVE YOU");
425 WriteChar(MSG_ONE, 10);
428 for (i = 1; i <= (TET_WIDTH + 2); i = i + 1)
429 WriteChar(MSG_ONE, TET_BORDER);
430 WriteTetrisString(" ");
431 WriteUnterminatedString(MSG_ONE, TET_PADDING_RIGHT);
432 WriteChar(MSG_ONE, 10);
433 for (i = 1; i <= TET_DISPLAY_LINES; i = i + 1)
435 if(self.tetris_on == 2)
436 WriteTetrisString(" GAME OVER ");
437 else if(self.tetris_on == 3)
438 WriteTetrisString("PLEASE WAIT");
442 WriteTetrisString(autocvar_g_bastet ? " THAT " : " NEXT ");
444 DrawPiece(self.next_piece, 1);
446 DrawPiece(self.next_piece, 2);
448 WriteTetrisString(" LINES");
450 pnum(self.tet_lines, 0);
452 WriteTetrisString(" SCORE");
454 pnum(self.tet_score, 0);
456 WriteTetrisString(" HIGH ");
458 WriteTetrisString(" SCORE");
460 pnum(tet_high_score, 0);
462 WriteTetrisString(" LEVEL");
464 pnum(Tetris_Level(), 0);
466 WriteTetrisString(" ");
467 WriteUnterminatedString(MSG_ONE, TET_PADDING_RIGHT);
468 WriteChar(MSG_ONE, 10);
472 for (i = 1; i <= (TET_WIDTH + 2); i = i + 1)
473 WriteChar(MSG_ONE, TET_BORDER);
474 WriteTetrisString(" ");
475 WriteUnterminatedString(MSG_ONE, TET_PADDING_RIGHT);
476 WriteChar(MSG_ONE, 10);
481 WriteChar(MSG_ONE, 10);
482 WriteChar(MSG_ONE, 10);
483 if(self.tetris_on == 3)
485 WriteUnterminatedString(MSG_ONE, strcat("WAITING FOR OTHERS (", ftos(ceil(tet_vs_current_timeout - time)), " SEC)\n"));
488 WriteChar(MSG_ONE, 10);
489 FOR_EACH_REALCLIENT(head) if(head.tetris_on) if(head.tet_vs_id == self.tet_vs_id)
492 WriteUnterminatedString(MSG_ONE, ">");
494 WriteUnterminatedString(MSG_ONE, " ");
495 if(head.tetris_on == 2)
496 WriteUnterminatedString(MSG_ONE, " X_X");
498 pnum(head.tet_highest_line, 0);
499 WriteUnterminatedString(MSG_ONE, " ");
500 WriteUnterminatedString(MSG_ONE, head.netname);
501 WriteChar(MSG_ONE, 10);
505 WriteChar(MSG_ONE, 0);
508 *********************************
512 *********************************
520 for (i=1; i<=TET_LINES; i = i + 1)
522 self.piece_pos = '0 0 0';
524 self.next_piece = self.tet_lines = self.tet_score = 0;
525 self.tet_piece_bucket = 0;
530 centerprint(self, " ");
534 self.movetype = MOVETYPE_WALK;
541 for(r = 1; r <= TET_LINES; ++r)
545 for(c = 1; c <= TET_WIDTH; ++c)
547 print(ftos(GetXBlock(c, l)));
553 float BastetEvaluate()
558 float occupied_count;
560 float score_save, occupied_save, occupied_count_save;
565 // adds a bonus for each free dot above the occupied blocks profile
566 occupied_count = TET_WIDTH;
569 for(i = 1; i <= TET_LINES; ++i)
578 occupied_save = occupied;
579 occupied_count_save = occupied_count;
581 for(j = 1; j <= TET_WIDTH; ++j)
585 if(!GetXBlock(j, occupied))
587 occupied = SetXBlock(j, occupied, 1);
593 score += 10000 * occupied_count;
597 occupied = occupied_save;
598 occupied_count = occupied_count_save;
599 score = score_save + 100000000 + 10000 * TET_WIDTH + 1000;
604 score += 1000 * height;
609 float CheckMetrics(float piece, float orgx, float orgy, float rot);
610 void ClearPiece(float piece, float orgx, float orgy, float rot);
611 void CementPiece(float piece, float orgx, float orgy, float rot);
612 float bastet_profile_evaluate_time;
613 float BastetSearch(float buf, float pc, float x, float y, float rot, float move_bias)
614 // returns best score, or -1 if position is impossible
621 return 0; // DO NOT WANT
623 if(x < 1 || x > TET_WIDTH || y < 1 || y > TET_LINES)
624 return -1; // impossible
628 // did we already try?
629 b = x + (TET_WIDTH+2) * (y + (TET_LINES+2) * rot);
630 r = bufstr_get(buf, b);
631 if(r != "") // already tried
634 bufstr_set(buf, b, "0"); // in case we READ that, not that bad - we already got that value in another branch then anyway
636 #define ALWAYS_CHECK_METRICS
637 #ifdef ALWAYS_CHECK_METRICS
638 if(CheckMetrics(pc, x, y, rot))
643 s = BastetSearch(buf, pc, x-1, y, rot, move_bias - 1); if(s > sm) sm = s;
644 s = BastetSearch(buf, pc, x+1, y, rot, move_bias - 1); if(s > sm) sm = s;
645 s = BastetSearch(buf, pc, x, y, rot+1, move_bias - 1); if(s > sm) sm = s;
646 s = BastetSearch(buf, pc, x, y, rot-1, move_bias - 1); if(s > sm) sm = s;
648 #ifndef ALWAYS_CHECK_METRICS
649 if(CheckMetrics(pc, x, y+1, rot))
652 s = BastetSearch(buf, pc, x, y+1, rot, move_bias + 2); if(s > sm) sm = s;
653 #ifndef ALWAYS_CHECK_METRICS
661 //print(sprintf("MAY CEMENT AT: %d %d %d\n", x, y, rot));
662 // moving down did not work - that means we can fixate the block here
663 var float t1 = gettime(GETTIME_HIRES);
665 CementPiece(pc, x, y, rot);
666 s = BastetEvaluate();
667 ClearPiece(pc, x, y, rot);
669 var float t2 = gettime(GETTIME_HIRES);
670 bastet_profile_evaluate_time += (t2 - t1);
675 #ifdef ALWAYS_CHECK_METRICS
677 sm = -1; // impassible
680 bufstr_set(buf, b, ftos(sm));
685 float bastet_piece[7];
686 float bastet_score[7];
687 float bastet_piecetime[7];
692 bastet_profile_evaluate_time = 0;
693 var float t1 = gettime(GETTIME_HIRES);
695 b = buf_create(); bastet_piece[0] = 1; bastet_score[0] = BastetSearch(b, 1, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[0]; buf_del(b);
696 b = buf_create(); bastet_piece[1] = 2; bastet_score[1] = BastetSearch(b, 2, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[1]; buf_del(b);
697 b = buf_create(); bastet_piece[2] = 3; bastet_score[2] = BastetSearch(b, 3, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[2]; buf_del(b);
698 b = buf_create(); bastet_piece[3] = 4; bastet_score[3] = BastetSearch(b, 4, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[3]; buf_del(b);
699 b = buf_create(); bastet_piece[4] = 5; bastet_score[4] = BastetSearch(b, 5, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[4]; buf_del(b);
700 b = buf_create(); bastet_piece[5] = 6; bastet_score[5] = BastetSearch(b, 6, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[5]; buf_del(b);
701 b = buf_create(); bastet_piece[6] = 7; bastet_score[6] = BastetSearch(b, 7, TET_START_PIECE_POS_x, 1+TET_START_PIECE_POS_y, TET_START_PIECE_POS_y, TET_WIDTH) + 100 * random() + bastet_piecetime[6]; buf_del(b);
703 var float t2 = gettime(GETTIME_HIRES);
704 dprint(sprintf("Time taken: %.6f seconds (of this, ev = %.2f%%)\n", t2 - t1, 100 * bastet_profile_evaluate_time / (t2 - t1)));
710 for(i = 0; i < 7; ++i)
712 print(sprintf("piece %s value = %d\n", substring("OJLIZST", bastet_piece[i]-1, 1), bastet_score[i]));
716 for(i = 0; i < 7; ++i)
721 for(j = i + 1; j < 7; ++j)
723 if(bastet_score[j] < s)
732 bastet_score[k] = bastet_score[i];
733 bastet_piece[k] = bastet_piece[i];
750 for(i = 0; i < 7; ++i)
753 bastet_piecetime[i] = 0.2 * bastet_piecetime[i];
755 bastet_piecetime[i] = 1.8 * bastet_piecetime[i] + 1000;
763 *********************************
767 *********************************
769 .float tet_piece_bucket;
777 if(self.tet_piece_bucket > 1)
779 p = mod(self.tet_piece_bucket, 7);
780 self.tet_piece_bucket = floor(self.tet_piece_bucket / 7);
785 p = floor(random() * 7);
788 for(i = 6; i > 0; --i)
790 q = floor(random() * i);
791 for(j = 0; j <= q; ++j)
802 self.tet_piece_bucket = b;
807 void TetAddScore(float n)
809 self.tet_score = self.tet_score + n * Tetris_Level();
810 if (self.tet_score > tet_high_score)
811 tet_high_score = self.tet_score;
813 float CheckMetrics(float piece, float orgx, float orgy, float rot) /*FIXDECL*/
815 // check to see if the piece, if moved to the locations will overlap
818 // why did I start counting from 1, damnit
822 for (y = 1; y < 5; y = y + 1)
824 for (x = 1; x < 5; x = x + 1)
826 if (PieceMetric(x, y, rot, piece))
828 if (GetSquare(x + orgx, y + orgy))
829 return FALSE; // uhoh, gonna hit something.
830 if (x+orgx<1 || x+orgx > TET_WIDTH || y+orgy<1 || y+orgy> TET_LINES)
831 return FALSE; // ouside the level
838 void ClearPiece(float piece, float orgx, float orgy, float rot) /*FIXDECL*/
842 // why did I start counting from 1, damnit
846 for (y = 1; y < 5; y = y + 1)
848 for (x = 1; x < 5; x = x + 1)
850 if (PieceMetric(x, y, rot, piece))
852 SetSquare(x + orgx, y + orgy, 0);
857 void CementPiece(float piece, float orgx, float orgy, float rot) /*FIXDECL*/
861 // why did I start counting from 1, damnit
865 pcolor = mod(piece, 3) + 1;
867 for (y = 1; y < 5; y = y + 1)
869 for (x = 1; x < 5; x = x + 1)
871 if (PieceMetric(x, y, rot, piece))
873 SetSquare(x + orgx, y + orgy, pcolor);
879 float LINE_LOW = 349525;
880 float LINE_HIGH = 699050; // above number times 2
882 void AddLines(float n)
887 FOR_EACH_REALCLIENT(head) if(head != self) if(head.tetris_on) if(head.tet_vs_id == self.tet_vs_id)
888 head.tet_vs_addlines += n;
891 void CompletedLines()
893 float y, cleared, ln, added, pos, i;
900 if (((ln & LINE_LOW) | ((ln & LINE_HIGH)/2)) == LINE_LOW)
901 cleared = cleared + 1;
904 ln = GetLine(y - cleared);
910 else if(cleared >= 1)
911 AddLines(cleared - 1);
913 self.tet_lines = self.tet_lines + cleared;
914 TetAddScore(cleared * cleared * 10);
916 added = self.tet_vs_addlines;
917 self.tet_vs_addlines = 0;
921 for(y = 1; y <= TET_LINES - added; ++y)
923 SetLine(y, GetLine(y + added));
925 for(y = max(1, TET_LINES - added + 1); y <= TET_LINES; ++y)
927 pos = floor(random() * TET_WIDTH);
929 for(i = 1; i <= TET_WIDTH; ++i)
931 ln = SetXBlock(i, ln, floor(random() * 3 + 1));
936 self.tet_highest_line = 0;
937 for(y = 1; y <= TET_LINES; ++y)
940 self.tet_highest_line = TET_LINES + 1 - y;
946 else if(cleared >= 4)
954 void HandleGame(float keyss)
957 // first off, we need to see if we need a new piece
966 if (self.piece_type == 0)
968 self.piece_pos = TET_START_PIECE_POS; // that's about middle top, we count from 1 ARGH
970 if(autocvar_g_bastet)
972 self.piece_type = BastetPiece();
973 self.next_piece = bastet_piece[6];
978 self.piece_type = self.next_piece;
980 self.piece_type = RandomPiece();
981 self.next_piece = RandomPiece();
983 keyss = 0; // no movement first frame
984 self.tet_autodown = time + 0.2;
988 ClearPiece(self.piece_type, self.piece_pos_x, self.piece_pos_y, self.piece_pos_z);
990 // next we need to check the piece metrics against what's on the level
991 // based on the key order
993 old_pos = check_pos = self.piece_pos;
997 if (keyss & TETKEY_RIGHT)
999 check_pos_x = check_pos_x + 1;
1002 else if (keyss & TETKEY_LEFT)
1004 check_pos_x = check_pos_x - 1;
1007 else if (keyss & TETKEY_ROTRIGHT)
1009 check_pos_z = check_pos_z + 1;
1010 piece_data = PieceShape(self.piece_type);
1014 else if (keyss & TETKEY_ROTLEFT)
1016 check_pos_z = check_pos_z - 1;
1017 piece_data = PieceShape(self.piece_type);
1022 if (check_pos_z > 3)
1024 else if (check_pos_z < 0)
1028 if (CheckMetrics(self.piece_type, check_pos_x, check_pos_y, check_pos_z))
1029 self.piece_pos = check_pos;
1033 self.tet_gameovertime = time + 5;
1038 for(i = 1; i <= nudge; ++i)
1040 if(CheckMetrics(self.piece_type, check_pos_x + i, check_pos_y, check_pos_z))
1041 self.piece_pos = check_pos + '1 0 0' * i;
1042 else if(CheckMetrics(self.piece_type, check_pos_x - i, check_pos_y, check_pos_z))
1043 self.piece_pos = check_pos - '1 0 0' * i;
1049 check_pos = self.piece_pos;
1050 if(keyss & TETKEY_DROP)
1052 // drop to bottom, but do NOT cement it yet
1053 // this allows sliding it
1055 while(CheckMetrics(self.piece_type, check_pos_x, check_pos_y + 1, check_pos_z))
1057 self.tet_autodown = time + 2 / (1 + Tetris_Level());
1059 else if (keyss & TETKEY_DOWN)
1061 check_pos_y = check_pos_y + 1;
1062 self.tet_autodown = time + 2 / (1 + Tetris_Level());
1064 else if (self.tet_autodown < time)
1066 check_pos_y = check_pos_y + 1;
1067 self.tet_autodown = time + 2 / (1 + Tetris_Level());
1069 if (CheckMetrics(self.piece_type, check_pos_x, check_pos_y, check_pos_z))
1071 if(old_pos != check_pos)
1072 self.tet_drawtime = 0;
1073 self.piece_pos = check_pos;
1077 CementPiece(self.piece_type, self.piece_pos_x, self.piece_pos_y, self.piece_pos_z);
1080 self.piece_type = 0;
1081 self.tet_drawtime = 0;
1084 CementPiece(self.piece_type, self.piece_pos_x, self.piece_pos_y, self.piece_pos_z);
1088 *********************************
1090 Important Linking Into Quake stuff
1092 *********************************
1096 void TetrisImpulse()
1098 if(self.tetris_on == 0 || self.tetris_on == 2) // from "off" or "game over"
1102 if(time < tet_vs_current_timeout)
1105 self.tet_vs_id = tet_vs_current_id;
1109 // start new VS game
1110 ++tet_vs_current_id;
1111 tet_vs_current_timeout = time + 15;
1112 self.tet_vs_id = tet_vs_current_id;
1113 bprint("^1TET^7R^1IS: ", self.netname, "^1 started a new game. Do ^7impulse 100^1 to join.\n");
1115 self.tet_highest_line = 0;
1117 self.tet_org = self.origin;
1118 self.movetype = MOVETYPE_NOCLIP;
1120 else if(self.tetris_on == 1) // from "on"
1128 float TetrisPreFrame()
1130 if (!self.tetris_on)
1133 self.tet_org = self.origin;
1134 if (self.tet_drawtime > time)
1137 if(self.tetris_on == 3)
1138 self.tet_drawtime = ceil(time - tet_vs_current_timeout + 0.1) + tet_vs_current_timeout;
1140 self.tet_drawtime = time + 0.5;
1143 float frik_anglemoda(float v)
1145 return v - floor(v/360) * 360;
1147 float angcompa(float y1, float y2)
1149 y1 = frik_anglemoda(y1);
1150 y2 = frik_anglemoda(y2);
1155 answer = answer - 360;
1156 else if (answer < -180)
1157 answer = answer + 360;
1161 .float tetkey_down, tetkey_rotright, tetkey_left, tetkey_right, tetkey_rotleft, tetkey_drop;
1163 float TetrisKeyRepeat(.float fld, float f)
1167 if(self.fld == 0) // initial key press
1169 self.fld = time + 0.3;
1172 else if(time > self.fld)
1174 self.fld = time + 0.1;
1179 // repeating too fast
1190 float TetrisPostFrame()
1196 if (!self.tetris_on)
1199 if(self.tetris_on == 2 && time > self.tet_gameovertime)
1205 if(self.tetris_on == 3 && time > tet_vs_current_timeout)
1207 self.tetris_on = 1; // start VS game
1208 self.tet_drawtime = 0;
1211 setorigin(self, self.tet_org);
1212 self.movetype = MOVETYPE_NONE;
1214 if(self.tetris_on == 1)
1216 if(TetrisKeyRepeat(tetkey_down, self.movement_x < 0))
1217 keysa |= TETKEY_DOWN;
1219 if(TetrisKeyRepeat(tetkey_rotright, self.movement_x > 0))
1220 keysa |= TETKEY_ROTRIGHT;
1222 if(TetrisKeyRepeat(tetkey_left, self.movement_y < 0))
1223 keysa |= TETKEY_LEFT;
1225 if(TetrisKeyRepeat(tetkey_right, self.movement_y > 0))
1226 keysa |= TETKEY_RIGHT;
1228 if(TetrisKeyRepeat(tetkey_rotleft, self.BUTTON_CROUCH))
1229 keysa |= TETKEY_ROTLEFT;
1231 if(TetrisKeyRepeat(tetkey_drop, self.BUTTON_JUMP))
1232 keysa |= TETKEY_DROP;