Exemple #1
0
int main()
{
	// Display a few instructions
	printf("Instructions:\nWhen ready, hit enter. You will have five seconds "
		"to place your mouse cursor in the upper left hand corner of the game board.\n"
		"\nTips: I would hit enter, then wait a few seconds and then click play. It might"
		" take a game or two to get your timing right.\n");
	system("pause");

	while (true)
	{
		CountDown(5);
		InitGame();

		// Play game for specified time_limit
		for (time_t start_time = time(0);
			start_time + time_limit - time(0) >= 0;)
		{
			GetGems();
			DisplayGrid();
			MakeMove();
			Sleep(throttle_time);
		}

		ClearGame();

		printf("Game over. . . Play again?\n");
		system("Pause");
	}
	
	return 0;
}
Exemple #2
0
void CCollegeTimeTableView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{  int j,k,height,maxheight;
	UINT line;
   CString temp;
   CStringArray arr;
   arr.SetSize(20);
   
   CFont fon;
   CFont* oldfont;
   fon.CreateFont(18,8,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
   CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"COURIER NEW");

   oldfont=pDC->SelectObject(&fon); 


   pDC->SetMapMode(MM_LOENGLISH);
   pDC->SetBkMode(TRANSPARENT);
   CPoint PP(70,-25);
   CPoint QQ(771,-25);
   CPoint tempPP,tempQQ;
   UINT lastline=PageArray[(pInfo->m_nCurPage)-1].Line.GetUpperBound();///
   for(line=0;line<=lastline;line++)
   {    maxheight=1;
	   for(j=0;j<7;j++)
		{tempPP=PP;//tempQQ=QQ;
		 temp=m_master.GetItemText(PageArray[(pInfo->m_nCurPage)-1].Line[line],j);
		 if(temp[0]>='0' && temp[0]<='9')
		 {PP.Offset(0,-25); 
		  tempPP=PP;QQ.Offset(0,-25);  /////create blank space between lecture blocks
		 }
         GetParallelLectureList(temp,arr);// in CStringarray arr
         height=arr.GetSize();
		 if(height<1) height=1;
		 if(height>maxheight) maxheight=height;
		 for(k=0;k<height;k++)
			{pDC->TextOut(74+j*100,PP.y-2,arr[k]);
		     PP.Offset(0,-25);
			 }
         PP=tempPP;//Reset to normal lecture line
		}
		QQ.Offset(0,-25*maxheight);
		DisplayGrid(PP,QQ,1,7,pDC);
		PP.Offset(0,-25*maxheight);
		
   }  

pDC->SelectObject(&oldfont); 
}
Exemple #3
0
int main (int args, char *argc[])
{
	FILE *f;
	char buf[64];
	char temp[64];
	char path[64];
	int add;
	long oldscore;
	unsigned int oldtime;
	unsigned int start = time(NULL);
	unsigned int spent;
	srand(time(NULL));
        printf("\n");
        printf("*********************************************************\n");
        printf("Welcome to TAWS (Text Adventure Without Swords) volume 2!\n");
        printf("*********************************************************\n");
	printf("\n");
	ConstructGrid();
	DisplayGrid();
	timestart = time(NULL);
	while (1)
	{
		printf("\n");
		printf("Enter command here: ");
		scanf("%s", buf);
		if (!strcmp(buf, "show"))
			DisplayGrid();
		else if (buf[0] == '5' || !strcmp(buf, "new"))
		{
			ConstructGrid();
			DisplayGrid();
			timestart = time(NULL);
		}
		else if (!strcmp(buf, "score"))
			printf("Score: %li\n", score);
		else if (!strcmp(buf, "help"))
		{
			printf("The object of TAWS v2 is to enter a sequence\n");
			printf("of numbers (on the numpad) that matches a path to\n");
			printf("the finish (F) from the start (S). Avoid mines (*).\n");
			printf("For example, 8 moves up, 9 moves up and right, and 2 moves down.\n");
			printf("-- Commands --\n");
			printf("#####: Type a series of numbers and hit enter to enter a path.\n");
			printf("'score': Show your current score.\n");
			printf("'new' or '5': Generate a new board.\n");
			printf("'show': Display current board.\n");
			printf("'help': Show this help.\n");
			printf("'highscore': See a saved highscore.\n");
			printf("'exit': Exit the game, but why would you want that?\n");
			printf("--   Tips   --\n");
			printf("The shorter your path and faster you do it, the more points you get!\n");
		}
                else if (!strcmp(buf, "TAWS"))
                {
                        printf("TAWS is most commonly known as Text Adventure Without Swords.\n");
                        printf("However, it has other meanings as well, including:\n");
                        printf("Timed Avoidance Withstanding Simulation\n");
                        printf("Torrential Admission of Watery Soup\n");
                        printf("Timetable Antithesis Waking Somebody\n");
			printf("Top Ankle Wise Surrender\n");
                        printf("... or just TAWS.\n");
                }
		else if (!strcmp(buf, "highscore"))
		{
			printf("Please enter a name: ");
			scanf("%s", temp);
			sprintf(path, "%s.sav", temp);
			f = fopen(path, "rb");
			if (f)
			{
				fread(&oldscore, sizeof(long), 1, f);
				fread(&oldtime, sizeof(unsigned int), 1, f);
				fclose(f);
				printf("Old score for %s: %li in %u seconds.\n", temp, oldscore, oldtime);
			}
			else
				printf("Failed to open save file %s.\n", path);
		}
		else if (!strcmp(buf, "quit") || !strcmp(buf, "exit"))
			break;
		else if (IsANumber(buf[0]))
		{
			int result = CheckPath(buf);
			if(result == FINISH)
			{
				float timediff = (float)(time(NULL)-timestart);
				if (timediff > 0)
					add = 50-(strlen(buf)-4)*4 + (int)(50.0f*(float)strlen(buf)/(float)(time(NULL)-timestart));	
				else
					add = 50-(strlen(buf)-4)*4 + (int)(50.0f*(float)strlen(buf));
				printf("Score: %li+%i=%li\n", score, add, score+add);
				score += add;
			}
			else
			{
				printf("You didn't make it to the finish!\n");
				printf("Score: %li-250=%li\n", score, score-250);
				score -= 250;
			}
			ConstructGrid();
			DisplayGrid();
			timestart = time(NULL);
		}
		else
			printf("Come on, type something real (try 'help').\n");
	}
	spent = time(NULL)-start;
	printf("You got %li points in %u minutes and %u seconds.  Good job!\n", score, (spent/60), (spent%60));
	printf("Please enter your name: ");
	scanf("%s", buf);
	sprintf(temp, "%s.sav", buf);
	f = fopen(temp, "rb");
	if (f)
	{
		fread(&oldscore, sizeof(long), 1, f);
		fread(&oldtime, sizeof(unsigned int), 1, f);
		fclose(f);
	}
	else
	{
		oldscore = 0;
		oldtime = 0;
	}
	if (score > oldscore)
	{
		f = fopen(temp, "wb");
		if (f)
		{
			printf("New personal highscore: %li in %u seconds!\n", score, spent);
			fwrite(&score, sizeof(long), 1, f);
			fwrite(&spent, sizeof(unsigned int), 1, f);
		}
	}
	if (oldscore > 0)
		printf("Old personal highscore: %li in %u seconds.\n", oldscore, oldtime);

	printf("Well wasn't that fun? See you next time!\n\n");
	return 0;
}