Ejemplo n.º 1
0
void RenderGameInfo(void *pCtx) {
	char *s1 = "Pacman - Snehal Tiwari";
	char *s2 = "COEP";
	clear();
	attron(COLOR_PAIR(PC_PILL));
	mvprintw(2,CenteredX(s1), s1);
	attroff(COLOR_PAIR(PC_PILL));
	attron(COLOR_PAIR(PC_PACMAN));
	mvprintw(3,CenteredX(s2), s2);
	attroff(COLOR_PAIR(PC_PACMAN));
}
Ejemplo n.º 2
0
int AnotherGame(void *pCtx) {
	char *s1 = "Another game?";
	char *s2 = "Y/N";
	attron(COLOR_PAIR(PC_GHOST));
	mvprintw(12,CenteredX(s1), s1);
	mvprintw(14,CenteredX(s2), s2);
	attroff(COLOR_PAIR(PC_GHOST));
	do {
		char ch = getch();
		if (ch=='y'||ch=='Y') 
			return 1;
		else if (ch=='n'||ch=='N') 
			return 0;
	} while(1);
	return 0;
}
Ejemplo n.º 3
0
tGameEnd Pac_GameLoop(void *pCtx, GAME_STATE *ptr)
{
	int c, keypress;
	float telaps;

	do {
		keypress = Pac_AnalyzeGameState(*ptr);
		
		int CenteredStr = CenteredX("Key Hint: A");
		mvprintw(24, CenteredStr, "Key Hint: %c", keypress);

		if (ptr->Player.Agent == ePAC_Human) {
			while (c = getch()) {
				if (c == PACKEY_UP ||
			    	c == PACKEY_DOWN ||
					c == PACKEY_RIGHT || 
					c == PACKEY_LEFT ||
					c == 'q' || 
					c == 'a') break;
			}
			if (c == 'q' || c == 'Q')
				return ePAC_UserQuit;
			keypress = c;
			if (c == 'a') {
				ptr->Player.Agent = ePAC_Computer;
			}
		}

		telaps = 0.2;

		/* scroll marquee */
		if (ptr->pMarquee) {
			c = *ptr->pMarquee;
			memmove(ptr->pMarquee, ptr->pMarquee+1, ptr->iMarqueeSize-1);
			ptr->pMarquee[ptr->iMarqueeSize-1] = c;
		}

		/* Update all game components */
		Pac_UpdatePlayer(ptr, telaps, keypress);
		Pac_CheckPlayerVsGhosts(ptr);
		Pac_UpdateGhosts(ptr, telaps);
		Pac_CheckPlayerVsGhosts(ptr);
		Pac_UpdatePills(ptr, telaps);

		/* Draw everything */
		DrawDynamic(pCtx, ptr);

		/* Make it visible */
		Pac_Blit(pCtx);

		/* Has an end game condition been reached? */
		if (ptr->iDotsLeft == 0)	return ePAC_SheetComplete;
		else if (ptr->Player.bDead)	return ePAC_LifeLost;

		// if (ptr->iDotsLeft < 50) ptr->Player.Agent = ePAC_Human;
		
		usleep(80000);
	} while(1);
}
Ejemplo n.º 4
0
void RenderRHS(void *pCtx, state *ptr) {
	char *pacimg[] = {"/-\\", "|'<", "\\_/", " ", " "," ", };
	int i,j;
	attron(A_BOLD | COLOR_PAIR(PC_PACMAN));
	for(i = 0; i<MAX_PACMAN_LIVES; i++)
		for(j=0; j<3; j++)
			mvprintw(16+j,i*5+30,pacimg[j+(ptr->Player.iLives>i?0:3)]);
	attroff(A_BOLD | COLOR_PAIR(PC_PACMAN));
	i = CenteredX("Score : 123456"); 
	mvprintw(5,i,"Score : %d", ptr->Player.iScore);
	mvprintw(6,i,"High : %d", ptr->iHighScore);
	mvprintw(8,i,"Level : %d", ptr->iLevel+1);
	if (LINES-1 >= ptr->iMapHeight) 
		i = 0;
	else
		i = ptr->iMapWidth;
	if (ptr->pMarquee)
		mvprintw(LINES-1, i, "%.*s", COLS-i, ptr->pMarquee);
}