|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 3558 (0xde6) Types: TextFile Names: »get_level.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Tetris/get_level.c.orig«
/* ** written by adam margulies vespa@ssyx.ucsc.edu ** {...}!ucbvax!ucscc!ssyx!vespa ** ** permission is granted to freely distribute this code provided that you: ** ** 1) don't charge for it ** 2) leave my name and header on it ** 3) clearly document your changes and place your name on them ** */ /* get_level.c ** ** Gets the level the user prefers to start on and also gets the users ** preference on "rubble" and generates the "rubble". Rubble is random ** stuff put on the playing field to spice up the game at the beginning. */ #include "tetris.h" void get_level() { int i; save_screen(5,19,16,62); clear(5,19,16,62); mvaddstr(05,19, "+-----------------------------------------+"); mvaddstr(06,19, "| Starting level: |"); mvaddstr(15,19, "| [hjkl] to move, [space] to toggle |"); for(i=7; i<15; i++) mvaddstr(i,19,"| |"); mvaddstr(11,19, "| Rows of obstacles: |"); mvaddstr(16,19,"+-----------------------------------------+"); mvaddstr(07,21,"**** **** **** **** **** **** **** ****"); mvaddstr(08,21,"*00* *01* *03* *05* *07* *09* *11* *13*"); mvaddstr(09,21,"**** **** **** **** **** **** **** ****"); mvaddstr(12,21,"**** **** **** **** **** **** **** ****"); mvaddstr(13,21,"*00* *01* *03* *05* *07* *09* *11* *13*"); mvaddstr(14,21,"**** **** **** **** **** **** **** ****"); read_input(); restore_screen(5,19,16,62); } read_input() { int x = 0; int y = 8; char c; mvaddstr(7, 21, "++++"); mvaddch(8, 21, '+'); mvaddch(8, 24, '+'); mvaddstr(9, 21, "++++"); mvaddstr(12, 21,"++++"); mvaddch(13,21, '+'); mvaddch(13,24, '+'); mvaddstr(14, 21,"++++"); csr_draw(5,19,16,62); csr(y, 23 + (x*5)); while(1){ c = getchar(); switch(c) { case 'h': x -= 1; x = (x<0 ? 7 : x); csr(y, 23 + (x*5)); break; case 'l': x += 1; x = (x>7 ? 0 : x); csr(y, 23 + (x*5)); break; case 'j': y = (y==8 ? 13 : 8); csr(y, 23 + (x*5)); break; case 'k': y = (y==8 ? 13 : 8); csr(y, 23 + (x*5)); break; case ' ': mvaddstr((y == 8 ? 7 : 12), 21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5),"****"); mvaddch((y == 8 ? 8 : 13),21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5), '*'); mvaddch((y == 8 ? 8 : 13),24 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5), '*'); mvaddstr((y == 8 ? 9 : 14), 21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5),"****"); csr_draw((y == 8 ? 7 : 12),21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5), (y == 8 ? 9 : 14), 24 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5)); if(y == 8) level = (x == 0 ? 0 : (2*x) - 1); else rubble = (x == 0 ? 0 : (2*x) - 1); mvaddstr((y == 8 ? 7 : 12), 21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5),"++++"); mvaddch((y == 8 ? 8 : 13),21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5), '+'); mvaddch((y == 8 ? 8 : 13),24 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5), '+'); mvaddstr((y == 8 ? 9 : 14), 21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5),"++++"); csr_draw((y == 8 ? 7 : 12),21 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5), (y == 8 ? 9 : 14), 24 + ((y == 8 ? (level+1)/2 : (rubble+1)/2)*5)); csr(y, 23 + (x*5)); break; default: return; } } } make_rubble() { int i,j; char color[8]; strcpy(color, "#$%@&*+"); for(i=21; i>21-rubble; i--) for(j=35; j<45; j++) if((random() % 100) > 60) mvaddch(i,j,color[(random() % 7)]); }