int main(void) { int game, multi, totalscore, hints, deduct, minus; game = GAMESCORE; multi = MULTIPLIER; totalscore = game * multi; hints = HINTS_USED; deduct = DEDUCTION; /*if statement to determine adding Multiplier*/ if (GAMETIME <= BENCHMARK_TIME) { multi++; } /*If hints have been used, points will be deducted.*/ if (HINTS_USED > 0) { minus = hints*deduct; totalscore = totalscore - minus; } printscore(game, multi, totalscore, hints, minus); return 0; }
main(int argn, char **argv) { int sum, n; float avg; char board[100], fname[100], buf[100], path[300], *ptr; while (NULL != fgets(buf, sizeof (buf), stdin)) { if (sscanf(buf, "%d%f%d%s%s", &sum, &avg, &n, board, fname) != 5) continue; sprintf(path, MY_BBS_HOME "/boards/%s/%s", board, fname); ptr = searchauthor(path); if (ptr == NULL) continue; addscore(ptr, sum, n); } printscore(); }
static void game(void) { char c; int counter = sspeed, rs, a, blocks = 0, paused = 0; gamescreen(); clearboard(); nexts = rnd()%28; nextc = rnd()%7 + 1; newshape(); score = view = 0; if (view) drawview(nexts, nextc); level = 1; speed = sspeed; printscore(); printlevel(); for(;;) { if (paused) { gametick(); c = tgetchar(); switch(c) { case 'q': goto stopgame; case 'p': paused = 0; moveto(68,5); setbg(black); printf(" "); normal(); flush(); default: break; } continue; } if (counter <= 0) { counter = 14 - speed; if (shapefits(current.s, current.x, current.y+1)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.y++; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } else { markboard(current.s, current.color, current.x, current.y); checkboard(current.y); incrscore(1); newshape(); if (!shapefits(current.s, current.x, current.y)) goto stopgame; blocks++; if (blocks == blocksperlevel) { blocks = 0; incrlevel(1); } if (view) drawview(nexts, nextc); } } counter--; moveto(1,24); flush(); gametick(); c = tgetchar(); switch(c) { case 'q': goto stopgame; case 'j': if (shapefits(current.s, current.x-1, current.y)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.x--; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } break; case 'l': if (shapefits(current.s, current.x+1, current.y)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.x++; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } break; case 'k': rs = (current.s & ~0x03) | ((current.s + 1) & 0x03); if (shapefits(rs, current.x, current.y)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.s = rs; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } break; case ' ': for (a=1; ; a++) { if (!shapefits(current.s, current.x, current.y+a)) break; } if (shapefits(current.s, current.x, current.y+a-1)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.y += a-1; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } incrscore(view ? (a-1) * 3 / 4 : a-1); break; case 'n': view ^= 1; if (view) drawview(nexts, nextc); else clearview(); break; case 'p': paused = 1; moveto(68,5); setfg(white); setbg(blue); printf(" PAUSED!!! "); moveto(1,24); flush(); default: break; } } stopgame: setbg(white); rect(20,8,60,12); setbg(red); frect(21,9,59,11); setfg(white); bold(); moveto(30,10); printf(" G A M E O V E R "); moveto(1,24); flush(); for(;;) { c = tgetchar(); if (c > 0) return; } }
static void incrscore(int i) { score += i; printscore(); }
void moveActor(AppState* App, actor_t* a,int mode) { a->posx+=a->vx; a->posy+=a->vy; int dir = 0; if(random() >RANDOM_MAX/2)dir = -1; else dir = 1; switch(mode) { case bounce: if(a->posx>WIDTH-1) { a->vx = -abs(a->vx) ; a->posx=WIDTH-1; } if(a->posx<0) { a->vx = abs(a->vx) ; a->posx=0;} if(a->posy>HEIGHT-1) { a->vy = -abs(a->vy) ; a->posy=HEIGHT-1;} if(a->posy<0) { a->vy = abs(a->vy) ; a->posy=0; } break; case puck: if(a->posx>WIDTH-1) {a->posx = WIDTH/2;a->posy = HEIGHT/2; App->puck->vx=-1; App->puck->vy = dir;App->p1score++;printscore(App);} if(a->posx<0) { a->posx = WIDTH/2;a->posy = HEIGHT/2; App->puck->vx=1; App->puck->vy = dir; App->p2score++;printscore(App);} if(a->posy>HEIGHT-1) { a->vy = -abs(a->vy) ; a->posy=HEIGHT-1;} if(a->posy<0) { a->vy = abs(a->vy) ; a->posy=0; } break; case cycle: if(a->posx>WIDTH-1)a->posx = 0; if(a->posx<0) a->posx = WIDTH; if(a->posy>HEIGHT-1) a->posy = 0; if(a->posy<0) a->posy = HEIGHT; break; } }