Example #1
0
void DrawScore(int xcenter, int ycenter, int p1_score, int p2_score, GameState *g)
{

	int right_center, left_center;
	right_center = xcenter + 20;
	left_center = xcenter - 20;
	DrawRectangle ((left_center - 5), (ycenter - 4), 10, 9, 1);
	DrawRectangle ((right_center - 5), (ycenter - 4), 10, 9, 1);
	DrawCircle((left_center - 10), ycenter, 2, 3);
	DrawCircle((right_center + 10), ycenter, 2, 3);
	DrawNumber(left_center, ycenter, p1_score);
	DrawNumber(right_center, ycenter, p2_score);

	if (isEndTurn(*g)) {
		if (g->turn_id == 0) {
			if (g->scratch){
				DrawCircle((left_center - 10), ycenter, 2, 0);
			} else if (all_balls_sunk(g, g->turn_id)) {
				DrawCircle((left_center - 10), ycenter, 2, 4);
			} else {
				DrawCircle((left_center - 10), ycenter, 2, 1);
			}
		}	else {
			if (g->scratch){
				DrawCircle((right_center + 10), ycenter, 2, 0);
			} else if (all_balls_sunk(g, g->turn_id)) {
				DrawCircle((right_center + 10), ycenter, 2, 4);
			} else {
				DrawCircle((right_center + 10), ycenter, 2, 2);
			}
		}
	}
}
Example #2
0
  void App::Draw() {
	SetProjection(fieldWidth, fieldHeight);

	if (!progress.IsPaused()) {
	  shaker.ApplyMatrix();
	  asteroids.Draw();
	  spliceAsteroids.Draw();
	  stars.Draw();
	  for (int i = 0; i < maxPlayersCount; i++) {
		players[i].Draw();
	  }
	  DrawNumber(false,
				 fieldWidth - 5.0f,
				 fieldHeight - 10.0f,
				 1,
				 1.5,
				 progress.GetLevel());
	  DrawNumber(true,
				 5.0f,
				 fieldHeight - 10.0f,
				 1,
				 1.5,
				 scoreTotal);
	}

	SetTranslate(0, 0);
	progress.Draw();
  }
Example #3
0
void S1Init()
{
	char str[16];
	char name[16];

	ScreenBox.g_x = ScreenBox.g_y = 0;
	ScreenBox.g_w = 320;
	ScreenBox.g_h = 192;

	/* initialiser ecrans */
	UnTiny(TnyRayoid);
	MemClear(_Screens[0],32000L);
	MemClear(_Screens[1],32000L);
	SwapReset();

	Alien.on = 0;
	Alien.mis.on = 0;
	Joueur[0].points = 0;
	S1Bonus = 2000;
	S1Level = 0;

	S1AstCreate();

	strcpy(str,"~8");
	strcpy(name,S1Stats.name);
	StrRight(name,8);
	strcat(str,name);
	_ShowStr(200,192,str,0);
	CopyZone(192,192,80,8);

	DrawNumber(272,192,S1Stats.score);

	S1ShowSpare(4);
}
Example #4
0
void InitializeGame(int x_cur, int y_cur)
{
	int i,j;
	for (i=0; i<15; i++) {
		for (j=0; j<15; j++) {
		    board_state[i][j]=EMPTY;
		}
	}
	DrawNumber(level,3,2,EMPTY);
	DrawWinning(0,1, EMPTY);
	DrawStatus(1, 21, EMPTY,PVP);
	DrawBack(3,1119,EMPTY);
	count=0;
	time0=0;
	turn=HUMAN_PLAYER;
	step_flag=0;
	win_flag=0;

	DrawBoard();
	DrawChess(x_cur, y_cur, CURSOR);
	DrawTime(88, EMPTY);
	DrawTime(30, turn);
	DrawStatus(1, 21, COMPUTER_PLAYER,PVP);
	xil_printf("\r\nGame Start!\r\n");

}
Example #5
0
/*
 * This draws a legend of the data sets displayed.  Only those that
 * will fit are drawn.
 */
