Esempio n. 1
0
///////////////////////////////////////////////////////////////	
//	Draw Level	
///////////////////////////////////////////////////////////////	
void	DrawDemoLevel(void)	
{	
	DrawCurrentLevel();	
	DrawConv();	
	DrawKeys();	
	DrawSwitches();	
	DrawExit();	
	DrawTPlate();	
	DrawAirBG();	
	DoHRobo();	
	DoVRobo();	
	DoSpecialRobo();	
	DrawExit();	
	DrawAir();	
	
	FontPrint(0,18,"                                ");	
	FontPrint(0,19,"                                ");	
	FontPrint(0,20,"                                ");	
	FontPrint(0,21,"                                ");	
	FontPrint(0,22,"                                ");	
	FontPrint(0,23,"                                ");	
	
	PrintScore();	
	PrintHighScore();	
	DrawLives();	
}	
void StartGame() {
  SCORE score;
  ResetScore(&score);
  while (1) {
    p_r_s player_choice;
    p_r_s machine_choice;
    // What the player picks?
    char c = GetUserInput();
    // Do we choose a control key rather than p r s?
    int controlKey = 0;
    switch (c) {
    case 'p':
      player_choice = paper;
      break;
    case 'r':
      player_choice = rock;
      break;
    case 's':
      player_choice = scissors;
      break;
    case 'g':
      PrintScore(&score);
      controlKey = 1;
      break;
    case 'h':
      PrintHelp();
      controlKey = 1;
      break;
    case 'e':
      PrintScore(&score);
      exit(0);
    default:
      PrintHelp();
      controlKey = 1;
      break;
    }
    if (controlKey)
      continue;
    // What the machine picks?
    machine_choice = MachineSelect();
    outcome re = Compare(player_choice, machine_choice); 
    PrintRoundResult(player_choice, machine_choice, re);
    SaveScore(re, &score);
  }
  return;
}
Esempio n. 3
0
void DrawBoardFrame(void)
{
	int y;

	for(y = 0; y < BOARD_HEIGHT+2*BOARD_BORDER; y++) {
		mvaddnstr(y+BOARD_TOP, BOARD_LEFT, (const char *)&initialScreen[(BOARD_WIDTH+2)*y], BOARD_WIDTH+2);
	}
	mvaddstr(y+BOARD_TOP, BOARD_LEFT, "Score");
	PrintScore(0);
}
Esempio n. 4
0
void CheckForLine()
{	int RemoveLines[10];
	int Remove;
	int x,y;
	int factor=1;
	for(y=0; y<ROWS; y++)
	{  Remove=1;
	   for(x=0; x<COLS; x++)
	   {	  if(ScreenLayout[x][y] == BLANK)
			 Remove=0;
	   }
	   if(Remove)
	   {	  RemoveLine(y);
		  Score += LineScore*factor;
		  factor++;
		  PrintScore();
	   }
	}
	while (kbhit()) getch();      //Empty the keyboard input
}
Esempio n. 5
0
File: Tetris.c Progetto: Jn58/Tetris
void DrawScreen()
{
	int x, y;

	for( x=0; x < WIDTH+2; x++){
		for( y=0; y < HEIGHT+2; y++){
			if ( y == 0 || y == HEIGHT + 1 || x == 0 || x == WIDTH+1)
				board[x][y].type = WALL;
			else 
				board[x][y].type = EMPTY;
			board[x][y].color=7;
			gotoxy(x*2, y);
			puts(Tile[board[x][y].type]);
		}
	}
	gotoxy(WIDTH*2+8,1);
	puts("Stage");
	PrintStage();
	gotoxy(WIDTH*2+8,5);
	puts("Next");
	gotoxy(WIDTH*2+8,11);
	puts("Score");
	PrintScore();
	gotoxy(WIDTH*2+8,15);
	puts("Key");
	gotoxy(WIDTH*2+7,17);
	puts("Arrow");
	gotoxy(WIDTH*2+7,18);
	puts("Space");
	gotoxy(WIDTH*2+9,19);
	puts("S");
	color(1);
	gotoxy(26, 21);
	puts("만든놈");
	gotoxy(26,23);
	puts("정상우");
	color(7);
}
Esempio n. 6
0
void ProcessIncoming(void)
{
	Message message;
	unsigned long int numBytesRead, numBytesWritten;
	int status;
	int numErrors;
	char c;
	int i;

	numErrors = 0;

	while(true) {
		// Get message header
		if(read(hOutputPipe, &message, sizeof(message)) <= 0) {
			if(simptris) EndSimptris();
			return;
		}

		// Get message body
		if(message.length > 0) {
			if(message.length >= CRT_OUT_BUFFER_SIZE) message.length = CRT_OUT_BUFFER_SIZE - 1;
			read(hOutputPipe, buffer, message.length);
		}

		switch(message.action) {
		case EXIT:
			if(simptris) EndSimptris();
			return;
		case CLEAR_SCREEN:
			if(simptris) {
				clear();
				DrawBoardFrame();
				refresh();
			}
			else {
				int i, numRows, numCols;
				GetTermSize(&numRows, &numCols);
				numCols--;
				printf("<END OF OUTPUT>");
				for(i = 0; i < 24; i++) putchar('\n');	// Add blank lines
				while(numCols-- > 0) putchar('_');			// Make separator
				while(numRows-- > 0) putchar('\n');			// Scroll screen
	
				printf("\033[2J");	// Wipe screen
				printf("\033[H");	// Return cursor to home position (or "\033[0;0f" would work)
				fflush(stdout);		// Ensure redraw of screen
			}
			break;
		case PRINT_STRING:
			printString(buffer, message.length);
			fflush(stdout);
			break;
		case PRINT_CHAR:
			putchar(buffer[0]);
			fflush(stdout);
			break;
		case INIT_BOARD:
			if(!InitSimptris()) {
				printf("Simptris couldn't be initialized.\nPress Enter to terminate...");
				getchar();
				return;
			}
			else simptris = true;
			break;
		case PRINT_BOARD:
			PrintBoard(buffer);
			refresh();
			break;
		case PRINT_SCORE:
			PrintScore(*((int *)buffer));
			refresh();
			break;
		default:
			numErrors++;
			if(!simptris) printf("<COMMUNICATION ERROR>\n");
			else printw("<COMMUNICATION ERROR>\n");

			if(numErrors >= MAX_COM_ERRORS) {
				if(simptris) EndSimptris();
				printf("Too many communication errors!\nPress any key to terminate...");
				return;
			}
		}
	}
}
Esempio n. 7
0
File: Tetris.c Progetto: Jn58/Tetris
void main(){
	//sndPlaySound("C/song.wav",SND_ASYNC | SND_LOOP);
	NoCursor();
	system("mode con cols=35 lines=25");
	srand((unsigned)time(NULL));
	system("cls");
	DrawScreen();
	Next.type = rand() % 7;
	Next.pos.x = WIDTH+4;
	Next.pos.y = 8;
	Next.rotation=0;
	Brick.t=BRICK;
	expect.pos.x=5;
	expect.pos.y=10;

	while(1){
		DisplayNext(FALSE);
		Brick.type = Next.type;
		Next.type = rand() % 7;
		DisplayNext(TRUE);
		Brick.pos.x = 5;
		Brick.pos.y = 3;
		Brick.rotation = 0;
		expect=Brick;
		Expect();
		DisplayBrick(Brick,TRUE);
			

		if(CanMove(Brick) != TRUE) break; 
		Delay = 0;
		if(!(rand()%15>0))
			item=1;
		while(1){
			brink^=1;
			Delay++;
			if(Delay == 20 )
			{
				if(MoveDown()){
					break;
				}
				Delay = 0;
			}
			if(PressKey()) break;
			DisplayBrick(Brick,TRUE);	
			Sleep(speed);
		}
		FixBrick();
		PrintScore();
		if(speed>30)
 			speed=50-(score/100)*2;
		else if(speed>15)
			speed=30-((score-1000)/200);
		else if(speed>10)
			speed=15-(score-4000)/600;
		else if(speed>1)
			speed=10-(score-7000)/1000;
		else
			speed=1;


		if(score>=stage*2000){
			stage++;
			DrawScreen();
			gotoxy(9,12);
			printf("Stage %d",stage);
			Sleep(1000);
			while(_kbhit())
				_getch();
			_getch();
			DrawScreen();
		}
		item=0;
		
	}

	system("cls");
	gotoxy(12,12); 
	puts("GAME OVER");
	_getch();
}
Esempio n. 8
0
void CRMjudgeManager::JudgeNoteByPlayer( PlayerNumber playerNumber )
{

	LayerType playerLayer;
	CRMplayer* playerClass = nullptr;
	if ( playerNumber == PLAYER_ONE )
	{
		playerLayer = LAYER_NOTE1;
		playerClass = CRMplayer1P::GetInstance();
	}
	else
	{
		playerLayer = LAYER_NOTE2;
		playerClass = CRMplayer2P::GetInstance();
	}

	CRMobject* thisNote = CRMobjectManager::GetInstance()->GetObjectFront( playerLayer );
	if ( thisNote != nullptr )
	{
		/////////////////////////////////////////////////////////////////
		if ( IsKeyInputRight( thisNote , playerNumber ) )
		{
			if ( thisNote->GetPositionY() > NOTE_JUDGE_PERFECT_START_LINE && thisNote->GetPositionY() < NOTE_JUDGE_PERFECT_END_LINE )
			{
				thisNote->SetVisible(false);
				//effect 플래그 세팅
				//플래그만 세팅하면 이펙트 노출은 알아서 되게끔 하자
				//플래그 세팅하는 곳은 effect manager(싱글톤)를 따로 두고 진행합시다
				/*
						1. judge에서 effect Manager flag세팅
						2. childeffectimage에서 flag 확인
						3. childeffectimage에서 flag 확인 후 다시 flag 초기화
				*/
				float hitPositionX = thisNote->GetPositionX();
				float hitPositionY = thisNote->GetPositionY();
				CRMeffectManager::GetInstance()->SetFlag( playerNumber , hitPositionX , hitPositionY );

				//score up
				playerClass->AddEvent( JUDGE_PERFECT );
				PrintScore( playerNumber, JUDGE_PERFECT );

				if ( m_IsItemRecoverOn[playerNumber] == true )
				{
					playerClass->AddHP(4);
				}

				//키 누르면서 바로 지우면 플래그 세팅이 안됨
				//키를 누르면 무조건 세팅이 되면 miss 처리 불가
				//deleteNote 이동
				CRMobjectManager::GetInstance()->DeleteNoteListFront( playerLayer );
			}
			// Good
			else if ( ( thisNote->GetPositionY() > NOTE_JUDGE_GOOD_START_LINE && thisNote->GetPositionY() < NOTE_JUDGE_GOOD_END_LINE ) )
			{
				thisNote->SetVisible(false);
				//effect 플래그 세팅
				float hitPositionX = thisNote->GetPositionX();
				float hitPositionY = thisNote->GetPositionY();
				CRMeffectManager::GetInstance()->SetFlag( playerNumber , hitPositionX , hitPositionY );

				//score up
				playerClass->AddEvent( JUDGE_GOOD );
				PrintScore( playerNumber, JUDGE_GOOD );

				if ( m_IsItemRecoverOn[playerNumber] == true )
				{
					playerClass->AddHP(2);
				}

				CRMobjectManager::GetInstance()->DeleteNoteListFront( playerLayer );
			}
			// 너무 빨리 눌러 MISS (a키를 누르고 있을때 good나오는 버그 회피)

			else if ( thisNote->GetPositionY() > NOTE_JUDGE_FAST_MISS_LINE )
			{
				thisNote->SetVisible(false);
				
				//score up;
				playerClass->AddEvent( JUDGE_MISS );
				playerClass->SubHP();
				PrintScore( playerNumber, JUDGE_MISS );

				CRMobjectManager::GetInstance()->DeleteNoteListFront( playerLayer );
			}
		}
		//note bottom miss
		else if ( thisNote->GetPositionY() > NOTE_JUDGE_LATE_MISS_LINE )
		{
			
			//score up
			playerClass->AddEvent( JUDGE_MISS );
			playerClass->SubHP();
			PrintScore( playerNumber, JUDGE_MISS );

			//thisNote->SetPosition( DEFAULT_POSITION_X, DEFAULT_POSITION_Y );
			CRMobjectManager::GetInstance()->DeleteNoteListFront( playerLayer );

		}
		// Perfect 
		

		/////////////////////////////////////////////////////////////////
	}
}
Esempio n. 9
0
File: wuziqi.cpp Progetto: HH-LFY/HH
void playtoplay()/*人人对战*/
{
int x,y,t=1,i,j,cc=0;
while(1)/*换棋手走棋*/
{
x=120,y=80;/*每次棋子一开始出来的坐标,x为行坐标,y为列坐标*/
while(1) /*具体一个棋手走棋的过程*/
{
PrintScore(1);/*输出棋手1的成绩*/
PrintScore(2);/*输出棋手2的成绩*/
SetPlayColor(t);/*t变量是用来判断棋手所执棋子的颜色*/
fillellipse(x,y,15,15);
key=bioskey(0);/*接收按键*/
if(key==ESC)/*跳出游戏*/
break;
else
if(key==ENTER)/*如果按键确定就可以跳出循环*/
{
if(y!=80&&a[(x-120)/40][(y-120)/40]!=1
&&a[(x-120)/40][(y-120)/40]!=2)/*如果落子位置没有棋子*/
{
if(t%2==1)/*如果是棋手1移动*/
a[(x-120)/40][(y-120)/40]=1;
else/*否则棋手2移动*/
a[(x-120)/40][(y-120)/40]=2;
if(!QpChange(x,y,t))/*落子后判断棋盘的变化*/
{
a[(x-120)/40][(y-120)/40]=0;/*恢复空格状态*/
cc++;/*开始统计尝试次数*/
if(cc>=64-score1-score2) /*如果尝试超过空格数则停步*/
{
MoveColor(x,y);
fillellipse(x,y,15,15);
break;
}
else
continue;/*如果按键无效*/
}
DoScore();/*分数的改变*/
break;/*棋盘变化了,则轮对方走棋*/
}
else/*已经有棋子就继续按键*/
continue;
}
else /*四个方向按键的判断*/
if(key==LEFT&&x>120)/*左方向键*/
{
MoveColor(x,y);
fillellipse(x,y,15,15);
SetPlayColor(t);
x-=40;
fillellipse(x,y,15,15);
}
else
if(key==RIGHT&&x<400&&y>80)/*右方向键*/
{
MoveColor(x,y);
fillellipse(x,y,15,15);
SetPlayColor(t);
x+=40;
fillellipse(x,y,15,15);
}
else
if(key==UP&&y>120)/*上方向键*/
{
MoveColor(x,y);
fillellipse(x,y,15,15);
SetPlayColor(t);
y-=40;
fillellipse(x,y,15,15);
}
else
if(key==DOWN&&y<400)/*下方向键*/
{
MoveColor(x,y);
fillellipse(x,y,15,15);
SetPlayColor(t);
y+=40;
fillellipse(x,y,15,15);
}
}
if(key==ESC)/*结束游戏*/
break;
if((score1+score2)==64||score1==0||score2==0)/*格子已经占满或一方棋子为0判断胜负*/
{
playWin();/*输出最后结果*/
break;
}
t=t%2+1; /*一方走后,改变棋子颜色即轮对方走*/
cc=0; /*计数值恢复为0*/
} /*endwhile*/
}
Esempio n. 10
0
PlayMaze()
{
    PrintStatus();             /* Prints the score and everything else */

    BlackOut(ALLBLACK);     /* Hide the reconstruction of the viewPort */
    WaitTOF(),WaitTOF();            /* Wait for the Blackout to finish */

    InitializeStarting();

    ScrollDisplay(SCROLLDEFINITELY);

    killallsound();

    button=0;
    joyx=0;
    joyy=0;     /* Initialize Joy Regs */

    JoyRead(CTRLR_RESET);

    while(!(joyx || joyy))
    {
        WaitTOF();
        JoyRead(CTRLR_READ);
    }

    playsound(SND_BACKGRND,0),playsound(SND_BACKGRND,0);

    SetAPen(rastport,PATHCOLOR);            /* We will be erasing dots */
    for(i=0; i<numghosts; i++) energized[i]=0;

    while(dead>=0 && numdots)
    {
        tx=xposn[0]+XOFF;
        ty=yposn[0]+YOFF;

        if(tx>=minx-1 && tx<=maxx+1 && ty>=miny-1 && ty<=maxy+1)
        {
            lookhere=ReadPixel(rastport,tx+x_dir,ty+y_dir);
            if(lookhere==DOTCOLOR)
            {
                atedot++;
                WritePixel(rastport,tx+x_dir,ty+y_dir);
                INCSCORE(10);
                if(--numdots==advspeed[speedindex])
                {
                    speedindex++;
                    if(killsound(SND_BACKGRND))
                        playsound(SND_BACKGRND,0),playsound(SND_BACKGRND,0);
                }
                playsound(SND_DOT,1);
            }
            else if(lookhere==ENERGCOLOR)
            {
                atedot=1;
                for(i=-1; i<2; i++) for(c=-1; c<2; c++)      /* Erase energizer */
                        WritePixel(rastport,tx+(x_dir<<1)+c,ty+(y_dir<<1)+i);
                INCSCORE(50);
                if(--numdots==advspeed[speedindex])
                {
                    speedindex++;
                    if(killsound(SND_BACKGRND))
                        playsound(SND_BACKGRND,0),playsound(SND_BACKGRND,0);
                }
                playsound(SND_DOT,1);
                Energize();
            }
        }
        if((!joyx)^(!joyy)) joy_dir =(joyy)?(1+joyy):(2-joyx);
        if(x_dir || y_dir) dir_code=(y_dir)?(1+y_dir):(2-x_dir);
        dvx=xposn[0]+XOFF-pdest_v->x;
        dvy=yposn[0]+YOFF-pdest_v->y;
        old_dcode = dir_code;
        if((ABS(dvx)+ABS(dvy))<2 && joy_dir!=dir_code
                && pdest_v->next[joy_dir])
        {
            dir_code = joy_dir;
            dvx=0;
            dvy=0;
            xposn[0]=pdest_v->x-XOFF;
            yposn[0]=pdest_v->y-YOFF;
            at_vertex = TRUE;
        }
        else at_vertex=((!dvx && !dvy) || (x_dir==y_dir));

        if ((!joyx)^(!joyy))     /* if joy movement */
        {
            if (at_vertex)
            {
                if(joyx && pdest_v->next[joy_dir]
                        && !(pdest_v->code[joy_dir]&FORBID))
                {
                    pmv=pdest_v;
                    pdest_v=pdest_v->next[joy_dir];       /* Destination vertex */
                    x_dir=joyx;                  /* Direction we are now headed */
                    y_dir=0;
                }
                else if(joyy && pdest_v->next[1+joyy]
                        && !(pdest_v->code[1+joyy]&FORBID))
                {
                    pmv=pdest_v;
                    pdest_v=pdest_v->next[1+joyy];
                    x_dir=0;
                    y_dir=joyy;
                }
                else if ((!(pdest_v->next[joy_dir])
                          || (pdest_v->code[joy_dir]&FORBID))
                         && ((!(pdest_v->next[old_dcode])
                              || (pdest_v->code[old_dcode]&FORBID))))
                    /* If(at_vertex && no (allowable) next vertex) dead end;stop */
                {
                    x_dir=0;
                    y_dir=0;
                }
                else if (x_dir||y_dir) /* Joy in invalid dir on vertex */
                {
                    pmv=pdest_v;  /* There is a path in current dir - follow it */
                    pdest_v=pdest_v->next[old_dcode];
                    dir_code = old_dcode;
                }
            }                          /* End of block for if at a vertex */
            else if (joyx && !(joyx+x_dir)) /* Reverses direction on edge */
            {
                x_dir=-x_dir;              /* Reverse current direction */
                tv=pdest_v;            /* Swap pdest_v with last vertex */
                pdest_v=pmv;
                pmv=tv;
            }
            else if (joyy && !(joyy+y_dir))       /* Reverses dir along y */
            {
                y_dir=-y_dir;              /* Reverse current direction */
                tv=pdest_v;            /* Swap pdest_v with last vertex */
                pdest_v=pmv;
                pmv=tv;
            }
        } /* End of block for if no button but movement on joystick */
        else if (at_vertex && (y_dir || x_dir))   /* move but no joymove */
        {
            if(x_dir && (!pdest_v->next[old_dcode]
                         || (pdest_v->code[old_dcode]&FORBID)))
                x_dir=0;/* Stop @ Dead End */
            else if(y_dir && (!pdest_v->next[old_dcode]
                              || (pdest_v->code[old_dcode]&FORBID)))
                y_dir=0;
            else
            {
                pmv=pdest_v;                 /* Continue moving to next vertex */
                pdest_v=pdest_v->next[old_dcode];
            }
        }
        if (atedot<2)
        {
            xposn[0]+=x_dir;
            yposn[0]+=y_dir;
        }
        else atedot=0;

        WrapSprite(0,x_dir,y_dir);                /* Wrap around routine */
        spoff=((xposn[0]+yposn[0])>>1)&3;
        spoff=(spoff>2) ? (1+3*dir_code) : (spoff+3*dir_code);
        ChangeSprite(svp,&sprite[0],(short *)(pacmen+spoff));

        if ((dead=MoveGhosts())<0) {
            dead=-1;
            --lives;                        /* Kill a PACMAN */
            Die();
        }
        else {
            ScrollDisplay(SCROLLMAYBE);
            PrintScore();
        }
        if(dead>0) {
            killallsound();
            playsound(SND_MONSTER,1);
            playsound(SND_MONSTER,1);
            DeEnergize(dead-1,0);                          /* Eat a ghost! */
            playsound(SND_EYES,0);
        }
        JoyRead(CTRLR_READ);
    }                             /* End of main control loop */
    return 0;
}                                /* End of loop to decrement lives. */
Esempio n. 11
0
void GameScore::printScore()
{
	// スコア表示
	PrintScore(miScore);
}
Esempio n. 12
0
void DisplayScreen()
{	setcolor(15);
	rectangle(156,26,478,452);                                      //for border of play box
	rectangle(158,28,476,450);					//for play box
	DrawBox(488,300,620,450, YELLOWBR, YELLOW, YELLOWDR);		//for next brick bar
	DrawBox(488,28,620,290, YELLOWBR, YELLOW, YELLOWDR);		//for information bar
	DrawBox(10,255,150,450, YELLOWBR, YELLOW, YELLOWDR);		//for instruction bar
	setcolor(PURPLE);
	settextstyle(0,0,1);
	outtextxy(500,310, "Next");
	outtextxy(538,310,"Brick");
	setcolor(PURPLE);
	outtextxy(500,40, "Score");
	setcolor(GREEN);
	rectangle(500,50,608,70);                       //for score box
	setcolor(PURPLE);
	settextstyle(0,0,1);
	outtextxy(500,100, "Level");
	setcolor(GREEN);
	rectangle(500,110,608,130);                     //for level box
	setcolor(PURPLE);
	outtextxy(500,160, "Speed");
	setcolor(GREEN);
	rectangle(500,170,608,190);                     //for speed box
	setcolor(PURPLE);
	outtextxy(500,220, "Lines");
	outtextxy(547,220,"Cleared");
	setcolor(GREEN);
	rectangle(500,230,608,250);			//for line cleared box
	PrintScore();                                   //Display scorecard
	PrintSpeed();                                   //Display speed
	PrintLevel();                                   //Display level
	PrintLinesCleared();                            //Display lines cleared
	setcolor(REDBR);
	settextstyle(10,1,4);
	outtextxy(0,30, "Aguntuk");				//for name
	outtextxy(60,60, "Bricks");
	setcolor(GREEN);
	settextstyle(8,0,2);
	outtextxy(20,255,"KEYS:");
	settextstyle(0,0,1);
	setcolor(PURPLE);
	outtextxy(20,290,"Left");
	setlinestyle(0,0,2);
	line(100,293,103,290);                          //for left arrow's \
	line(100,293,103,296);                          //for left arrow's /
	line(100,293,109,293);				//for left arrow's hyphen
	outtextxy(20,310,"Right");
	line(109,313,106,310);                          //for right arrow's \
	line(100,313,109,313);                          //for right arrow's hyphen
	line(109,313,106,316);                          //for right arrow's /
	outtextxy(20,330,"Rotate");
	outtextxy(100,330,"^");
	line(103,330, 103, 340);			//for up arrow's hyphen
	outtextxy(20,350,"Drop");
	line(103,350, 103, 360);			//for down arrow's hyphen
	line(100,357, 103, 360);			//for down arrow's \
	line(106,357, 103, 360);			//for down arrow's /
	outtextxy(20,370,"Pause");
	outtextxy(100,370,"P");
	outtextxy(20,390,"Sound");
	outtextxy(100,390,"S");
	outtextxy(20,410,"About");
	outtextxy(100,410,"A");
	outtextxy(20,430,"Exit");
	outtextxy(100,430,"Esc");
	setcolor(GREEN);
}
Esempio n. 13
0
int main(){
	int gd=DETECT, gm;
	int Return=0;
	char Key, ScanCode;
	int Counter=0;                          //Divide total delay & take multiple input
	initgraph(&gd, &gm,"c:\\tc\\bgi");      //initialize graphics mode
	randomize();                            //Randomize block's shapes & color
	cleardevice();                          //clear screen
	InitPalette();                          //for setting color pallete
	InitMatrix();                           //Initialize Matrix
	GetImages();                            //Saving the images
	StartScreen();                          //for start screen
	cleardevice();                          //clear screen
	AssignShape(GetRandomShape(), GetRandomColor());      //for the falling block
	NextShape=GetRandomShape();
	NextColor=GetRandomColor();                                         	DisplayScreen();                        //Show main screen
	DisplayNextShape();                     //show next brick
	MoveBlock(LEFT);                        //keep the block on center & check game over
	while(kbhit()) getch();  		//empty the keyboard input
	while (!Quit && !GameOver) {            //Moving the blocks down
		if(++Counter >= Speed)          //For controling the speed
		{	Counter=0;
			MoveBlock(DOWN);
			SoundDrop();
		}
		if(kbhit())                     //For the arrow keys
		{  Key = getch();
		   if(Key == 0)
		   {	   ScanCode = getch();
			   if(ScanCode == KEY_UP)
					RotateBlock();
			   else if(ScanCode == KEY_LEFT)
					MoveBlock(LEFT);
			   else if(ScanCode == KEY_RIGHT)
					MoveBlock(RIGHT);
			   else if(ScanCode == KEY_DOWN)
			   {		Score++;         //increase score
					PrintScore();
					MoveBlock(DOWN);
			   }
			   if(!Return)
				   SoundDrop();
			   Return = 0;
		   }
		   else if(Key == KEY_ENTER || Key == KEY_SPACE)   //Rotating bricks
				RotateBlock();
		   else if(Key == 'P' || Key == 'p')      //For pause
		   {	  MessageBox("  Paused");
			  while(kbhit()) getch();         //clear the keyboard input
			  for(int x=0; x<COLS; x++)
				 for(int y=0; y<ROWS; y++)
					PreviousScreenLayout[x][y] -= 1;    //Clear the present screen layout to refresh the whole screen
			  UpdateScreen();                //refresh screen
		   }
		   else if(Key == KEY_ESC)                                      //For quit
		   {	  char ret = MessageBox("Are you sure, you want to Quit?", 563, 2);
			  if(ret == 'y' || ret == 'Y' || ret == KEY_ENTER)
			  {	  Quit = 1;
				  break;
			  }
			  cleardevice();                              //Clear the message box
			  while(kbhit()) getch();  		      //Clear the keyboard input
			  for(int x=0; x<COLS; x++)
				 for(int y=0; y<ROWS; y++)
					PreviousScreenLayout[x][y] -= 1;    // Clear the present screen layout to refresh the whole screen
			  UpdateScreen();                //refresh screen
			  DisplayScreen();               //show the main screen again
			  DisplayNextShape();            //show next brick box
		   }
		   else if(Key == 's' || Key == 'S')        //For sound on/off
		   {
			  SoundOn = !SoundOn;

		   }
		   else if(Key=='a' || Key=='A')                      //For author
		   {	 MessageBox("Author: Aguntuk Group",450);
			 cleardevice();                               //Clear the message box
			 while(kbhit()) getch();                      //Clear the keyboard input
			 for(int x=0;x<COLS;x++)
				for(int y=0;y<ROWS;y++)
					PreviousScreenLayout[x][y] -=1;     //Clear the present screen layout to refresh the whole screen
			 UpdateScreen();                   //refresh screen
			 DisplayScreen();                  //show the main screen again
			 DisplayNextShape();               //show next brick box
		   }
		}
		delay(6);      	      //For moving down the blocks slowly
	}
	if(GameOver)                  //For game over option
	{      	DisplayBlock(6,0);    //For display the top most brick
		ShowGameOver();       //For display game over message box
	}
	restorecrtmode();    //For closing graphicg mode
	return 0;
}
// Update: draw background
update_status ModuleLevelOne::Update()
{
	// Draw everything --------------------------------------
	if (clock >= 40 && clock <= 180)
	{
		App->renderer->Blit(interficie, 0, pos_mid, &(x_mid->GetCurrentFrame()));
		if (pos_mid > 23)
		{
			pos_mid -= 5; // Smooth
		}
		if (pos_mid < 23)
		{
			pos_mid = 23;
		}
		else if (pos_mid > 23)
		{
			pos_mid -= 4;
		}
		if (pos_title <= 64)
		{
			pos_title += 6;
		}
	}

	if (clock >= 150)
	{
		pos_title += 8;
	}
	
	if (clock >= 180)
	{
		App->renderer->Blit(interficie, 0, 23, &(x_raw_layout->GetCurrentFrame()));
		App->map->Enable();
		App->particles->Enable();
		App->player->Enable();
		App->enemy->Enable();
	}

	App->renderer->Blit(interficie, 0, 0, &(x_layout->GetCurrentFrame()));

	// Timer
	if (clock >= 180 && clock < 6900)
	{
		App->renderer->Blit(interficie, 124, 14, &(x_timer->GetCurrentFrame()));
		for (int k = 13 - (1 * ((clock - 179) / 535)); k >= 0; k--)
		{
			App->renderer->Blit(interficie, 114 - (k * 8), 26, &(x_timer_square->GetCurrentFrame()));
		}
	}

	// Score

	PrintScore();

	if (App->player->score > incremental_score)
	{
		incremental_score += 5;
	}

	// Player dies if time runs out
	if (clock == 6900)
	{
		App->player->player_losses = true;
		App->player->life -= 1;
	}

	// Defeat
	if (App->player->life == 0)
		lose = true;

	App->renderer->Blit(interficie, pos_title, 90, &(x_title->GetCurrentFrame()));

	clock++;

	//Check Game Over
	if (win && !scene_transition)
	{
		App->fade->FadeToBlack(this, App->level_boss, 3.0f);
		scene_transition = true;
	}

	if (lose && !scene_transition)
	{
		App->fade->FadeToBlack(this, App->scene_intro, 3.0f);
		scene_transition = true;
	}

	return UPDATE_CONTINUE;
}