コード例 #1
1
ファイル: game.cpp プロジェクト: TeamAwesomeSlackers/SP-1
//--------------------------------------------------------------
// Purpose	: Initialisation function
// Input	: Void
// Output	: void
//--------------------------------------------------------------
void init( void )
{
    // Set precision for floating point output
    std::cout << std::fixed << std::setprecision(3);

	// set the name of your console window
    SetConsoleTitle(L"SP1 Framework");

    // Sets the console size, this is the biggest so far.
    setConsoleSize(100, 50);

    // Get console width and height
    CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */     

    /* get the number of character cells in the current buffer */ 
    GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi );
    g_cConsoleSize.X = csbi.srWindow.Right + 1;
    g_cConsoleSize.Y = csbi.srWindow.Bottom + 1;

    // set the character to be in the center of the screen.
    g_cCharLocation.X = g_cConsoleSize.X / 2;
    g_cCharLocation.Y = g_cConsoleSize.Y / 2;

    g_dElapsedTime = 0.0;
}
コード例 #2
0
ファイル: main.c プロジェクト: vidorge/PP2-MummyMaze
void main ()
{

	setConsoleSize(WIDTH,HEIGHT);

	startAnimation ();

	mainMenu();

}
コード例 #3
0
ファイル: main.c プロジェクト: Kaiotic/GameCompilation
/*****************************************************************************
int initConsole(void)
    Description :
		Initializes the console window.
    Parameters  : -
    Returns     :
		TRUE, if everything initialized correctly.
		FALSE, if not.
*****************************************************************************/
int initConsole(void) 
{
	if(!setConsoleSize(100, 40))
	{
		// console size could not be set
		return FALSE;
	}

	if(!setConsoleTitle("Game Compilation"))
	{
		// console title could not be set
		return FALSE;
	}

	// everything went well
	return TRUE;
}
コード例 #4
0
ファイル: shell.c プロジェクト: jcaracciolo/Arqui2016
void initShell() {
	//clearScreen();
	printf("-- WELCOME THE SHELL --\n\n  >>");
	setTimeZone(-3);
	setConsoleSize();
	shellBuffer = sbuffer[0];
	cleanBuffer();

	while(1) {
		int c = getc();
		if (c != EOF) {
			if (c == '\n') {
				execute();
			} else if (c == '\b') {
				removeKey();
			} else {
				addToShellBuffer(c);
				putc(c);
			}
		}
	}
}
コード例 #5
0
ファイル: console.cpp プロジェクト: Zero-Ice/SP1Framework
void initConsole(COORD consoleSize, LPCSTR lpConsoleTitle)
{
    // Use the ascii version for the consoleTitle
    SetConsoleTitleA(lpConsoleTitle);
    SetConsoleCP(437);
    
    // set up screen buffer
    screenDataBuffer = new CHAR_INFO[consoleSize.X * consoleSize.Y];

    hScreenBuffer = CreateConsoleScreenBuffer( 
       GENERIC_READ |           // read/write access 
       GENERIC_WRITE, 
       FILE_SHARE_READ | 
       FILE_SHARE_WRITE,        // shared 
       NULL,                    // default security attributes 
       CONSOLE_TEXTMODE_BUFFER, // must be TEXTMODE 
       NULL);                   // reserved; must be NULL 

    SetConsoleActiveScreenBuffer(hScreenBuffer); 
    // Sets the console size
    setConsoleSize(consoleSize.X, consoleSize.Y);
}
コード例 #6
0
ファイル: game.cpp プロジェクト: pr0gr4m/TeamNoru
void Move(int dir)
{
	int dx = 0, dy = 0;

	switch (dir)
	{
	case LEFT:
		dx = -1;
		break;
	case RIGHT:
		dx = 1;
		break;
	case UP:
		dy = -1;
		break;
	case DOWN:
		dy = 1;
		break;
	}

	int nxt = map[nStage][ny + dy][nx + dx];

	if (nxt != 1)
	{
		if (nxt == 2)
		{	// 이전 맵으로
			map[nStage][ny][nx] = 0;
			if (nStage == 1)
				nx = 19, ny = 23;
			else if (nStage == 2)
				nx = 38, ny = 5;
			else if (nStage == 3)
				nx = 38, ny = 3;
			else if (nStage == 4)
				nx = 34, ny = 22;
			else if (nStage == 5)
				nx = 37, ny = 1;
			else if (nStage == 6)
				nx = 19, ny = 1;
			else if (nStage == 7)
				nx = 5, ny = 2;
			nStage--;
			if (nStage == 6)
				nStage = 3;
			map[nStage][ny][nx] = 9;
			clrscr();
			mapDraw(nStage);
		}
		else if (nxt == 3)
		{	// 다음 맵으로
			map[nStage][ny][nx] = 0;
			if (nStage == 0)
				nx = 1, ny = 21;
			else if (nStage == 1)
				nx = 1, ny = 9;
			else if (nStage == 2)
				nx = 2, ny = 21;
			else if (nStage == 3)
				nx = 2, ny = 19;
			else if (nStage == 4)
				nx = 19, ny = 22;
			else if (nStage == 5)
				nx = 1, ny = 4;
			nStage++;
			map[nStage][ny][nx] = 9;
			clrscr();
			mapDraw(nStage);
		}
		else if (nxt == 4)
		{
			if (nStage == 0)
			{
				// 첫 번째 맵의 5번째 줄에 있는 npc
				if (ny + dy == 5)
					n1.Dialogue();
				else if (ny + dy == 14)
					n2.Dialogue();
				else if (ny + dy == 16)
					n5.Dialogue();
				else if (ny + dy == 6)
					n6.Dialogue();
			}
			else if (nStage == 1)
			{
				n2.Dialogue();
				map[1][21][34] = 0;
				gotoxy(70, 21);
				std::cout << "  ";
				map[0][14][4] = 4;
			}
			else if (nStage == 2)
			{
				n3.Dialogue();
			}
			else if (nStage == 3)
			{
				if (ny + dy == 2)
				{	// 숨겨진 맵으로
					n4.Dialogue();	// 다른 npc로 변경
					map[nStage][ny][nx] = 0;
					map[nStage][2][4] = 0;
					nx = 38, ny = 3;
					nStage = 7;
					map[nStage][ny][nx] = 9;
					map[nStage][1][38] = 4;
					clrscr();
					mapDraw(nStage);
				}
			}
			else if (nStage == 4)
			{
				n5.Dialogue();
				map[4][21][21] = 0;
				gotoxy(44, 21);
				std::cout << "  ";
				map[0][16][28] = 4;
			}
			else if (nStage == 5)
			{
				n6.Dialogue();
				map[5][13][8] = 0;
				gotoxy(18, 13);
				std::cout << "  ";
				map[0][6][12] = 4;
			}
			else if (nStage == 6)
			{
				n7.Dialogue();
				map[6][ny][nx] = 0;
				nx = 32, ny = 14;
				map[6][ny][nx] = 9;
				clrscr();
				mapDraw(nStage);
			}
			else if (nStage == 7)
			{
				n4.Dialogue();
			}
			// npc와 대화
			return;
		}
		else if (nxt == 5)
		{
			// 아이템 습득
			if (nStage == 0)
				p.item_list[0] = 1;
			else if (nStage == 1)
				p.item_list[4] += 1;
			else if (nStage == 2)
				p.item_list[6] += 1;
			else if (nStage == 3)
				p.item_list[5] += 1;
			else if (nStage == 5)
				p.item_list[6] += 1;
			else if (nStage == 6)
				p.item_list[3] = 1;
			else if (nStage == 7)
			{
				if (ny + dy == 16)
					p.item_list[1] = 1;
				else
					p.item_list[2] = 1;
			}
			map[nStage][ny + dy][nx + dx] = 0;
			gotoxy((ny + dy) * 2 + 2, nx + dx);
			std::cout << "  ";
			return;
		}
		else if (nxt == 6)
		{
			// 몬스터 만남
			HighMonster m(20, 30, AGGR);
			Battle b(m);
			clrscr();
			map[nStage][ny + dy][nx + dx] = 0;
			mapDraw(nStage);

			return;
		}
		else if (nxt == 7)
		{
			// 주유소
			gotoxy(5, 35);
			std::cout << "체력과 기력이 회복되었다!";
			getKey();
			p.HealHP(10000);
			p.HealAP(1000);
			gotoxy(5, 35);
			std::cout << "                         ";
			if (!RandInt(20))
			{
				p.sk_list[3] = 1;
				gotoxy(5, 35);
				std::cout << "몰아치기Lv1 스킬을 습득하였다!";
				getKey();
				gotoxy(5, 35);
				std::cout << "                              ";
			}
			return;
		}
		else if (nxt == 8)
		{
			gotoxy(5, 35);
			std::cout << "심상치 않은 기운이 느껴지는 구체다..";
			getKey();
			gotoxy(5, 36);
			std::cout << "이것에서 발산되는 기운 때문에 몬스터가 생기는듯 하다.";
			getKey();
			gotoxy(5, 37);
			std::cout << "내일의 안녕을 위하여!!!";
			getKey();
			
			BossMonster boss;
			Battle b(boss);
			clrscr();

			map[nStage][ny][nx] = 0;
			nx = 5, ny = 12;
			map[nStage][ny][nx] = 9;
			clrscr();
			mapDraw(nStage);

			gotoxy(5, 35);
			std::cout << "..!! 보스를 잡았지만 갇혔다?!";
			getKey();
			gotoxy(5, 35);
			std::cout << "                              ";

			// 보스
			return;
		}
		else if (nxt == 10)
		{
			gotoxy(5, 35);
			std::cout << "..!! 비밀 문을 찾았다!!";
			getKey();
			map[nStage][ny][nx] = 0;
			nStage = 0, nx = 1, ny = 1;
			map[nStage][ny][nx] = 9;

			char buf[BUF_LEN];

			std::ifstream ep(end_file, std::ios::in | std::ios::binary);
			if (!ep.is_open())
			{
				std::cerr << "파일 오픈 실패." << std::endl << "ASCII 폴더와 텍스트 파일을 확인해 주십시오." << std::endl;
				exit(1);
			}

			bigConsoleSize();
			std::memset(buf, 0, BUF_LEN);
			while (!ep.eof())
			{
				ep.read((char*)buf, BUF_LEN - 1);
				buf[BUF_LEN - 1] = 0;
				std::cout << buf;
				std::memset(buf, 0, BUF_LEN);
			}
			ep.close();
			std::cin.get();

			setConsoleSize();
			mapDraw(nStage);
		}
		else
		{
			gotoxy(nx * 2 + 2, ny);
			std::cout << "  ";
			map[nStage][ny][nx] = 0;
			nx += dx;
			ny += dy;
			map[nStage][ny][nx] = 9;
			gotoxy(nx * 2 + 2, ny);
			std::cout << "P";
			if (nStage != 0 && nStage != 7 && !RandInt(30))		// 1/30 확률
			{
				if (nStage >= 1 && nStage <= 3)
				{
					int rand_mon = RandInt(3);
					if (rand_mon == 1)
					{
						LowMonster m(nStage * (RandInt(3) + 1), nStage * 10, AGGR);
						Battle b(m);
						clrscr();
						mapDraw(nStage);
					}
					else if (rand_mon == 2)
					{
						LowMonster m(nStage * (RandInt(3) + 1), nStage * 5, DEFN);
						Battle b(m);
						clrscr();
						mapDraw(nStage);
					}
					else
					{
						LowMonster m(nStage * (RandInt(3) + 1));
						Battle b(m);
						clrscr();
						mapDraw(nStage);
					}
					if (!RandInt(10))	// 1 / 10 확률로
					{
						p.sk_list[0] = 1;
						gotoxy(5, 35);
						std::cout << "강타Lv1 스킬을 얻었다!";
						getKey();
						gotoxy(5, 35);
						std::cout << "                      ";
					}
				}
				else if (nStage >= 4 && nStage <= 6)
				{
					int rand_mon = RandInt(3);
					if (rand_mon == 1)
					{
						HighMonster m(nStage * (RandInt(3) + 1), nStage * 20, AGGR);
						Battle b(m);
						clrscr();
						mapDraw(nStage);
					}
					else if (rand_mon == 2)
					{
						HighMonster m(nStage * (RandInt(3) + 1), nStage * 15, DEFN);
						Battle b(m);
						clrscr();
						mapDraw(nStage);
					}
					else
					{
						HighMonster m(nStage * (RandInt(3) + 1));
						Battle b(m);
						clrscr();
						mapDraw(nStage);
					}
					if (!RandInt(10))	// 1 / 10 확률로
					{
						p.sk_list[1] = 1;
						gotoxy(5, 35);
						std::cout << "강타Lv2 스킬을 얻었다!";
						getKey();
						gotoxy(5, 35);
						std::cout << "                      ";
					}
					else if (!RandInt(20))	// 9/200 확률로
					{
						p.sk_list[2] = 1;
						gotoxy(5, 35);
						std::cout << "강타Lv3 스킬을 얻었다!";
						getKey();
						gotoxy(5, 35);
						std::cout << "                      ";
					}
				}
			}
			return;
		}
	}
}
コード例 #7
0
ファイル: game.cpp プロジェクト: Glenn-Pao/StudioPStuff
void init()
{
	// Set precision for floating point output
	cout << std::fixed << std::setprecision(1);

	SetConsoleTitle(L"Laser Cat");

	// Sets the console size
		setConsoleSize(63, 25);

	// Get console width and height
	CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */     

	/* get the number of character cells in the current buffer */ 
	GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &csbi );
	consoleSize.X = csbi.srWindow.Right + 1;
	consoleSize.Y = csbi.srWindow.Bottom + 1;

	// set the character location
	if (check == 1)
	{
		charLocation.X = consoleSize.X / 2 - 4;
		charLocation.Y = consoleSize.Y / 2 ;
	}

	else
	{
		charLocation.X = consoleSize.X / 2 - 2;
		charLocation.Y = consoleSize.Y / 2 - 6 ;
	}

	//change difficulty
	if (check == 0)
	{
		pawnumber = 2;
		tailnumber = 1;
		life = 30;
		elapsedTime = 0.0;
	}

	else
	{
		pawnumber = 4;
		tailnumber = 2;
		life = 20;
		elapsedTime = 31.0;
	}


	// set the taillocation

	tails[0].loc1.X = 0;
	tails[0].loc1.Y = 2;

	tails[0].loc2.X = 0;
	tails[0].loc2.Y = 2;
	
	if (check == 1)
	{
		tails[1].loc1.X = 46;
		tails[1].loc1.Y = 18;

		tails[1].loc2.X = 46;
		tails[1].loc2.Y = 18;
	}

	//set paw locations
	for (int i = 0; i < pawnumber; ++i)
	{
		paws[i].loc1.X = 0;
		paws[i].loc1.Y = 0;
		paws[i].loc2.X = 0;
		paws[i].loc3.X = 0;
		paws[i].loc3.Y = 0;
	}

	//set item location and ID
	for (int i = 0; i < 3; ++i)
	{
		pickups[i].loc.X = 0;
		pickups[i].loc.Y = 0;
		pickups[i].ID = 1 + i;
	}

	//set deadspace location & ID
	if (check == 0)
	{
		deadspace[2].loc.X = 27;
		deadspace[2].loc.Y = 7;
		deadspace[2].ID = 3;
	}

	else
	{
		deadspace[0].loc.X = 13;
		deadspace[0].loc.Y = 7;
		deadspace[0].ID = 1;

		deadspace[1].loc.X = 35;
		deadspace[1].loc.Y = 7;
		deadspace[1].ID = 2;
	}

		

	//set seed for rand() as the time program is launched
	srand( time( NULL ) );

	//set score
	score = 0.0;

	//clear all vectors
	counter.clear();
	checker.clear();
	redo.clear();

	//initialise counters
	for (int i = 0; i < 23; ++i)
	{
		counter.push_back(0);
	}

	//initialise checkers
	for (int i = 0; i < 8; ++i)
	{
		checker.push_back(0);
	}

	//initialise redos
	for (int i = 0; i < 6; ++i)
	{
		redo.push_back(0);
	}
}