int DrawLegend(char *gw, GraphWin * wi)
{
    DataSet *temp;
    int cnt;

    int idx, spot, lineLen, oneLen;
    XSegment leg_line;
    int markFlag;

    spot = wi->XOrgY;
    lineLen = 0;
    /* First pass draws the text */
    for(temp = wi->Data; temp != NULL; temp = temp->next) {
	if ((temp->list) && (spot + wi->dev_info.axis_height + 2 < wi->XOppY)) {
	    if (temp->setName) {
		/* Meets the criteria */
		oneLen = strlen(temp->setName);
		if (oneLen > lineLen) lineLen = oneLen;
		wi->dev_info.xg_text(gw,
				     wi->XOppX + wi->dev_info.bdr_pad,
				     spot+wi->dev_info.bdr_pad,
				     temp->setName,
				     T_UPPERLEFT, T_AXIS);
	    }
	    else {
		if (8 > lineLen) lineLen = oneLen;
		DrawNumber(gw, wi, temp->setValue,
			   wi->XOppX + wi->dev_info.bdr_pad,
			   spot+wi->dev_info.bdr_pad, T_UPPERLEFT, 0);
	    }
	    spot += 2 * wi->dev_info.axis_height;
        }
    }

    lineLen = lineLen * wi->dev_info.axis_width;
    leg_line.x1 = wi->XOppX + wi->dev_info.bdr_pad;
    leg_line.x2 = leg_line.x1 + lineLen;
    spot = wi->XOrgY;

    /* second pass draws the lines */
    for(cnt = 0, temp = wi->Data; temp != NULL; temp = temp->next, cnt++) {
	markFlag = temp->marker;
	if ((temp->list) && (spot + wi->dev_info.axis_height + 2 < wi->XOppY)) {
	    leg_line.y1 = leg_line.y2 = spot - wi->dev_info.legend_pad;
	    wi->dev_info.xg_seg(gw,
				  1, &leg_line, 1, L_VAR,
				  cnt, cnt);
	    if (markFlag) {
		wi->dev_info.xg_dot(gw,
				      leg_line.x1, leg_line.y1,
				      P_MARK, cnt, cnt);
	    }
	    spot += 2 * wi->dev_info.axis_height;
	}
    }
}
void DrawAirLeft(int x, int y)
{
	if (player->airshowtimer)
	{
		draw_sprite(x, y, SPR_AIR, (player->airleft%30 > 10) ? 0:1, RIGHT);
		
		if (player->airshowtimer%6 < 4)
			DrawNumber(x+32, y, player->airleft/10);
	}
}
void DrawWeaponAmmo(int x, int y, int wpn)
{
	// draw slash
	if (!player->hurt_flash_state || game.mode != GM_NORMAL)
	{
		draw_sprite(x, y+8, SPR_WHITENUMBERS, 11, 0);
	}
	
	if (!player->weapons[wpn].maxammo)
	{	// ammo is "not applicable"
		x += 16;
		draw_sprite(x, y, SPR_NAAMMO, 0, 0);
		draw_sprite(x, y+8, SPR_NAAMMO, 0, 0);
	}
	else
	{
		DrawNumber(x, y, player->weapons[wpn].ammo);
		DrawNumber(x, y+8, player->weapons[wpn].maxammo);
	}
}
Example #8
0
/**
**	Draw the stat for an unit in top-panel.
**
**	@param x	Screen X position
**	@param y	Screen Y position
**	@param modified	The modified stat value
**	@param original	The original stat value
*/
local void DrawStats(int x,int y,int modified,int original)
{
    char buf[64];

    if( modified==original ) {
	DrawNumber(x,y,SMALL_FONT,modified);
    } else {
	sprintf(buf,"%d~+~%d",original,modified-original);
	// FIXME: 10 reverse???
	DrawText(x,y,SMALL_FONT,buf);
    }
}
Example #9
0
//  Play a full championship match (13 set) and display winner and table of results at end
void Match::Play(Player players[], int BGPos[], int cursorpos[], int cursoractual[]) {
	bool running = true;
	int set = 0;
	bool winner;
	
	while(running) {
	
		if (set < 12) {
			sets[set].Play(players, BGPos, cursorpos, cursoractual);
		} else {
			sets[set].PlayTieBreaker(players, BGPos, cursorpos, cursoractual);
		}
		set++;
		
		if (players[0].p_setwins == 7) {
			running = false;
			winner = 0;
			
		}
		if (players[1].p_setwins == 7) {
			running = false;
			winner = 1;
		}
	
	}
 	ClearScreenBlocks(25,31);
	DrawWindow(0, 0, 30, 20);
	players[0].DrawName(9, 1);
	players[1].DrawName(14, 1);
	for (int i = 0; i < set; i++) {
		DrawNumber(11, i+2, players[0].p_legwins[i], 25);
		DrawNumber(14, i+2, players[1].p_legwins[i], 25);
	}
	
	players[winner].DrawName(8, 18);
	DrawText(13,18, "Wins the Match!", 25);
	
	while(true) {}
	
};
Example #10
0
//  Draw current points onto screen
void Player::DrawPoints(int x, int y) {
	// int tile = 0;
	y -= 4;
	y = (y > 12 ? 12 : y);
	if (y < 12) {
		p_pointsdisplay[y] = p_points;
		DrawNumber(x, y+4, p_points, 25);
		if (y > 0) {
			DrawText(x, y+3, "---", 26);
		}
	} else {	
		for (int i = 0; i < 11; i++) {
			p_pointsdisplay[i] = p_pointsdisplay[i+1];
		}
		p_pointsdisplay[11] = p_points;
		for (int i = 0; i < 12; i++) {
			SetTile(25, x, i+4, 0);
			SetTile(25, x+1, i+4, 0);
			SetTile(25, x+2, i+4, 0);
			DrawNumber(x, i+4, p_pointsdisplay[i], 25);
		}
	}
}
Example #11
0
void HUD::ProcessNumber(int number, Vector2i locationStart, int size)
{
	int space = 0;
	do
	{
		//Make digit the modulus of 10 from number.
		int digit = number % 10;
		//This sends a digit to the draw function with the location and size.
		DrawNumber(Vector2i(locationStart.x - space, locationStart.y), digit, size);
		// Dividing the int by 10, we discard the digit that was derived from the modulus operation.
		number /= 10;
		// Move the location for the next digit location to the left. We start on the right hand side with the lowest digit.
		space += size * 2;
	} while (number > 0);
}
Example #12
0
void niku_draw(int value, bool force_white)
{
	int clkframe = (game.counter % 30) <= 10;
	if (game.frozen || player->inputs_locked || force_white) clkframe = 0;
	
	draw_sprite(NIKU_X, NIKU_Y, SPR_NIKU_CLOCK, clkframe);
	
	int mins = (value / 3000);		// the game runs at 50 fps
	int secs = (value / 50) % 60;
	int tens = (value / 5) % 10;
	
	DrawNumber(NIKU_X, NIKU_Y, mins);
	DrawTwoDigitNumber(NIKU_X+36, NIKU_Y, secs);
	DrawDigit(NIKU_X+56, NIKU_Y, tens);
	
	draw_sprite(NIKU_X+30, NIKU_Y, SPR_NIKU_PUNC);
}
Example #13
0
CardLabel::CardLabel( Card* pc, int offset, QRect rect)
{
    QString resourcePath;
    if(pc->GetColor() == BLACK)
    {
        resourcePath = QString::fromUtf8(":/VenciCode/Resources/Cards/black_bg.png");
    }
    else if(pc->GetColor() == WHITE)
    {
        resourcePath = QString::fromUtf8(":/VenciCode/Resources/Cards/white_bg.png");
    }
    QPixmap *cardImage = new QPixmap(resourcePath);
    DrawNumber(cardImage, pc->GetNumStr());
    setPixmap(*cardImage);
    setGeometry(rect);
    QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    setSizePolicy(sizePolicy);
    pCard = pc;
    this->installEventFilter(this);
}
Example #14
0
int CTitle::Draw()
{
	D3DVIEWPORT9 view = { 0, 0, WINDOW_WIDTH, WINDOW_WIDTH, 0.0, 1.0 };
	Sun3D.SetViewport( view );

	RECT rect;
	const int h = 32;
	const int h2 = 100;
	int x=50;
	int y=220;
	switch( mode ) {
	case 0: //タイトル画面
		if( g_pTitle->otaku ) {
			SetRect(&rect,0,0,512,480);
			g_pTitleMaterial->imgTitle.DrawRect(0,0,rect);
			SetRect(&rect,0,0,128,480);
			g_pTitleMaterial->imgRight.DrawRect(512,0,rect);
		}
		else
		Sun3D.Clear( xrgb(0,0,0));

		//Start
		SetRect(&rect,0,0,104,32);
		g_pTitleMaterial->imgTitleMoji.DrawRect(x,y,rect,alpha(128+127*(title_select==0)));
		y+=h;
		
		//Extra Start
		//SetRect(&rect,0,32,216,64);
		//g_pTitleMaterial->imgTitleMoji.DrawRect(50,190+h,rect,alpha(128+127*(title_select==1)));
		
		//Practice
		SetRect(&rect,0,64,150,96);
		g_pTitleMaterial->imgTitleMoji.DrawRect(x,y,rect,alpha(128+127*(title_select==2)));
		y+=h;
		
		//Replay
		SetRect(&rect,0,96,120,136);
		g_pTitleMaterial->imgTitleMoji.DrawRect(x,y,rect,alpha(128+127*(title_select==3)));
		y+=h;
		
		//Result
		SetRect(&rect,0,136,120,168);
		g_pTitleMaterial->imgTitleMoji.DrawRect(x,y,rect,alpha(128+127*(title_select==4)));
		y+=h;

		//Music Room
		//SetRect(&rect,0,168,200,208);
		//g_pTitleMaterial->imgTitleMoji.DrawRect(50,190+5*h,rect,alpha(128+127*(title_select==5)));

		//Option
		SetRect(&rect,0,208,128,248);
		g_pTitleMaterial->imgTitleMoji.DrawRect(x,y,rect,alpha(128+127*(title_select==6)));
		y+=h;
		
		//Quit
		SetRect(&rect,128,208,256,248);
		g_pTitleMaterial->imgTitleMoji.DrawRect(x,y,rect,alpha(128+127*(title_select==7)));
		y+=h;
		break;
	case 1: //難易度選択
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		for( int i = 0; i < 4; ++i ) {
			SetRect(&rect,0,128*i,256,128*(i+1));
			g_pTitleMaterial->imgDifficult.DrawRect(50,h2*i,rect,alpha(128+127*(difficult_select==i)));
		}
		break;
	case 2: //ステージ選択
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		for(int i = 1; i < 7; i++){
			SetRect(&rect,0,32,96,64);
			g_pTitleMaterial->imgStageMoji.DrawRect(400,100+50*i,rect,alpha(128+127*(stage_select==i)));
			SetRect(&rect,i*32,0,(i+1)*32,32);
			g_pTitleMaterial->imgStageMoji.DrawRect(500,100+50*i,rect,alpha(128+127*(stage_select==i)));
		}
		for( int i = 0; i < 4; ++i ) {
			SetRect(&rect,0,128*i,256,128*(i+1));
			g_pTitleMaterial->imgDifficult.DrawRect(50,h2*i,rect,alpha(128+127*(difficult_select==i)));
		}
		break;
	case 3: //リプレイ選択
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		for(int i = 0; i < REPLAY_NUM; i++){
			if( replay_exist[i] )
				DrawNumber(100+i/10*100,80+30*(i%10),i,2,alpha(128+127*(replay_select==i)),1);
		}
		break;
	case 4: //リザルト選択
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		SetRect(&rect,0,64,100,96);
		g_pTitleMaterial->imgStageMoji.DrawRect(200,200,rect,alpha(128+127*(result_select==0)));
		
		SetRect(&rect,100,64,256,96);
		g_pTitleMaterial->imgStageMoji.DrawRect(200,250,rect,alpha(128+127*(result_select==1)));

		break;
	case 6: //オプション
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		//コンフィグ
		for( int i = 0; i < 8; ++i ) {
			rect.left = 0;
			rect.top = 32*i;
			rect.bottom = 32*(i+1);
			int right[] = {80,112,112,112,128,112,144,80};
			rect.right = right[i];
			g_pTitleMaterial->imgConfig.DrawRect(50,64+32*i,rect,alpha(128+127*(option_select==i)));
		}
		//FullScrean
		SetRect(&rect,96,0,256,32);
		g_pTitleMaterial->imgConfig.DrawRect(200,64,rect,alpha(128+127*(optMode.m_now==0)));
		//Window
		SetRect(&rect,128,32,256,64);
		g_pTitleMaterial->imgConfig.DrawRect(360,64,rect,alpha(128+127*(optMode.m_now==1)));
		//16Bit
		SetRect(&rect,128,64,256,96);
		g_pTitleMaterial->imgConfig.DrawRect(200,96,rect,alpha(128+127*(optGraphic.m_now==16)));
		//32Bit
		SetRect(&rect,128,96,256,128);
		g_pTitleMaterial->imgConfig.DrawRect(360,96,rect,alpha(128+127*(optGraphic.m_now==32)));
		//BGMVol
		{
			SunEffectGauge gauge;
			SetRect( &gauge.m_rect, 200, 132, 400, 156 );
			gauge.m_point = (double)optBGMVol.m_now/100.0;
			gauge.m_downColor = xrgb(0,0,0);
			gauge.m_yoko = 1;
			gauge.Draw();

			gauge.m_rect.left += 1;
			gauge.m_rect.top += 1;
			gauge.m_rect.right -= 1;
			gauge.m_rect.bottom -= 1;
			gauge.m_downColor = xrgb(255,255,255);
			gauge.Draw();
		}
		//SEVol
		{
			SunEffectGauge gauge;
			SetRect( &gauge.m_rect, 200, 164, 400, 188 );
			gauge.m_point = (double)optSEVol.m_now/100.0;
			gauge.m_downColor = xrgb(0,0,0);
			gauge.m_yoko = 1;
			gauge.Draw();

			gauge.m_rect.left += 1;
			gauge.m_rect.top += 1;
			gauge.m_rect.right -= 1;
			gauge.m_rect.bottom -= 1;
			gauge.m_downColor = xrgb(255,255,255);
			gauge.Draw();
		}
		//Interval
		{
			SetRect(&rect,1*24,0,(1+1)*24,32);
			g_pTitleMaterial->imgKeyConfig.DrawRect(200,64+32*4,rect,alpha(128+127*(optInterval.m_now==1)));
			SetRect(&rect,2*24,0,(2+1)*24,32);
			g_pTitleMaterial->imgKeyConfig.DrawRect(250,64+32*4,rect,alpha(128+127*(optInterval.m_now==2)));
			SetRect(&rect,3*24,0,(3+1)*24,32);
			g_pTitleMaterial->imgKeyConfig.DrawRect(300,64+32*4,rect,alpha(128+127*(optInterval.m_now==3)));
		}
		break;
	case 7: //キーコンフィグ
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		//コンフィグ
		for( int i = 0; i < 7; ++i ) {
			SetRect(&rect,0,32*(i+1),150,32*(i+2));
			g_pTitleMaterial->imgKeyConfig.DrawRect(50,64+32*i,rect,alpha(128+127*(config_select==i)));
			//数字
			int inp  = optKeyConfig[i].m_now;
			SetRect(&rect,inp%10*24,0,(inp%10+1)*24,32);
			g_pTitleMaterial->imgKeyConfig.DrawRect(326,64+32*i,rect);
			SetRect(&rect,inp/10*24,0,(inp/10+1)*24,32);
			g_pTitleMaterial->imgKeyConfig.DrawRect(300,64+32*i,rect);
		}
		//Reset
		{
			rect.left = 0;
			rect.top = 32*5;
			rect.bottom = 32*(5+1);
			rect.right = 112;
			g_pTitleMaterial->imgConfig.DrawRect(50,64+32*7,rect,alpha(128+127*(config_select==7)));
		}
		//Quit
		{
			rect.left = 0;
			rect.top = 32*7;
			rect.bottom = 32*(7+1);
			rect.right = 80;
			g_pTitleMaterial->imgConfig.DrawRect(50,64+32*8,rect,alpha(128+127*(config_select==8)));
		}
		break;
	case 8: //Score
		SetRect(&rect,0,0,512,480);
		g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
		SetRect(&rect,256,0,384,480);
		g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

		//Easy
		SetRect(&rect,0,128,72,160);
		g_pTitleMaterial->imgStageMoji.DrawRect(100,150,rect);

		SetRect(&rect,72,128,180,160);
		g_pTitleMaterial->imgStageMoji.DrawRect(100,200,rect);

		SetRect(&rect,180,128,256,160);
		g_pTitleMaterial->imgStageMoji.DrawRect(100,250,rect);

		SetRect(&rect,0,160,120,192);
		g_pTitleMaterial->imgStageMoji.DrawRect(100,300,rect);

		for( int i = 0; i < 4; ++i ) {
			DrawNumber(250,150+50*i,g_pRecord->data.score[i].score,8,alpha(255),1);
		}
		break;
	case 9: //Spell Card
		{
			SetRect(&rect,0,0,512,480);
			g_pTitleMaterial->imgSelect.DrawRect(0,0,rect);
			SetRect(&rect,256,0,384,480);
			g_pTitleMaterial->imgRight.DrawRect(512,0,rect);

			//スペルカード合計
			SetRect(&rect,160,32,192,64);
			g_pTitleMaterial->imgStageMoji.DrawRect(480,40,rect,alpha(255),0.75);
			DrawNumber(400,40,spell_sum,3,alpha(255),0.75);
			DrawNumber(510,40,SPELL_NUM*4,3,alpha(255),0.75);

			//難易度表示
			RECT rectdiff[] = {
				{0,128,72,160},
				{72,128,184,160},
				{184,128,256,160},
				{0,160,112,192}};
			g_pTitleMaterial->imgStageMoji.DrawRect(60,70,rectdiff[spell_difficult],alpha(255),0.75);
			//スペルカード合計(難易度別)
			SetRect(&rect,160,32,192,64);
			g_pTitleMaterial->imgStageMoji.DrawRect(480,70,rect,alpha(255),0.75);
			DrawNumber(400,70,spell_sum_diff,3,alpha(255),0.75);
			DrawNumber(510,70,SPELL_NUM,3,alpha(255),0.75);

			for( int i = 0; i < SPELL_DISPLAY; ++i ) {
				int num = spell_select*SPELL_DISPLAY+i;
				int a = 255;
				if( num < SPELL_NUM ) {
					int success = g_pRecord->data.spell[num][spell_difficult].success;
					int challenge = g_pRecord->data.spell[num][spell_difficult].challenge;
					if(success == 0)
						a = 127;

					fontSpellName[i].DrawFlame(60,110+30*i,alpha(a),argb(a,0,0,0));
					SetRect(&rect,160,32,192,64);
					g_pTitleMaterial->imgStageMoji.DrawRect(480,100+30*i,rect,alpha(a),0.75);
					DrawNumber(400,100+30*i,success,3,alpha(a),0.75);
					DrawNumber(510,100+30*i,challenge,3,alpha(a),0.75);

				}
			}
		}
		break;
	case 10: //Other Result
		break;
	}
	return 1;
}
Example #15
0
File: App.cpp Project: edvorg/chair
void App::Draw() {
	SetProjection(fieldWidth, fieldHeight);

	SetTranslate(0, 0);
	progress.Draw();

	if (!progress.IsPaused()) {

		// background

		SetTranslate(0, 0);
		shaker.ApplyMatrix();

		drawTexture(texture, backPos, 0, 100, fieldHeight, 1.0f / 100, 1.0f);
		drawTexture(texture, backPos + 100, 0, 100, fieldHeight, 1.0f / 100, 1.0f);

		// debug data

		SetTranslate(25 - camPos, 0);
		shaker.ApplyMatrix();

		world.DrawDebugData();

		// platforms

		drawTexture(bottom,
					borderBodies[0]->GetPosition().x - 100,
					0,
					200,
					8,
					1.0f / fieldWidth * 3.0f,
					1.0f);
		drawTexture(top,
					borderBodies[1]->GetPosition().x - 100,
					fieldHeight - 13,
					200,
					13,
					1 / fieldWidth * 2.0f,
					1.0f);
		drawTexture(bottom,
					borderBodies[2]->GetPosition().x - 100,
					0,
					200,
					8,
					1.0f / fieldWidth * 3.0f,
					1.0f);
		drawTexture(top,
					borderBodies[3]->GetPosition().x - 100,
					fieldHeight - 13,
					200,
					13,
					1 / fieldWidth * 2.0f,
					1.0f);

		// creature

		drawCreature(playerBodiesPoints, b2Color(playerColorRState, playerColorGState, playerColorBState), 1, playerStatePoint);
		drawEyes(playerEyesBodiesPoints, playerBodiesPoints);

		// numbers

		SetTranslate(0, 0);
		shaker.ApplyMatrix();

		DrawNumber(false,
				   fieldWidth - 5.0f,
				   fieldHeight - 10.0f,
				   1,
				   1.5,
				   progress.GetLevel());
	}
}
Example #16
0
//  Find the points value of the point the cursor is over, uses radius and angle to calculate
void Player::GetPointsValue(int cursoractual[], int BGPos[]){
	
	int x = (cursoractual[0] + BGPos[0])-30*8;
	int y = (cursoractual[1] + BGPos[1])-30*8;
	int h = x*x+y*y;
	float angle = atan2(y,x) * 180 / M_PI;
	int basepoints = 0;
	int type = 0;
	p_targettype = 0;
	p_innersingle = false;
	
	int index = (angle+9)/18+11;
	
	if (h < sq_radii[0]) {
		basepoints = 50;
		type = 5;
		p_targettype = 4;
	} else if (h < sq_radii[1]) {
		basepoints = 25;
		type = 4;
		p_targettype = 1;
	} else if (h < sq_radii[2]) {
		type = 1;
		p_innersingle = true;
		p_targettype = 0;
	} else if (h < sq_radii[3]) {
		type = 3;
		p_targettype = 3;
	} else if (h < sq_radii[4]) {
		type = 1;
		p_targettype = 0;
	} else if (h < sq_radii[5]) {
		type = 2;
		p_targettype = 2;
	} else {
		basepoints = 0;
		type = 0;
		p_targettype = 5;
	}
	p_hit = basepoints;
	DrawText(20, 17, "          ", 25);
	if (type == 1 || type == 2 || type == 3) {
		basepoints = boardpointsextended[index];
		p_hit = basepoints * type;
		if (type == 1) {
			DrawText(20, 17, "Single", 25);
		} else if (type == 2) {
			DrawText(20, 17, "Double", 25);
		} else {
			DrawText(20, 17, "Treble", 25);
		}
		DrawNumber(27, 17, basepoints, 25);	
	} else if (type == 0) {
		DrawText(23, 17, "Miss", 25);
	} else if (type == 4) {
		DrawText(23, 17, "Bull", 25);
	} else {
		DrawText(20, 17, "BullsEye", 25);
	}
	
	if (p_colinmode) {
		p_target = p_hit;
	}
}
Example #17
0
//  Throw a single dart, handles both AI and Player controlled, if a player than enable cursor and wait for input
//  if computer then call target select functions and decide what to do with results by passing to DartLocationDecide()
void Player::TakeAShot(int cursoractual[], int cursorpos[],int BGPos[]){
	bool wait = true;
	oldkey[A_KEY] = true;

	if (p_ishuman == true) {		
		while (wait) {
			WaitVSync();
			UpdateObjects();
			HandleCursorMovement(cursoractual, cursorpos, BGPos);
			
			for (int i = 0; i < p_turnthrows; i++) {
				darts[i].UpdateDart(BGPos);			
			}
			
			if ((REG_P1 & KEY_A) == 0 && oldkey[A_KEY] == false) {
				GetPointsValue(cursoractual, BGPos);
				wait = false;
				oldkey[A_KEY] = true;
			}
			if ((REG_P1 & KEY_A) != 0) {
				oldkey[A_KEY] = false;
			}
		}
		if (p_colinmode) {
			Inaccuracy();
			DartLocationDecide();
			darts[p_turnthrows] = Dart(p_darthitloc[0], p_darthitloc[1], p_turnthrows+1);					
		} else {	
			darts[p_turnthrows] = Dart(cursoractual[0]+BGPos[0], cursoractual[1]+BGPos[1], p_turnthrows+1);	
		}
	} else {
		for (int animate = 0; animate < 10; animate++) {
			WaitVSync();
			UpdateObjects();
			for (int i = 0; i < p_turnthrows; i++) {
				darts[i].UpdateDart(BGPos);			
			}					
		}
		for (int i  = DELAY; i > 0; i--) {
			WaitVSync();
		}		
		TargetSelect(0);
		Inaccuracy();
		DartLocationDecide();
		BGPos[0] = p_darthitloc[0]-80;
		BGPos[1] = p_darthitloc[1]-80;
		
		REG_BG3HOFS = BGPos[0];
		REG_BG3VOFS = BGPos[1];	
		darts[p_turnthrows] = Dart(p_darthitloc[0], p_darthitloc[1], p_turnthrows+1);
	}
	if (CheckLegality(p_hit)) {
		p_points -= p_hit;	
		DrawText(20, 17, "          ", 25);
		if (p_targettype == 0) {
			DrawText(20, 17, "Single", 25);
			DrawNumber(27, 17, (p_hit), 25);
		} else if (p_targettype == 1) {
			DrawText(24, 17, "Bull", 25);
		} else if (p_targettype == 2) {
			DrawText(20, 17, "Double", 25);
			DrawNumber(27, 17, (p_hit/2), 25);
		} else if (p_targettype == 3) {
			DrawText(20, 17, "Treble", 25);
			DrawNumber(27, 17, (p_hit/3), 25);
		} else if (p_targettype == 4) {
			DrawText(21, 17, "BullsEye", 25);
		} else {
			DrawText(24, 17, "Miss", 25);
		}				
	} else {
		DrawText(20, 17, "  Illegal   ", 25);
	}

}
Example #18
0
void	RunKey( void )
{
	Sprite	*s;
	int			nac;
	int			sel_type=0;
	unsigned long	otype;

	switch( actcode )
	{
#ifdef KEY_TOPLEFT
	case KEY_TOPLEFT:
	case KEY_TOPRIGHT:
	case KEY_BOTTOMLEFT:
	case KEY_BOTTOMRIGHT:
#endif
	case RC_LEFT :
	case RC_RIGHT :
	case RC_UP :
	case RC_DOWN :
		HandleDirection ( actcode );
		break;
	case RC_RED :		// kill all lemmings
		if ( pause || (action!=2) || !in_level )
			break;
		SoundPlay( SND_OHNO );
		FBGetImage( 11*32+32, 384, 32, 48, svdimage[11] );
		FBDrawRect( 11*32+32, 384, 31, 47, RED );
		FBDrawRect( 11*32+33, 385, 29, 45, RED );
		killall=1;
		break;
	case RC_BLUE :		// PAUSE - GO
		if ( action!=2 )
			return;
		if ( pause == 1 )
			FBCopyImage( 10*32+32, 384, 32, 48, svdimage[10] );
		pause = pause ? 0 : 1;
		if ( pause )
		{
			FBGetImage( 10*32+32, 384, 32, 48, svdimage[10] );
			FBDrawRect( 10*32+32, 384, 31, 47, BLUE );
			FBDrawRect( 10*32+33, 385, 29, 45, BLUE );
		}
		break;
	case RC_1 :
	case RC_2 :
	case RC_3 :
	case RC_4 :
	case RC_5 :
	case RC_6 :
	case RC_7 :
	case RC_8 :	// select lemm-action
		if ( pause || !action || (action>2))
			break;
		nac=actcode-1;
		if ( afunc == actcode-1 )
			break;
		if ( !portfolio[ actcode-1 ] )
			break;
		FBGetImage( (nac+2)*32+32, 384, 32, 48, svdimage[nac+2] ); // save
		if ( afunc != -1 )
		{
			FBCopyImage( (afunc+2)*32+32, 384, 32, 48, svdimage[afunc+2] );
			DrawNumber( 106+afunc*32, 389, portfolio[afunc] );
		}
		FBDrawRect( (nac+2)*32+32, 384, 31, 47, YELLOW );
		FBDrawRect( (nac+2)*32+33, 385, 29, 45, YELLOW );
		afunc=nac;
		break;
	case RC_PLUS :
		if ( pause || (action!=2) )
			break;
		newspeed--;
		if ( newspeed < 1 )
			newspeed=1;
		else
		{
			DrawNumber( 74, 389, 100-newspeed );
		}
		break;
	case RC_MINUS :
		if ( pause || (action!=2) )
			break;
		newspeed++;
		if ( newspeed > minspeed )
			newspeed=minspeed;
		else
		{
			DrawNumber( 74, 389, 100-newspeed );
		}
		break;
	case RC_OK :
		if( !action )
		{
			action=1;
			s=deko[1];	// tor;
			s->anilocked=0;
			SoundPlay( SND_DOOR );
			break;
		}
		if (( action != 2 ) || pause || ( sel_sprite == -1 ) || !portfolio[afunc])
			break;
		s=lemm[ sel_sprite ];
		if ( !s )
			break;
		if ( afunc == 2 )	// EXPLODE
		{
			if ( !( s->type & TYP_EXPLODE ) )
			{
				s->type |= TYP_EXPLODE;
				s->counter1=0;
				portfolio[ afunc ]--;
				DrawNumber( 106+afunc*32, 389, portfolio[afunc] );
			}
		}
		else if ( afunc == 0 )	// CLIMB
		{
			if ( !( s->type & TYP_CLIMB ) )
			{
				s->type |= TYP_CLIMB;
				portfolio[ afunc ]--;
				DrawNumber( 106+afunc*32, 389, portfolio[afunc] );
			}
		}
		else
		{
			switch( afunc )
			{
			case 3 :
				sel_type = TYP_STOPPER;
				break;
			case 4 :
				sel_type = TYP_BUILDER;
				break;
			case 6 :
				sel_type = TYP_DIGDIAG;
				break;
			case 7 :
				sel_type = TYP_DIGDOWN;
				break;
			}
			otype=s->type & TYP_WORK;
			while( 1 )
			{
				if ( otype == sel_type )
				{
					if (( otype == TYP_BUILDER ) && ( s->counter2 > 11 ))
						break;
					sel_type = 0;
					break;
				}
				if ( !( otype & TYP_STOPPER ) && !( s->type & TYP_FALLEN ))
					break;
				sel_type = 0;
				break;
			}
			if ( sel_type )
			{
				otype = s->type;
				s->type = sel_type;
				portfolio[ afunc ]--;
				DrawNumber( 106+afunc*32, 389, portfolio[afunc] );
// erstmal die sprite-koordinaten wieder auf 0
				if (( otype & TYP_BUILDER ) && ( s->counter2 < 12 ))
				{
					s->y+=3;
				}
				else if (( otype & TYP_BUILDER ) && ( s->counter2 == 12 ))
				{
					s->y-=2;
				}
				else if ( otype & TYP_DIGDIAG )
				{
					s->y+=5;
					if ( !s->dir )
						s->x+=7;
				}
				else if ( otype & TYP_DIGDOWN )
				{
					s->y+=2;
				}
// sprite-koordinaten eventl. verschieben
				if ( sel_type == TYP_DIGDOWN )
				{
					s->y-=2;
					SpriteChangePic( s, 5 );	// lemming3
				}
				if ( sel_type == TYP_STOPPER )
				{
					s->counter1=0;
					SpriteChangePic( s, 4 );	// lemming2
					bgRect( s->x+(s->width/2), s->y, 1, s->height-2, 150 );
				}
				if ( sel_type == TYP_BUILDER )
				{
					s->counter1=0;
					s->counter2=0;
					s->y -= 3;	// 2
					SpriteChangePic( s, 31 );	// builder
					if ( s->dir )
					{
						s->x++;
						MirrorSprite( s );
					}
					else
						s->x--;
				}
				if ( sel_type == TYP_DIGDIAG )
				{
					s->counter1=0;
					s->counter2=0;
					s->y -= 5;
					SpriteChangePic( s, 33 );	// hacke
					if ( s->dir )
					{
						MirrorSprite( s );
					}
					else
						s->x-=7;
				}
			}
		}
		break;
	}
}
Example #19
0
void	InitLevel( void )
{
	int		i;
	char	text[64];

	in_level=0;
	pause=0;
	killall=0;
	action=0;
	lem_in=0;
	lem_run=0;
	afunc=-1;
	main_x=660;
	memset(deko,0,sizeof(deko));
	memset(bgImage,STEELBLUE,1600*160);
	deko[0]=CreateSprite(0,0,main_x+160,80);			// cursor
	deko[0]->anilocked=1;
	switch( level )
	{
	case 1 :
	case 4 :
	case 6 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,39);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,0,871,106);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,876,108);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,902,108);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		switch( level )
		{
		case 6 :
			portfolio[7]=2;
			portfolio[3]=2;
			portfolio[2]=2;
			break;
		case 1 :
			portfolio[7]=10;
#if 1
portfolio[6]=10;
portfolio[4]=10;
portfolio[3]=10;
portfolio[2]=10;
#endif
			break;
		case 4 :
			portfolio[2]=5;
			break;
		}
		haus_x=889;
		haus_y1=117;
		haus_y2=135;
		to_rescue=level==6?39:5;
		newspeed=level==6?1:50;
		lem_cnt=level==6?40:10;
		break;
	case 2 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,7);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,700,128);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,704,129);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,731,129);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[3]=4;
		haus_x=718;
		haus_y1=139;
		haus_y2=157;
		to_rescue=25;
		newspeed=50;
		lem_cnt=50;
		break;
	case 3 :
		/* deko */
		deko[1]=CreateSprite(1,0,726,23);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,1000,128);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,1004,129);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,1031,129);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[3]=2;
		portfolio[7]=2;
		haus_x=1018;
		haus_y1=139;
		haus_y2=157;
		to_rescue=50;
		newspeed=50;
		lem_cnt=50;
		break;
	case 5 :
		/* deko */
		deko[1]=CreateSprite(1,0,712,3);		// tor
		deko[1]->anilocked=1;
		deko[1]->backlocked=1;
		/* zielhaus */
		deko[2]=CreateSprite(7,1,1150,117);		// haus
		deko[2]->anilocked=1;
		deko[2]->backlocked=1;
		deko[3]=CreateSprite(2,0,1154,118);		// flamme
		deko[3]->backlocked=1;
		deko[4]=CreateSprite(2,3,1181,118);		// flamme
		deko[4]->backlocked=1;
		MirrorSprite( deko[4] );

		/* feuer */
		deko[5]=CreateSprite(9,0,849,39);		// feuer
		deko[6]=CreateSprite(9,0,979,39);		// feuer
		deko[7]=CreateSprite(9,0,880,66);		// feuer
		deko[8]=CreateSprite(9,0,880,107);		// feuer
		deko[9]=CreateSprite(9,0,979,131);		// feuer
		deko[10]=CreateSprite(9,0,1002,86);		// feuer

		/* setup */
		memset(lemm,0,sizeof(lemm));
		memset(portfolio,0,sizeof(portfolio));
		portfolio[2]=5;
		portfolio[3]=3;
		haus_x=1168;
		haus_y1=128;
		haus_y2=146;
		to_rescue=30;
		newspeed=50;
		lem_cnt=50;
		break;
	}
	minspeed=newspeed;
	DrawLevelIntoBg();
	/* copy level to screen */
	CopyBg2Screen( main_x, 0, 328, 160 );
	SpritesGetBackground();
	DrawSprites();
	/* Draw Menu-Item-Numbers */
	for( i=0; i<8; i++ )
		DrawNumber( 106+i*32, 389, portfolio[i] );

	DrawNumber( 42, 389, newspeed );
	DrawNumber( 74, 389, 100-newspeed );
	DrawInfo(3);
	/* show level info */
	FBFillRect( 60, 448, 200, 100, BLACK );
	sprintf(text,"Lemmings : %d  ",lem_cnt);
	FBDrawString(64,450,32,text,WHITE,0);
	sprintf(text,"%d%% to be saved  ",to_rescue*100/lem_cnt);
	FBDrawString(64,482,32,text,WHITE,0);
	sprintf(text,"Release Rate %d  ",100-newspeed);
	FBDrawString(64,514,32,text,WHITE,0);
	SoundPlay( SND_LETSGO );
}
Example #20
0
void CAccountLayer::draw()
{
    if (!visible_)
    {
        return;
    }

    __super::draw();

    CGameScene *pGameScene = (CGameScene *)parent();
    CClientKernel *pClientKernel = pGameScene->GetClientKernel();
    if ( !pClientKernel)
        return ;

    Point pt(position_absolute());
    Point ptDraw;
    std::ostringstream ostr;

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104;

        DrawNumber(ostr.str(), ptDraw);
    }

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i+4];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104+74;

        DrawNumber(ostr.str(), ptDraw);
    }

    for (int i=0; i<4; i++)
    {
        ostr.str("");
        ostr << m_CaptureFishs[i+8];

        ptDraw.x_ = pt.x_ + 136+i*180;
        ptDraw.y_ = pt.y_ +104+148;

        DrawNumber(ostr.str(), ptDraw);
    }


     WORD wMeChairID = pGameScene->GetMeChairID();

     if (wMeChairID != INVALID_CHAIR)
     {
         int nFishGold = pGameScene->m_layRoles[wMeChairID]->GetFishGold();
         ostr.str("");
         ostr << nFishGold; 
         ptDraw.x_ = pt.x_ + 296;
         ptDraw.y_ = pt.y_ + 310;
         DrawNumber(ostr.str(), ptDraw);

         LONG lCellScore = pGameScene->m_layBuyBulletLayer->GetCellScore();

         ostr.str("");
         ostr << nFishGold*lCellScore; 
         ptDraw.x_ = pt.x_ + 500;
         ptDraw.y_ = pt.y_ + 310;
         DrawNumber(ostr.str(), ptDraw);



         const tagUserData *pUserData = pClientKernel->GetMeUserInfo();

         if (pUserData)
         {
             ostr.str("");
             ostr << 0; 
             ptDraw.x_ = pt.x_ + 240;
             ptDraw.y_ = pt.y_ + 352;
             DrawNumber(ostr.str(), ptDraw);

             ostr.str("");
             ostr << pUserData->lScore; 
             ptDraw.x_ = pt.x_ + 580;
             ptDraw.y_ = pt.y_ + 352;
             DrawNumber(ostr.str(), ptDraw);
         }



     }

     DWORD dwTime = (DWORD)time(NULL) - m_dwStartTime;

     if (dwTime >= 20)
     {
         ShowWidnow(false);
     }
     else
     {
         ostr.str("");
         ostr << 20-dwTime; 

         ptDraw.x_ = pt.x_ + 696;
         ptDraw.y_ = pt.y_ + 38;

         DrawTimer(ostr.str(), ptDraw);
     }
}
Example #21
0
int main (void)
{
   XGpio dip;
   int dip_check;


   static XPs2 Ps2Inst;
   XPs2_Config *ConfigPtr;
   u32 StatusReg;
   u32 BytesReceived;
   u8 RxBuffer;
   int key_count=0;
   int i;

   status=PVP;
   int x_cur=7, y_cur=7, x_pos=0, y_pos=0;

   XGpio_Initialize(&dip, XPAR_DIP_SWITCHES_8BITS_DEVICE_ID);
   XGpio_SetDataDirection(&dip, 1, 0xffffffff);

   ConfigPtr = XPs2_LookupConfig(XPAR_XPS_PS2_0_0_DEVICE_ID);
   XPs2_CfgInitialize(&Ps2Inst, ConfigPtr, ConfigPtr->BaseAddress);

   XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR,
   		                 XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR,
                         (XInterruptHandler) timer_int_handler,
                         (void *)XPAR_XPS_TIMER_0_BASEADDR);

   XIntc_MasterEnable(XPAR_XPS_INTC_0_BASEADDR);
   XIntc_EnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1);

   XTmrCtr_SetLoadReg(XPAR_XPS_TIMER_0_BASEADDR, 0, 333333);

   XTmrCtr_SetControlStatusReg(XPAR_XPS_TIMER_0_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK );

   XIntc_EnableIntr(XPAR_XPS_TIMER_0_BASEADDR, XPAR_XPS_TIMER_0_INTERRUPT_MASK);

   XTmrCtr_SetControlStatusReg(XPAR_XPS_TIMER_0_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK |
     						XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);

   microblaze_enable_interrupts();

   InitializeGame(x_cur, y_cur);status=PVP;

   xil_printf("-- Game Starts! --\r\n");
   xil_printf("\r\nHuman Player's turn!\r\n");

   int vga_input;
   vga_input=(0<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(1<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(2<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(3<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(4<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(5<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(6<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(7<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(8<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(0<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(1<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(2<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(3<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(4<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(5<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(6<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(7<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(8<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

     vga_input=(0<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(1<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(2<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(3<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(4<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(5<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(6<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(7<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(8<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(9<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(0<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(1<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(2<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(3<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(4<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(5<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(6<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(7<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(8<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(9<<24)+(1<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(2<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(3<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(4<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(5<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(6<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(7<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(9<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(10<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(9<<24)+(11<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(12<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(13<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(14<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(15<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(16<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(18<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(19<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(20<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(9<<24)+(21<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(22<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(23<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(24<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(25<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(26<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(27<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(28<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(29<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(30<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);


   while (1)
   {
	  if (turn==HUMAN_PLAYER || (turn==COMPUTER_PLAYER && status==PVP)) {
		  do {
			  if (turn==COMPUTER_PLAYER && status==PVC)
			  	  break;
		      dip_check=XGpio_DiscreteRead(&dip, 1);
	          StatusReg = XPs2_GetStatus(&Ps2Inst);
	      }while((StatusReg & XPS2_STATUS_RX_FULL) == 0);
	      BytesReceived = XPs2_Recv(&Ps2Inst, &RxBuffer, 1);
	      key_count=(key_count+1)%3;
	      if (key_count==0) {
	    	  if (RxBuffer==0x21&& win_flag==0) {
	    		  DrawNumber(level,3,2,EMPTY);

	    		  if(level==1)
	    			  level=2;
	    		  else
	    			  level=1;

	    		  if(status==PVC )
	    		  DrawNumber(level,3,2,0);
	    		  else if(status==CVP)
			      DrawNumber(level,3,2,1);
	    		  else
	    		  DrawNumber(level,3,2,EMPTY);

	    	  }
		      if (RxBuffer==0x1D && win_flag==0) {
			      EraseCursor(x_cur, y_cur);
		          if (y_cur<=0)
		    	      y_cur=14;
		          else
		    	      y_cur--;
		          DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x1B && win_flag==0) {
		  	      EraseCursor(x_cur, y_cur);
		  	      if (y_cur>=14)
		  	          y_cur=0;
		  	      else
		  	          y_cur++;
		  	      DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x1C && win_flag==0) {
		  	      EraseCursor(x_cur, y_cur);
		  	      if (x_cur<=0)
		  	          x_cur=14;
		  	      else
		  		      x_cur--;
		  	      DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x23 && win_flag==0) {
		  	      EraseCursor(x_cur, y_cur);
		  	      if (x_cur>=14)
		  	          x_cur=0;
		  	      else
		  		      x_cur++;
		  	      DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x5A && win_flag==0) {
		    	  DrawBack(3,1119,EMPTY);
			      if (board_state[x_cur][y_cur]==EMPTY) {

			  	      if(status==CVP)
				      DrawChess(x_cur, y_cur, 1-turn);
			  	      else
			  	      DrawChess(x_cur, y_cur, turn);

				      board_state[x_cur][y_cur]=turn;
				      board_record[BackTimes].x=x_cur;
				      board_record[BackTimes].y=y_cur;
				      BackTimes++;
				      count=0;
				      time0=0;
				      if (turn==COMPUTER_PLAYER)
				    	  step_flag=1;
				      if (CheckWin(x_cur,y_cur,turn)==1) {
					      xil_printf("\r\nHuman Player wins!\r\n");
					      win_flag=1;
					      DrawWinning(0, 1, EMPTY);
					      if(status==CVP)
						      DrawWinning(0, 1, 1-turn);
					      else
					          DrawWinning(0, 1, turn);
				      }
				      if (CheckBan(x_cur,y_cur,turn)==1){
				    	  xil_printf("\r\nComputer Player wins!\r\n");
				    	  win_flag=1;
				    	  DrawWinning(0, 1, EMPTY);
					      if(status==CVP)
						      DrawWinning(0, 1, turn);
					      else
					          DrawWinning(0, 1, 1-turn);
				      }
				      else {
				    	  if (turn==HUMAN_PLAYER)
				    		  turn=COMPUTER_PLAYER;
				    	  else
				    		  turn=HUMAN_PLAYER;
				          xil_printf("\r\nComputer Player's turn!\r\n");
				      }
			      }
			  }
		      if (RxBuffer==0x29 && turn==HUMAN_PLAYER && win_flag==0) {
		    	  count=0;time0=0;

		    	  if (status==PVP) {
			    	  x_cur=7;
			    	  y_cur=7;
			    	  for (i=0; i<256; i++) {
			    	  		board_record[i].x=0;
			    	  	    board_record[i].y=0;
			    	  			  }
				      InitializeGame(x_cur, y_cur);status=PVP;
		    		  DrawStatus(1, 21, EMPTY,status);
		    		  status=PVC;
		    		  DrawNumber(level,3,2,0);
		    		  DrawStatus(1, 21, COMPUTER_PLAYER,status);
		    	  }
		    	  else if(status==PVC) {
			    	  x_cur=7;
			    	  y_cur=7;
			    	  for (i=0; i<256; i++) {
			    	  		board_record[i].x=0;
			    	  	    board_record[i].y=0;
			    	  			  }
				      InitializeGame(x_cur, y_cur);status=PVP;
		    		  DrawStatus(1, 21, EMPTY,status);
		    		  status=CVP;
		    		  DrawNumber(level,3,2,1);
		    		  DrawStatus(1, 21, COMPUTER_PLAYER,status);
		    		  turn=COMPUTER_PLAYER;
		    	  }
		    	  else if(status==CVP) {
			    	  x_cur=7;
			    	  y_cur=7;
			    	  for (i=0; i<256; i++) {
			    	  		board_record[i].x=0;
			    	  	    board_record[i].y=0;
			    	  			  }
				      InitializeGame(x_cur, y_cur);status=PVP;
		    		  DrawStatus(1, 21, EMPTY,status);
		    		  status=PVP;
		    		  DrawStatus(1, 21, COMPUTER_PLAYER,status);
		    	  }
		      }
		      if (RxBuffer==0x76) {
		    	  x_cur=7;
		    	  y_cur=7;
		    	  for (i=0; i<256; i++) {
		    	  		board_record[i].x=0;
		    	  	    board_record[i].y=0;
		    	  			  }
			      InitializeGame(x_cur, y_cur);status=PVP;
		      }
		      if (RxBuffer==0x2D) {
		      	  if(BackTimes>0){
		      		BackTimes--;
		      	  	x_cur=board_record[BackTimes].x;
		      	  	y_cur=board_record[BackTimes].y;
		      	  	board_state[x_cur][y_cur]=EMPTY;
		      	  	DrawChess(x_cur,y_cur,EMPTY);
		      	  	turn=1-turn;
		      	  	if(status==PVC)
		      	  	{
		      	  	BackTimes--;
		      	  	x_cur=board_record[BackTimes].x;
		      	  	y_cur=board_record[BackTimes].y;
		      	  	board_state[x_cur][y_cur]=EMPTY;
		      	  	DrawChess(x_cur,y_cur,EMPTY);
		      	  	turn=HUMAN_PLAYER;
		      	  	}
		      	    DrawBack(3,1119,turn);
		      	  					      }
		      	  				  		  }
	      }
	  }

	  if (turn==COMPUTER_PLAYER && (status==PVC ||status==CVP )&& win_flag==0) {
	      if (step_flag==0) {
	  		  if (x_cur-1<0)
	  			  x_pos=x_cur+1;
	  		  else
	  			  x_pos=x_cur-1;
	  		      y_pos=y_cur;
	  		      step_flag=1;
	      }
	  	  else {
	  		  if(level==2||level==3){
	  		  EvaluateComputerMove(board_state, 0, MIN_INFINITY, MAX_INFINITY, 0, 0);
	  		  x_pos=maxMoveX;
	  		  y_pos=maxMoveY;
	  		  xil_printf("\r\n computer \r\n");}
	  		  else
	  		  {
		  	  everyScore(Computer);
		  	  current_pos=best(Computer);
	  		  x_pos=current_pos.y;
	  		  y_pos=current_pos.x;
	  		  xil_printf("\r\n computer \r\n");
	  		  }

	  	  }
  	      xil_printf("\r\n%x, %x\r\n", x_pos, y_pos);

  	      if(status==CVP)
	      DrawChess(x_pos, y_pos, 1-turn);
  	      else
  	      DrawChess(x_pos, y_pos, turn);


	  	  board_state[x_pos][y_pos]=COMPUTER_PLAYER;
	  	  board_record[BackTimes].x=x_pos;
  		  board_record[BackTimes].y=y_pos;
  		  BackTimes++;

	  	  count=0;
	  	  time0=0;
	      if (CheckWin(x_pos, y_pos, turn)) {
	  	      xil_printf("\r\nComputer Player wins!\r\n");
	  	      win_flag=1;
	  	      DrawWinning(0,1, EMPTY);
	  	      if(status==CVP)
	  	    	  DrawWinning(0,1, 1-turn);
	  	      else
	  	    	  DrawWinning(0,1, turn);
	  	      turn=HUMAN_PLAYER;
	  	  }
	      else {
	    	  turn=HUMAN_PLAYER;
	    	  xil_printf("\r\nHuman Player's turn!\r\n");
	      }
	  }
   }
   return 0;
}
Example #22
0
/*
 * This routine draws grid line labels in engineering notation,
 * the grid lines themselves,  and unit labels on the axes.
 */
int DrawGridAndAxis(char *w, GraphWin * wi)
{
    int startX;
    int Yspot, Xspot;
    double Xincr, Yincr, Xstart, Ystart, Yindex, Xindex;
    XSegment segs[2];
    double initGrid(), stepGrid();
    int tickFlag = FALSE;
    int logXFlag = wi->logx;
    int logYFlag = wi->logy;
    char *XUnitText = wi->XUnitText;
    char *YUnitText = wi->YUnitText;
    XSegment bb[4];

    /*
     * With the powers computed,  we can draw the axis labels.
     */
    Yspot = wi->dev_info.bdr_pad * 2 + wi->dev_info.title_height;
    wi->dev_info.xg_text(w,
			 wi->dev_info.bdr_pad, Yspot, YUnitText,
			 T_UPPERLEFT, T_AXIS);

    startX = wi->dev_info.area_w - wi->dev_info.bdr_pad;
    wi->dev_info.xg_text(w,
			 startX, wi->XOppY, XUnitText, T_RIGHT, T_AXIS);

    /*
     * First,  the grid line labels
     */
    Yincr = (wi->dev_info.axis_pad + wi->dev_info.axis_height) * wi->YUnitsPerPixel;
    Ystart = initGrid(wi->UsrOrgY, Yincr, logYFlag);
    for (Yindex = Ystart;  Yindex < wi->UsrOppY;  Yindex = stepGrid()) {
	Yspot = SCREENY(wi, Yindex);
	/* Write the axis label */
	if ( !logYFlag && ( fabs(Yindex/Yincr) < 1.0e-3 ) )
	    DrawNumber(w, wi, 0.0, wi->dev_info.bdr_pad +
			     (8 * wi->dev_info.axis_width),
			     Yspot, T_RIGHT, logYFlag);
	else
	    if (wi->xg_yscl < 0.0)
		DrawNumber(w, wi, -Yindex, wi->dev_info.bdr_pad +
			     (8 * wi->dev_info.axis_width),
			     Yspot, T_RIGHT, logYFlag);
	    else
		DrawNumber(w, wi, Yindex, wi->dev_info.bdr_pad +
			     (8 * wi->dev_info.axis_width),
			     Yspot, T_RIGHT, logYFlag);
    }

    Xincr = (wi->dev_info.axis_pad + (wi->dev_info.axis_width * 7)) * wi->XUnitsPerPixel;
    Xstart = initGrid(wi->UsrOrgX, Xincr, logXFlag);
    for (Xindex = Xstart;  Xindex < wi->UsrOppX;  Xindex = stepGrid()) {
	Xspot = SCREENX(wi, Xindex);
	/* Write the axis label */
	if ( !logXFlag && ( fabs(Xindex/Xincr) < ZERO_THRES ) )
	    DrawNumber(w, wi, 0.0, Xspot,
			     wi->dev_info.area_h - wi->dev_info.bdr_pad,
			     T_BOTTOM, logXFlag);
	else
	    if (wi->xg_xscl < 0.0)
		DrawNumber(w, wi, -Xindex, Xspot,
			     wi->dev_info.area_h - wi->dev_info.bdr_pad,
			     T_BOTTOM, logXFlag);
	    else
		DrawNumber(w, wi, Xindex, Xspot,
			     wi->dev_info.area_h - wi->dev_info.bdr_pad,
			     T_BOTTOM, logXFlag);
    }

    /*
     * Now,  the grid lines or tick marks
     */
    Yincr = (wi->dev_info.axis_pad + wi->dev_info.axis_height) * wi->YUnitsPerPixel;
    Ystart = initGrid(wi->UsrOrgY, Yincr, logYFlag);
    for (Yindex = Ystart;  Yindex < wi->UsrOppY;  Yindex = stepGrid()) {
	Yspot = SCREENY(wi, Yindex);
	/* Draw the grid line or tick mark */
	if (tickFlag) {
	    segs[0].x1 = wi->XOrgX;
	    segs[0].x2 = wi->XOrgX + wi->dev_info.tick_len;
	    segs[1].x1 = wi->XOppX - wi->dev_info.tick_len;
	    segs[1].x2 = wi->XOppX;
	    segs[0].y1 = segs[0].y2 = segs[1].y1 = segs[1].y2 = Yspot;
	} else {
	    segs[0].x1 = wi->XOrgX;  segs[0].x2 = wi->XOppX;
	    segs[0].y1 = segs[0].y2 = Yspot;
	}
	if ((fabs(Yindex) < ZERO_THRES) && !logYFlag) {
	    wi->dev_info.xg_seg(w, 1, segs, 0, L_ZERO, 0, 0);
	    if (tickFlag) {
		wi->dev_info.xg_seg(w, 1, &(segs[1]), 0, L_ZERO, 0, 0);
	    }
	} else {
	    wi->dev_info.xg_seg(w, 1, segs, 0, L_AXIS, 0, 0);
	    if (tickFlag) {
		wi->dev_info.xg_seg(w, 1, &(segs[1]), 0, L_AXIS, 0, 0);
	    }
	}
    }

    Xincr = (wi->dev_info.axis_pad + (wi->dev_info.axis_width * 7)) * wi->XUnitsPerPixel;
    Xstart = initGrid(wi->UsrOrgX, Xincr, logXFlag);
    for (Xindex = Xstart;  Xindex < wi->UsrOppX;  Xindex = stepGrid()) {
	Xspot = SCREENX(wi, Xindex);
	/* Draw the grid line or tick marks */
	if (tickFlag) {
	    segs[0].x1 = segs[0].x2 = segs[1].x1 = segs[1].x2 = Xspot;
	    segs[0].y1 = wi->XOrgY;
	    segs[0].y2 = wi->XOrgY + wi->dev_info.tick_len;
	    segs[1].y1 = wi->XOppY - wi->dev_info.tick_len;
	    segs[1].y2 = wi->XOppY;
	} else {
	    segs[0].x1 = segs[0].x2 = Xspot;
	    segs[0].y1 = wi->XOrgY; segs[0].y2 = wi->XOppY;
	}
	if ((fabs(Xindex) < ZERO_THRES) && !logXFlag) {
	    wi->dev_info.xg_seg(w, 1, segs, 0, L_ZERO, 0, 0);
	    if (tickFlag) {
		wi->dev_info.xg_seg(w, 1, &(segs[1]), 0, L_ZERO, 0, 0);
	    }
	} else {
	    wi->dev_info.xg_seg(w, 1, segs, 0, L_AXIS, 0, 0);
	    if (tickFlag) {
		wi->dev_info.xg_seg(w, 1, &(segs[1]), 0, L_AXIS, 0, 0);
	    }
	}
    }

    /* Draw bounding box */
    bb[0].x1 = bb[0].x2 = bb[1].x1 = bb[3].x2 = wi->XOrgX;
    bb[0].y1 = bb[2].y2 = bb[3].y1 = bb[3].y2 = wi->XOrgY;
    bb[1].x2 = bb[2].x1 = bb[2].x2 = bb[3].x1 = wi->XOppX;
    bb[0].y2 = bb[1].y1 = bb[1].y2 = bb[2].y1 = wi->XOppY;
    wi->dev_info.xg_seg(w, 4, bb, 0, L_AXIS, 0, 0);
}
Example #23
0
/*****************************************************************************
 * Draw: creates and returns the bar graph image
 *****************************************************************************/
static void Draw(BarGraph_t *b)
{
    int nbChannels = b->nbChannels;
    int scale      = b->scale;
    int barWidth   = b->barWidth;

    int w = 40;
    if (nbChannels > 0)
        w = 2 * nbChannels * barWidth + 30;
    int h = scale + 30;

    int level[6];
    for (int i = 0; i < 6; i++)
        level[i] = iec_scale(-(i+1) * 10) * scale + 20;

    if (b->p_pic)
        picture_Release(b->p_pic);
    b->p_pic = picture_New(VLC_FOURCC('Y','U','V','A'), w, h, 1, 1);
    if (!b->p_pic)
        return;
    picture_t *p_pic = b->p_pic;
    plane_t *p = p_pic->p;

    for (int i = 0 ; i < p_pic->i_planes ; i++)
        memset(p[i].p_pixels, 0x00, p[i].i_visible_lines * p[i].i_pitch);

    Draw2VLines(p, scale, 20, black);
    Draw2VLines(p, scale, 22, white);

    static const uint8_t pixmap[6][5] = {
        { 0x17, 0x15, 0x15, 0x15, 0x17 },
        { 0x77, 0x45, 0x75, 0x15, 0x77 },
        { 0x77, 0x15, 0x75, 0x15, 0x77 },
        { 0x17, 0x15, 0x75, 0x55, 0x57 },
        { 0x77, 0x15, 0x75, 0x45, 0x77 },
        { 0x77, 0x55, 0x75, 0x45, 0x77 },
    };

    for (int i = 0; i < 6; i++) {
        DrawHLines(p, h - 1 - level[i] - 1, 24, white, 1, 3);
        DrawHLines(p, h - 1 - level[i],     24, black, 2, 3);
        DrawNumber(p, h, pixmap[i], level[i]);
    }

    int minus8  = iec_scale(- 8) * scale + 20;
    int minus18 = iec_scale(-18) * scale + 20;
    int *i_values  = b->i_values;
    const uint8_t *indicator_color = b->alarm ? bright_red : black;

    for (int i = 0; i < nbChannels; i++) {
        int pi = 30 + i * (5 + barWidth);

        DrawHLines(p, h - 20 - 1, pi, indicator_color, 8, barWidth);

        for (int line = 20; line < i_values[i] + 20; line++) {
            if (line < minus18)
                DrawHLines(p, h - line - 1, pi, bright_green, 1, barWidth);
            else if (line < minus8)
                DrawHLines(p, h - line - 1, pi, bright_yellow, 1, barWidth);
            else
                DrawHLines(p, h - line - 1, pi, bright_red, 1, barWidth);
        }

        for (int line = i_values[i] + 20; line < scale + 20; line++) {
            if (line < minus18)
                DrawHLines(p, h - line - 1, pi, green, 1, barWidth);
            else if (line < minus8)
                DrawHLines(p, h - line - 1, pi, yellow, 1, barWidth);
            else
                DrawHLines(p, h - line - 1, pi, red, 1, barWidth);
        }
    }
}
Example #24
0
//描画
int CSystem::Draw()
{
	int i;
	RECT rect;

	//ステージリザルト
	if( state == SYSTEM_RESULT ){
		switch( result_mode ) {
		case 0:
			DrawResult(200,100*(RESULT_COUNT-result_count),alpha(255));
			break;
		case 1:
			DrawResult(200,0,alpha(255));
			break;
		case 2:
			DrawResult(200,100*result_count,alpha(255));
			break;
		}
	}

	//システム背景
	if( draw_system ) {
		//上
		SetRect(&rect,0,0,256,48);
		imgSystem1.DrawRect(0,0,rect);

		SetRect(&rect,0,48,256,96);
		imgSystem1.DrawRect(256,0,rect);
		
		SetRect(&rect,0,96,128,144);
		imgSystem1.DrawRect(512,0,rect);

		//下
		SetRect(&rect,0,144,256,176);
		imgSystem1.DrawRect(0,448,rect);

		SetRect(&rect,0,176,256,208);
		imgSystem1.DrawRect(256,448,rect);

		SetRect(&rect,128,96,256,144);
		imgSystem1.DrawRect(512,448,rect);

		//左
		SetRect(&rect,0,0,24,256);
		imgSystem2.DrawRect(0,48,rect);

		SetRect(&rect,24,0,48,144);
		imgSystem2.DrawRect(0,304,rect);

		//右
		SetRect(&rect,48,0,88,256);
		imgSystem2.DrawRect(600,48,rect);

		SetRect(&rect,88,0,128,144);
		imgSystem2.DrawRect(600,304,rect);

		//ライフ
		for(i=0;i<life;++i){
			imgLife.Draw(93+i*24,7,alpha(255),1,(double)count/36*2);
		}
		//ボム
		for(i=0;i<bomb;++i){
			imgBomb.Draw(93+i*24,23,alpha(255),1.0+0.1*sin((double)count/36*10));
		}

		//魔法陣
		Sun3D.SetBlendingType(BLEND_ADD);
		imgMaho.Draw(414,440,alpha(255),0.8,(double)count/36);
		Sun3D.SetBlendingType(BLEND_NORMAL);

		//難易度
		SetRect(&rect,0,16+16*g_pGame->diff,88,32+16*g_pGame->diff);
		imgMoji.DrawRect(50,454,rect);

		//数値
		DrawNumber(480,7,score,8);
		DrawNumber(480,23,hiscore,8);
		if( power < 1000 ) {
			DrawNumber(340,7,power,3);
		}
		else {
			SetRect(&rect,208,0,248,16);
			imgMoji.DrawRect(340,7,rect);
		}
		DrawNumber(340,23,graze,3);

		//FPS
		DrawNumber(360,454,SunApp.m_obfps,2);

		//弾数
		DrawNumber(240,454,g_lTama.GetSize(),3);
		if( g_lTama.GetSize() > bullet )
			bullet = g_lTama.GetSize();

		//フルパワー
		if( fullpower_count > 0 ) {
			SetRect(&rect,0,72,190,96);
			imgMoji2.DrawRect(240,80,rect);
		}
		//スペルカードボーナス
		if( spellbonus_count > 0 ) {
			SetRect(&rect,0,96,120,120);
			imgMoji2.DrawRect(180,100,rect);
			if( spellbonus > 0 ) {
				SetRect(&rect,0,120,72,144);
				imgMoji2.DrawRect(320,100,rect,alpha(255));
				DrawNumber( 550,100,spellbonus,0,xrgb(255,255,255));
			}
			else {
				SetRect(&rect,72,120,144,144);
				imgMoji2.DrawRect(320,100,rect,alpha(255));
			}
		}
	}
	switch(state) {
	case SYSTEM_PAUSE:	//ポーズ中
		{
			SunEffectRect effect;
			SetRect(&effect.m_rect,GAME_LEFT,GAME_TOP,GAME_RIGHT,GAME_BOTTOM);
			effect.m_color = argb(200,0,0,0);
			effect.Draw();

			SetRect(&rect,0,128,96,160);
			imgMoji.DrawRect(250,130,rect);

			SetRect(&rect,0,160,216,191);
			imgMoji.DrawRect(200,200,rect,alpha(128+127*(pause_select==0)));

			SetRect(&rect,0,192,168,224);
			imgMoji.DrawRect(220,250,rect,alpha(128+127*(pause_select==1)));

			//リプレイモードでは「最初からやり直す」はなし
			if( g_pTitle->title_select != 3 ) {
				SetRect(&rect,0,224,254,255);
				imgMoji.DrawRect(200,300,rect,alpha(128+127*(pause_select==2)));
			}
		}
		break;
	case SYSTEM_GAMEOVER://ゲームオーバー
		{
			SunEffectRect effect;
			SetRect(&effect.m_rect,GAME_LEFT,GAME_TOP,GAME_RIGHT,GAME_BOTTOM);
			effect.m_color = argb(200,0,0,0);
			effect.Draw();

			SetRect(&rect,0,0,256,24);
			imgMoji2.DrawRect(200,130,rect);

			SetRect(&rect,0,24,216,48);
			imgMoji2.DrawRect(220,200,rect,alpha(128+127*(gameover_select==0)));

			SetRect(&rect,0,48,200,72);
			imgMoji2.DrawRect(220,250,rect,alpha(128+127*(gameover_select==1)));

			SetRect(&rect,144,120,224,144);
			imgMoji2.DrawRect(420,300,rect);
			DrawNumber(420+40,303,continue_rest,1);
		}
		break;
	case SYSTEM_REPLAY://リプレイ保存
		{
			SunEffectRect effect;
			SetRect(&effect.m_rect,GAME_LEFT,GAME_TOP,GAME_RIGHT,GAME_BOTTOM);
			effect.m_color = argb(200,0,0,0);
			effect.Draw();

			SetRect(&rect,0,144,256,168);
			imgMoji2.DrawRect(200,130,rect);

			if( continue_dirty == 0 ) {
				SetRect(&rect,120,96,200,120);
				imgMoji2.DrawRect(220,200,rect,alpha(128+127*(replay_select==0)));

				SetRect(&rect,200,96,256,120);
				imgMoji2.DrawRect(220,250,rect,alpha(128+127*(replay_select==1)));
			}else{
				SetRect(&rect,0,168,256,216);
				imgMoji2.DrawRect(220,200,rect);
			}
		}
		break;
	case SYSTEM_RESUME://ゲーム再開中
		{
			SunEffectRect effect;
			SetRect(&effect.m_rect,GAME_LEFT,GAME_TOP,GAME_RIGHT,GAME_BOTTOM);
			effect.m_color = argb(200,0,0,0);
			effect.Draw();
		}
		break;
	}
	return 1;
}