/*
 * The callback function when a redraw has been requested
 */
void DisplayFunc()
{
	// Create the screen for both colour and depth values
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// The modelview matrix is pushed before drawing the scene
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	// Set up the trackball transformation
	float rotmatrix[4][4];
	build_rotmatrix(rotmatrix, quat);
	glMultMatrixf(&rotmatrix[0][0]);

	// Draw the scene from the display list
	if (current_display == DISPLAY_TEAPOT)
		glCallList(teapot_list);
	else {


		/*
		 *
		 * Draw your hierarchical tin robot model here
		 *
		 */

		glColor3f(0.0, 0.0, 1.0);
		DrawBox(400, 400, 400);


	}

	glPopMatrix();

	// Redraw the screen by swapping the buffer
	glutSwapBuffers();
}
Exemple #2
0
Scene* Menu::Update(){
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);
	DrawBox(0, 0, MainLoop::WINDOW_WIDTH, MainLoop::WINDOW_HEIGHT, GetColor(0, 0, 0), TRUE);
	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
	
	int menuLeft = MainLoop::WINDOW_WIDTH / 2 - GetDrawStringWidth("[X-KEY]:START", strlen("[X-KEY]:START")) / 2;

	DrawFormatStringToHandle(menuLeft, MainLoop::WINDOW_HEIGHT / 2 - 50, GetColor(255, 255, 255), mFontHandle, "[Z-KEY]:RESUME");
	DrawFormatStringToHandle(menuLeft, MainLoop::WINDOW_HEIGHT / 2, GetColor(255, 255, 255), mFontHandle, "[X-KEY]:RESTART");
	DrawFormatStringToHandle(menuLeft, MainLoop::WINDOW_HEIGHT / 2 + 50, GetColor(255, 255, 255), mFontHandle, "[C-KEY]:TITLE");

	//シーケンス処理
	Scene* next = this;
	if (CheckHitKey(KEY_INPUT_Z) != 0){
		next = new Play(mParent);
	}
	else if (CheckHitKey(KEY_INPUT_X) != 0){
		next = new OnePlayGame();
	}
	else if (CheckHitKey(KEY_INPUT_C) != 0){
		next = new Title();
	}
	return next;
}
Exemple #3
0
Scene* SceneTitleInit::Update()
{
	int t;
	switch (state) {
	case 0:
		if (Bright::Instance()->ChangeBright(255, 30)) ++state;
		break;
	case 1: // データロード
		t = GetNowCount();
		Image::Instance()->Init("data/image/image.csv");
		Sound::Instance()->Init();
		//ショットデータ読み込み
		PlayerBullet::Load();
		//セーブデータ読み込み
		Save::Instance()->LoadSaveData();
		//フォントデータ読み込み
		ChangeFont("MS ゴシック");
		SetFontThickness(3);
		SetFontSize(16);
		ChangeFontType(1);
		fonts.push_back(std::make_shared<Font>("梅PゴシックC5", 24, 4, "data/font/ume-pgc5.ttf"));
		fonts.push_back(std::make_shared<Font>("梅PゴシックC5", 16, 3, "data/font/ume-pgc5.ttf", DX_FONTTYPE_ANTIALIASING_EDGE));
		//ロードにかかった時間
		t = GetNowCount() - t;
		// ロードが1000ms以下なら1000msまで待機
		if (t < 1000) Sleep(1000 - t);
		++state;
		break;
	case 2:
		if (Bright::Instance()->ChangeBright(0, 30)) return new SceneTitle();
	}
	DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0xffffff, TRUE);
	DrawGraph(60, 40, images[0], TRUE);

	return this;
}
//--------------------------------------------------------------------------
//
//  Client window procedure.
//
// --------------------------------------------------------------------------
MRESULT EXPENTRY ClientWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{

   switch (msg)
   {

     // When the left mouse button is clicked, run the sample functions.

     case WM_BUTTON1DOWN:
     {
       DrawBox( hwnd );
       DrawTransformedBox( hwnd );
       RotateBox( hwnd );
       DrawShearedBox( hwnd );
     }
     break;

     case WM_PAINT:
     {
       HPS   hpsPaint ;
       RECTL rectl;

       hpsPaint = WinBeginPaint( hwnd, (HPS)0, &rectl );

       WinFillRect( hpsPaint, &rectl, SYSCLR_WINDOW );

       WinEndPaint( hpsPaint );
     }
     break;

     default:
     {
       return( WinDefWindowProc( hwnd, msg, mp1, mp2 )) ;
     }
   }
}
Exemple #5
0
void CShop::Draw()
{
	// This draws the first menu to the player to have them select if they
	// want to buy or sell items.  First, draw menu and it's buy/sell buttons
	DrawBox(kShopPromptWidth, kShopPromptHeight, kMenuX, kMenuY);

	DrawString("Buy", 3, kMenuX + 3, kMenuY + 2, NULL,  ShowBuyMenu);
	DrawString("Sell", 4, kMenuX + 12, kMenuY + 2, NULL,  ShowSellMenu);

	// Loop until the user escapes or clicks on one of the buttons
	while(!EscapePressed() && !ChoiceMade())
	{
		HandleInput();
	}

	// Reset the flag that says we hit escape and redraw the map
	ResetEscapeFlag();
	g_Map.SetDrawFlag(true);
	g_Map.Draw();

	// If there was a button clicked, let's go to it's associated function
	if(ChoiceMade())
		ChoiceMade()->m_function();
}
void disp_frame()
{
	static int draw_x = 0;
	static unsigned int e = GetNowCount();
	int y, cell_x, cell_y;
	int r,g,b;
	char key[256];	// 入力状態を格納する
	

	cell_x = W_CELL*draw_x;
	for (y=0; y<H_SIZE; y++)
	{
		pat2rgb(pat[y][draw_x], &r, &g, &b);

		cell_y = H_CELL*y;
		//DrawBox(cell_x, cell_y, cell_x+W_CELL, cell_y+H_CELL, GetColor(r,g,b), 1);	// 隙間なしバージョン
		DrawBox(cell_x, cell_y, cell_x+W_CELL-1, cell_y+H_CELL-1, GetColor(r,g,b), 1);	// 隙間ありバージョン
	}

	// 実行するたびに次の列を描画する
	draw_x = (draw_x+1) % H_SIZE;


	//1/60秒間隔でループ。
	//while (GetNowCount() - e < (1.0/60*1000)) { Sleep(10); }
	//e = GetNowCount();

	// 入力信号を取得
	GetHitKeyStateAll(key);
	U_BTN = key[KEY_INPUT_UP];
	D_BTN = key[KEY_INPUT_DOWN];
	R_BTN = key[KEY_INPUT_RIGHT];
	L_BTN = key[KEY_INPUT_LEFT];
	BTN1  = key[KEY_INPUT_Z];
	BTN2  = key[KEY_INPUT_X];
}
Exemple #7
0
void Options::Draw()
{
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, 120); //透過
	DrawBox(0, 0, 640, 480, black, TRUE); //明るい背景を暗くする
	if (!keyconfigflag)
	{
		DrawBox(0, 25, 100, 55, yellow, TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); //元に戻す
		DrawExtendString(20, 30, 1.5, 1.5, "Option", black);
		DrawBox(0, choosenow * 25 + 65, 640, (choosenow + 1) * 25 + 65, yellow, TRUE);
		for (int i = 0; i < option_max; i++)
		{
			DrawFormatString(200 - GetDrawFormatStringWidth("%s", option_list[i]), i * 25 + 70, (choosenow == i ? black : white), "%s", option_list[i]);
		}
		DrawString(400, (option_max - 2) * 25 + 70, "設定", (choosenow == option_max - 2 ? black : white));
	}
	else
	{
		DrawBox(0, 25, 200, 55, yellow, TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); //元に戻す
		DrawExtendString(20, 30, 1.5, 1.5, "KeyConfig", black);
		DrawString(222, 35, "キーボード", white);
		DrawString(422, 35, "ゲームパッド", white);


		DrawBox(0, choosenow_keyconfig * 20 + 58, 640, (choosenow_keyconfig + 1) * 20 + 58, (keyconfingflag?black:yellow), TRUE);
		for (int i = 0; i < key_name_max - 1; i++)
		{
			DrawFormatString(160, i * 20 + 60, (choosenow_keyconfig == i ? black : white),"%s",key_name_list[i]);
			DrawKey(260, i * 20 + 60, key_deside_temp[i]);
		}
		DrawString(60, (key_name_max - 1) * 20 + 60, "設定を反映して戻る", (choosenow_keyconfig == 8 ? black : white));
	}
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, 144); //透過
	DrawBox(0, 0, 640, 20, blue, TRUE); //説明欄
	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); //元に戻す

	DrawFormatString(22, 2, white, "%s", option_explanation[choosenow], TRUE); //説明しよう
}
void DrawCube(CPUTRenderParameters &renderParams, float3 position, float size, CPUTColor4 color)
{
	DrawBox(renderParams, position, float3(size, size, size), color);
}
Exemple #9
0
//=================================================================================================
void TeamPanel::Draw(ControlDrawData*)
{
	GamePanel::Draw();

	Rect rect = {
		pos.x + 8,
		pos.y + 8,
		pos.x + size.x - 16,
		pos.y + size.y - 16
	};
	GUI.DrawText(GUI.fBig, txTeam, DTF_TOP | DTF_CENTER, Color::Black, rect);

	Int2 offset = global_pos + Int2(8, 40 - scrollbar.offset);
	rect = Rect::Create(Int2(global_pos.x + 8, global_pos.y + 40), Int2(size.x - 52, size.y - 96));

	Vec2 share = Team.GetShare();
	int pc_share = (int)round(share.x * 100);
	int npc_share = (int)round(share.y * 100);
	LocalString s;

	if(!picking)
		picked = -1;

	int n = 0;
	int hitbox_counter = 0;
	hitboxes.clear();
	Matrix mat;
	for(Unit* u : Team.members)
	{
		if(u->GetClass() != Class::INVALID)
		{
			TEX t = ClassInfo::classes[(int)u->GetClass()].icon;
			Int2 img_size;
			Vec2 scale;
			Control::ResizeImage(t, Int2(32, 32), img_size, scale);
			mat = Matrix::Transform2D(nullptr, 0.f, &scale, nullptr, 0.f, &Vec2((float)offset.x, (float)offset.y));
			GUI.DrawSprite2(t, mat, nullptr, &rect, Color::White);
		}
		if(u == Team.leader)
			GUI.DrawSprite(tKorona, Int2(offset.x + 32, offset.y), Color::White, &rect);
		if(!u->IsAlive())
			GUI.DrawSprite(tCzaszka, Int2(offset.x + 64, offset.y), Color::White, &rect);

		Rect r2 = {
			offset.x + 96,
			offset.y,
			offset.x + 1000,
			offset.y + 32
		};
		s = "$h+";
		s += Format(txCharInTeam, u->GetName(), u->IsPlayer() ? pc_share : (u->hero->free ? 0 : npc_share), u->GetCredit());
		if(u->IsPlayer() && Net::IsOnline())
		{
			if(Net::IsServer())
			{
				if(u != game.pc->unit)
					s += Format(txPing, N.peer->GetAveragePing(u->player->player_info->adr));
			}
			else if(u == game.pc->unit)
				s += Format(txPing, N.peer->GetAveragePing(N.server));
			s += Format(txDays, u->player->free_days);
		}
		s += ")$h-";
		if(!GUI.DrawText(GUI.default_font, s->c_str(), DTF_VCENTER | DTF_SINGLELINE | DTF_PARSE_SPECIAL, (n == picked ? Color::White : Color::Black), r2, &rect, &hitboxes, &hitbox_counter))
			break;

		offset.y += 32;
		++n;
	}

	scrollbar.Draw();

	int count = (Net::IsOnline() ? 4 : 2);
	for(int i = 0; i < count; ++i)
		bt[i].Draw();

	DrawBox();
}
Exemple #10
0
void reset()
{
    receivedX = 0;
    receivedY = 0;

    memset(videoBuffer, 0, 1024);

    if(level == 0) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);

        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 42;
        } else {
            playerX = 85;
        }
    }
    if(level == 1) {
        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 42;
        } else {
            playerX = 85;
        }
    }
    if(level == 2) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawLine(64, 0, 64, 63, videoBuffer, BLACK);

        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 32;
        } else {
            playerX = 96;
        }
    }
    if(level == 3) {
        DrawLine(0, 0, 127, 0, videoBuffer, BLACK);
        DrawLine(0, 63, 127, 63, videoBuffer, BLACK);
        DrawLine(64, 0, 64, 63, videoBuffer, BLACK);

        playerY = 32;
        direction = 0;
        if(isHost) {
            playerX = 42;
        } else {
            playerX = 85;
        }
    }
    if(level == 4) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawLine(0, 23, 57, 23, videoBuffer, BLACK);
        DrawLine(0, 40, 57, 40, videoBuffer, BLACK);
        DrawLine(70, 23, 127, 23, videoBuffer, BLACK);
        DrawLine(70, 40, 127, 40, videoBuffer, BLACK);

        playerY = 32;
        if(isHost) {
            direction = 1;
            playerX = 5;
        } else {
            direction = 3;
            playerX = 122;
        }
    }
    if(level == 5) {
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawBox(59, 5, 68, 58, videoBuffer, BLACK);
        DrawLine(8, 45, 30, 45, videoBuffer, BLACK);
        DrawLine(30, 45, 30, 63, videoBuffer, BLACK);
        DrawLine(119, 45, 97, 45, videoBuffer, BLACK);
        DrawLine(97, 45, 97, 63, videoBuffer, BLACK);

        playerY = 52;
        if(isHost) {
            direction = 3;
            playerX = 21;
        } else {
            direction = 1;
            playerX = 106;
        }
    }
}
Exemple #11
0
int AddIn_main(int isAppli, unsigned short OptionNum)
{
    int collided = 0;
    unsigned char answer;

    Bdisp_AllClr_DDVRAM();

    Init_SerialPort();
    Start_SerialPort();

    if(connect() == 0) {
        isHost = 1;
    }

    while(1) {
        startScreen();

        memset(videoBuffer, 0, 1024);
        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawBox(48, 27, 79, 37, videoBuffer, BLACK);
        CoolText(51, 29, FONT_FIVE, "Ready?", videoBuffer);
        DrawAll(videoBuffer);

        Sleep(1000);

        SerialTransmit(READY);
        while(SerialReceive() != READY) {
            ;
        }

        reset();

        while(1) {
            answer = SerialReceive();

            if(answer == CRASH) {
                score++;
                wonLast = ME;
                break;
            }
            if(answer == EXIT) {
                Reset_Calc();
            }
            if(answer == COORDS) {
                receivedX = SerialReceive();
                receivedY = SerialReceive();

                setBit(videoBuffer, 128, receivedX, receivedY, 1);
            }

            checkKeys();
            move();

            collided = getBit(videoBuffer, 128, playerX, playerY);
            if(collided) {
                otherScore++;
                wonLast = OTHER;
                SerialTransmit(CRASH);
                break;
            }

            setBit(videoBuffer, 128, playerX, playerY, 1);

            SerialTransmit(COORDS);
            SerialTransmit(playerX);
            SerialTransmit(playerY);

            DrawAll(videoBuffer);

            Sleep(delays[speed]);
        }
    }

    return 1;
}
Exemple #12
0
void startScreen()
{
    unsigned char answer;
    char scoreText[4], otherScoreText[4], statusText[22], speedText[22], levelText[22];
    int isReady = 0, is1Pressed = 0, is2Pressed = 0, is3Pressed = 0, isLeftPressed = 0, isRightPressed = 0;

    while(!isReady) {
        if(isHost) {
            if(isConnected) {
                strcpy(statusText, "Hosting");
            } else {
                strcpy(statusText, "Waiting");
            }
        } else {
            strcpy(statusText, "Connected");
        }

        sprintf(scoreText, "%d", score);
        sprintf(otherScoreText, "%d", otherScore);
        sprintf(speedText, "SPEED:  %d", speed + 1);
        sprintf(levelText, "LEVEL:  %d", level + 1);

        memset(videoBuffer, 0, 1024);

        DrawBox(0, 0, 127, 63, videoBuffer, BLACK);
        DrawLine(0, 8, 127, 8, videoBuffer, BLACK);
        DrawLine(0, 16, 127, 16, videoBuffer, BLACK);
        DrawLine(0, 24, 127, 24, videoBuffer, BLACK);
        DrawLine(64, 16, 64, 24, videoBuffer, BLACK);
        DrawLine(0, 32, 127, 32, videoBuffer, BLACK);
        DrawLine(0, 40, 127, 40, videoBuffer, BLACK);

        CoolText(32, 1, FONT_FIVE, "MTRON by rojet601", videoBuffer);
        CoolText(48, 9, FONT_FIVE, statusText, videoBuffer);
        CoolText(27, 17, FONT_FIVE, scoreText, videoBuffer);
        CoolText(91, 17, FONT_FIVE, otherScoreText, videoBuffer);
        if(wonLast == ME) {
            CoolText(48, 25, FONT_FIVE, "You won", videoBuffer);
        }
        if(wonLast == OTHER) {
            CoolText(48, 25, FONT_FIVE, "You lost", videoBuffer);   
        }
        if(isHost) {
            CoolText(2, 33, FONT_FIVE, speedText, videoBuffer);
            CoolText(65, 33, FONT_FIVE, levelText, videoBuffer);
            CoolText(2, 52, FONT_FIVE, "[1]-[3] SPEED", videoBuffer);
            CoolText(65, 52, FONT_FIVE, "         LEVEL", videoBuffer);
            DrawLine(65, 55, 71, 55, videoBuffer, BLACK);
            DrawLine(66, 55, 68, 53, videoBuffer, BLACK);
            DrawLine(66, 55, 68, 57, videoBuffer, BLACK);

            DrawLine(73, 55, 79, 55, videoBuffer, BLACK);
            DrawLine(79, 55, 77, 53, videoBuffer, BLACK);
            DrawLine(79, 55, 77, 57, videoBuffer, BLACK);
            if(isConnected) {
                CoolText(2, 43, FONT_FIVE, "[SHIFT] START", videoBuffer);
            }
        } else {
            CoolText(2, 43, FONT_FIVE, "Only the host can change", videoBuffer);
            CoolText(2, 52, FONT_FIVE, "the settings", videoBuffer);
        }

        DrawAll(videoBuffer);

        if(IsKeyDown(KEY_CTRL_EXIT) || IsKeyDown(KEY_CTRL_MENU)) {
            SerialTransmit(EXIT);
            Stop_SerialPort();
            Reset_Calc();
        }

        answer = SerialReceive();

        if(answer == EXIT) {
            Stop_SerialPort();
            Reset_Calc();
        }
        if(answer == START) {
            Sleep(50);
            speed = SerialReceive();
            level = SerialReceive();
            isReady = 1;
        }

        if(isHost) {
            if(!isConnected) {
                if(answer == HELLO_HOST) {
                    SerialTransmit(HELLO_CLIENT);
                    isConnected = 1;
                }
            } else {
                if(IsKeyDown(KEY_CTRL_SHIFT)) {
                    SerialTransmit(START);
                    SerialTransmit(speed);
                    SerialTransmit(level);
                    Sleep(50);
                    isReady = 1;
                }
            }
            if(!IsKeyDown(KEY_CHAR_1)) {
                is1Pressed = 0;
            }
            if(IsKeyDown(KEY_CHAR_1) && !is1Pressed) {
                is1Pressed = 1;
                speed = 0;
            }
            if(!IsKeyDown(KEY_CHAR_2)) {
                is2Pressed = 0;
            }
            if(IsKeyDown(KEY_CHAR_2) && !is2Pressed) {
                is2Pressed = 1;
                speed = 1;
            }
            if(!IsKeyDown(KEY_CHAR_3)) {
                is3Pressed = 0;
            }
            if(IsKeyDown(KEY_CHAR_3) && !is3Pressed) {
                is3Pressed = 1;
                speed = 2;
            }
            if(!IsKeyDown(KEY_CTRL_LEFT)) {
                isLeftPressed = 0;
            }
            if(IsKeyDown(KEY_CTRL_LEFT) && !isLeftPressed) {
                isLeftPressed = 1;
                level--;
                if(level == 255) {
                    level = levels - 1;
                }
            }
            if(!IsKeyDown(KEY_CTRL_RIGHT)) {
                isRightPressed = 0;
            }
            if(IsKeyDown(KEY_CTRL_RIGHT) && !isRightPressed) {
                isRightPressed = 1;
                level++;
                if(level > levels - 1) {
                    level = 0;
                }
            }
        }
    }
}
Exemple #13
0
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	ChangeWindowMode(TRUE);
	//SetMouseDispFlag(TRUE);
	SetDrawMode(DX_DRAWMODE_BILINEAR);
	SetScreenMemToVramFlag(FALSE);
	SetAlwaysRunFlag(TRUE);
	SetDrawScreen( DX_SCREEN_BACK);
	if(DxLib_Init()==-1)		// DXライブラリ初期化処理
	{
		return -1 ;			// エラーが起きたら直ちに終了
	}

	//デバック用にコンソールを出現させる
	/*
	AllocConsole();
	freopen("CONOUT$","w",stdout);
	freopen("CONIN$","r",stdin);z
	*/

	Mode gamemode=OPENING;
	AI_T ai[AI_NUM];
	Takara takara;
	int death[AI_NUM]={0};
	Tagger tagger[TAGGER_NUM];
	int tagger_num = 0;
	int STAGE[WIDTH][HEIGHT]={0};
	int round=0;
	int start=0;
	int end=0;
	int StartTime,TimeLimit;

	for(int i=0;i<AI_NUM;i++){
		ai[i].entry=1;
	}
	ai[0].entry=0;

	while(ProcessMessage()!=-1){
		int speed=0;
		switch(gamemode){
		case OPENING:
			start=intro(ai);
			if(start==1)gamemode=SETTING;
			break;
		case SETTING:
			takara.x=GetRand(WIDTH/2)+WIDTH/2-1;
			takara.y=GetRand(HEIGHT/2)+1;
			takara.drop=0;
			make_Stage(STAGE,takara);//マップ構成
			tagger_num = init_Tagger(tagger,STAGE);//鬼の初期化 //tagger_numは鬼の要素番号

			init_Ai(ai,STAGE);

			round++;
			TimeLimit=TIME_LIMIT*60*79;//ゲーム開始時の時刻に合わせる
			gamemode=RUNNING;

			break;
		case RUNNING:
			TimeLimit-=79;
			if(TimeLimit<0)TimeLimit=0;
			if(tagger[tagger_num].step==0){
				//tagger[tagger_num].act=next_Tagger(tagger[tagger_num],STAGE,ai);
				tagger[tagger_num].act=tagger[tagger_num].moveFunc(tagger[tagger_num].x,tagger[tagger_num].y,STAGE); //AIと一緒で、moveFunc使う
			}
			for(int i=0;i<AI_NUM;i++){
				if(ai[i].step==0 && ai[i].entry==1){
					setview_Ai(&ai[i],STAGE);
					//ai[i].act=next_Ai(ai[i].view); //henteko : 下のmoveFunc()を使うためコメントアウト
					ai[i].act = ai[i].moveFunc(ai[i].view);
				}
			}
			if(TimeLimit>TIME_LIMIT*45*79)speed=0;
			else if(TimeLimit>TIME_LIMIT*30*79)speed=1;
			else if(TimeLimit>TIME_LIMIT*15*79)speed=1;
			else speed=3;
			update_Tagger(&tagger[tagger_num],STAGE,speed);
			for(int i=0;i<AI_NUM;i++){
				if(ai[i].entry==1)
					update_Ai(&ai[i],STAGE,&takara);
			}
			update_stage(STAGE,ai,tagger[tagger_num],takara);
			
			ClearDrawScreen();
			draw(STAGE,ai,tagger[tagger_num],takara);
			DrawFormatString(30,30,GetColor(0,255,255),"ROUND%d",round);
			
			DrawFormatString(500,15,GetColor(0,255,0),"TIME %d",TimeLimit);
			
			if(1){
				for(int i=0;i<AI_NUM;i++){
					if(death_Ai(ai[i],tagger[tagger_num])==1 && ai[i].entry==1){
						death[i]++;
						DrawBox(0,230,640,260,GetColor(0,0,0),1);
						DrawBox(-1,230,642,260,GetColor(255,0,0),0);
						DrawFormatString(100,240,GetColor(255,0,0),"%sがつかまりました",ai[i].name);// 8/3 zero追記:AI捕獲の宣言をまとめた。
						init_Ai(&ai[i],STAGE);//元の場所に戻される
						TimeLimit-=1000;//時間ペナルティ
						/*WaitTimer(3000);
						if(round>=ROUND_MAX){
							gamemode=ENDING;
						}
						else{
							gamemode=SETTING;
						}
						break;*/
					}
				}
			}
			if(TimeLimit<=0){// 8/3 zero追記:タイムアップを設定
				round--;
				DrawString(100,240,"時間切れです",GetColor(255,0,0));
				WaitTimer(3000);
				if(round>=ROUND_MAX){
					gamemode=ENDING;
				}
				else{
					gamemode=SETTING;
				}
				break;
			}
			if(CheckHitKey(KEY_INPUT_R)==1){
				gamemode=SETTING;
			}
			break;
		case ENDING:
			end=ranking(ai,death);
			break;
		default:
			break;
		}
		if(end==1 || CheckHitKey(KEY_INPUT_ESCAPE))break;
		ScreenFlip();
	}

	DxLib_End() ;				// DXライブラリ使用の終了処理

	return 0 ;				// ソフトの終了 
}
Exemple #14
0
int main(int argc, char *argv[])
{
    SDL_Surface *screen;
    Uint32 videoflags;
    int    done;
    SDL_Event event;
    int width, height, bpp;

    /* Initialize SDL */
    if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
        fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
        exit(1);
    }

    /* See if we try to get a hardware colormap */
    width = 640;
    height = 480;
    bpp = 8;
    videoflags = SDL_SWSURFACE;
    while ( argc > 1 ) {
        --argc;
        if ( argv[argc-1] && (strcmp(argv[argc-1], "-width") == 0) ) {
            width = atoi(argv[argc]);
            --argc;
        } else if ( argv[argc-1] && (strcmp(argv[argc-1], "-height") == 0) ) {
            height = atoi(argv[argc]);
            --argc;
        } else if ( argv[argc-1] && (strcmp(argv[argc-1], "-bpp") == 0) ) {
            bpp = atoi(argv[argc]);
            --argc;
        } else if ( argv[argc] && (strcmp(argv[argc], "-hw") == 0) ) {
            videoflags |= SDL_HWSURFACE;
        } else if ( argv[argc] && (strcmp(argv[argc], "-hwpalette") == 0) ) {
            videoflags |= SDL_HWPALETTE;
        } else if ( argv[argc] && (strcmp(argv[argc], "-noframe") == 0) ) {
            videoflags |= SDL_NOFRAME;
        } else if ( argv[argc] && (strcmp(argv[argc], "-fullscreen") == 0) ) {
            videoflags |= SDL_FULLSCREEN;
        } else {
            fprintf(stderr, "Usage: %s [-warp] [-fullscreen]\n",
                    argv[0]);
            exit(1);
        }
    }

    /* Set a video mode */
    screen = CreateScreen(width, height, bpp, videoflags);
    if ( screen == NULL ) {
        exit(2);
    }

    /* Wait for a keystroke */
    done = 0;
    while ( !done && SDL_WaitEvent(&event) ) {
        switch (event.type) {
        case SDL_MOUSEBUTTONDOWN:
            DrawBox(screen, event.button.x, event.button.y);
            break;
        case SDL_KEYDOWN:
            /* Ignore ALT-TAB for windows */
            if ( (event.key.keysym.sym == SDLK_LALT) ||
                    (event.key.keysym.sym == SDLK_TAB) ) {
                break;
            }
            /* Center the mouse on <SPACE> */
            if ( event.key.keysym.sym == SDLK_SPACE ) {
                SDL_WarpMouse(640/2, 480/2);
                break;
            }
            /* Toggle fullscreen mode on <RETURN> */
            if ( event.key.keysym.sym == SDLK_RETURN ) {
                videoflags ^= SDL_FULLSCREEN;
                screen = CreateScreen(
                             screen->w, screen->h,
                             screen->format->BitsPerPixel,
                             videoflags);
                if ( screen == NULL ) {
                    fprintf(stderr,
                            "Couldn't toggle fullscreen mode\n");
                    done = 1;
                }
                break;
            }
        /* Any other key quits the application... */
        case SDL_QUIT:
            done = 1;
            break;
        default:
            break;
        }
    }
    SDL_Quit();
    return(0);
}
Exemple #15
0
// -----------------------------------------------------------
// Engine::FindNearest
// Finds the nearest intersection in a KdTree for a ray
// -----------------------------------------------------------
int KDTree::FindNearestToRay( Ray& vRay, Vec3 &tmin, Vec3 &tmax, RayIntersectCallback callback, Matrix4x4 * temp )
{
	static bool bOutput = false;
	float tnear = 0;
	float tfar = ( tmax - tmin ).Length();
	float t;
	int retval = 0;
	float D[3];
	float O[3];
	VecToFloatArray( vRay.m_Direction, D );
	VecToFloatArray( vRay.m_Origin, O );
	// We assume ray fits in extents
	// clip ray segment to box
	static AABB bbox;
	bbox.Set( tmin, tmax );
	if( !bbox.IntersectRay( vRay, tnear, tfar ) )
		return 0;
	if( tnear < 0 || 
		tfar < 0 || 
		tnear > tfar )
		return 0;
	// init stack
	int entrypoint = 0, exitpoint = 1;
	// init traversal
	KDTreeNode* farchild, *currnode;
	farchild = 0;
	currnode = m_Root;
	m_Stack[entrypoint].t = tnear;
	if (tnear > 0.0f) 
	{
		m_Stack[entrypoint].pb[0] = O[0] + D[0]*tnear;
		m_Stack[entrypoint].pb[1] = O[1] + D[1]*tnear;
		m_Stack[entrypoint].pb[2] = O[2] + D[2]*tnear;
	}
	else
	{
		m_Stack[entrypoint].pb[0] = O[0];
		m_Stack[entrypoint].pb[1] = O[1];
		m_Stack[entrypoint].pb[2] = O[2];
	}
	m_Stack[exitpoint].t = tfar;
	m_Stack[exitpoint].pb[0] = O[0] + D[0]*tfar;
	m_Stack[exitpoint].pb[1] = O[1] + D[1]*tfar;
	m_Stack[exitpoint].pb[2]= O[2] + D[2]*tfar;
	m_Stack[exitpoint].node = 0;
	int dim = -1;
	// traverse kd-tree
	char buf[1024];

	static int aa = 0;
	if( bOutput )
	{
		sprintf( buf, "tfar: %f, tnear: %f\n", tfar, tnear );
		OutputDebugString( buf );
		OutputVector( vRay.m_Origin, "Ray origin" );
		OutputVector( vRay.m_Direction, "Ray direction" );
		OutputVector( O, "Ray origin2" );
		OutputVector( D, "Ray direction2" );
		OutputVector( m_Stack[ entrypoint ].pb, "entry" );
		sprintf( buf, "exit far: %f\n", m_Stack[exitpoint].t );
		OutputDebugString( buf );
		OutputVector( m_Stack[ exitpoint ].pb, "exit" );
	}
	KDTreeNode * lastNode = 0;
	g_Boxes.clear();
	vector< KDTreeNode * > nodesToCheck;
	while(currnode)
	{
		if( aa < 1 )
			DrawBox( currnode->bounds.m_Bounds[0], currnode->bounds.m_Bounds[1], temp );
		//Is not a leaf?
		while( currnode->pntidx < 0 )
		{		
			lastNode = currnode;
			dim = (dim + 1) % ndim;
			if( m_Stack[entrypoint].pb[dim] <= currnode->key )
			{
				if( m_Stack[exitpoint].pb[dim] <= currnode->key )
				{
					currnode = m_Root + currnode->leftIdx;
					continue;
				}
				farchild = m_Root + currnode->rightIdx; // GetRight();
				currnode = m_Root + currnode->leftIdx;
			}
			else 
			{
				if (m_Stack[exitpoint].pb[dim] > currnode->key)
				{
					currnode = m_Root + currnode->rightIdx;
					continue;
				}
				farchild = m_Root + currnode->leftIdx;
				currnode = m_Root + currnode->rightIdx; // GetRight();
			}
			
			t = (currnode->key - O[dim]) / D[dim];
			int tmp = exitpoint++;
			if (exitpoint == entrypoint) 
				exitpoint++;
			m_Stack[exitpoint].prev = tmp;
			m_Stack[exitpoint].t = t;
			m_Stack[exitpoint].node = farchild;
			m_Stack[exitpoint].pb[dim] = currnode->key;
			int nextaxis = (dim + 1) % ndim;
			int prevaxis = (dim + 2) % ndim;
			m_Stack[exitpoint].pb[nextaxis] = O[nextaxis] + t * D[nextaxis];
			m_Stack[exitpoint].pb[prevaxis] = O[prevaxis] + t * D[prevaxis];
		}
		if( aa < 1 )
				DrawBox( currnode->bounds.m_Bounds[0], currnode->bounds.m_Bounds[1], temp );			
			
		float dist = m_Stack[exitpoint].t;
		nodesToCheck.push_back( currnode );
		entrypoint = exitpoint;
		currnode = m_Stack[exitpoint].node;
		exitpoint = m_Stack[entrypoint].prev;
	}
	bool bfound = (*callback)( nodesToCheck );
	if( bfound )
	{
		return 1;
	}
//	return 0;
	//check by comparing all nodes
	nodesToCheck.clear();
	nodesToCheck.push_back( m_Root );
	bool bresult = (*callback)( nodesToCheck );
	if( bresult )
	{
		if( g_Boxes.size() > 0 && aa < 1 )
		{
			for( int i = 0; i < (int)g_Boxes.size(); i++ )
			{
				static DWORD msgHash_AddAxisAlignedBox = CHashString(_T("AddAxisAlignedBox")).GetUniqueID();
				EngineGetToolBox()->SendMessage(msgHash_AddAxisAlignedBox,sizeof(g_Boxes[i]), &g_Boxes[i] );
				OutputDebugString("Box:\t");
				OutputVector(	g_Boxes[i].min, "Min" );
				OutputVector(	g_Boxes[i].max, "Max" );
			}
			g_Boxes.clear();
			aa++;
			static CHashString h(_T("none"));
			ADDLINEPARAMS LineParam;
			LineParam.name = &h;
			LineParam.start = (*temp)*vRay.m_Origin;
			LineParam.end =  vRay.m_Origin + vRay.m_Direction*10000;
			LineParam.end = (*temp)*LineParam.end;
			LineParam.red = 0;
			LineParam.blue = 0;
			LineParam.green = 255;
			static DWORD msgHash_AddLine = CHashString(_T("AddLine")).GetUniqueID();
			EngineGetToolBox()->SendMessage(msgHash_AddLine,sizeof(LineParam), &LineParam );

		}
        return 1;
	}
	return 0;
}
Exemple #16
0
void csGraphics2D::Clear(int color)
{
  DrawBox (0, 0, vpWidth, vpHeight, color);
}
void server_main(){
  graresource.initialize();
  static const int BLACK = GetColor(0, 0, 0);
  static const int WHITE = GetColor(255, 255, 255);
	ServerConnection server(PORT);
	server.startListen();
	while(server.size() < CLIENT_NUM){
		DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
		DrawFormatString(60, 60, WHITE, "access: %d", server.size());
		ScreenFlip();
		Sleep(10);
		server.action();
    // Windows 特有の面倒な処理をDXライブラリにやらせる
    // -1 が返ってきたらループを抜ける
    if( ProcessMessage() < 0 ) exit(1) ;

    // もしESCキーが押されていたらループから抜ける
    if( CheckHitKey( KEY_INPUT_ESCAPE ) ) exit(1);
	}
	server.endListen();
	DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
	DrawFormatString(60, 60, WHITE, "access: %d", server.size());
	DrawFormatString(60, 80, WHITE, "game start", server.size());
	ScreenFlip();
  Shooting shooting(CLIENT_NUM);
  // 移動ルーチン
	int fpsTimer = GetNowCount();
  while( 1 ){
		string serverMessage;
    // todo treat dead client
    //while(true){
    //  int lostNetWork = GetLostNetWork();
    //}

		for(int i = 0; i < server.size(); ++i){
      if(server.receive(i, serverMessage) >= 0){
        while(server.receive(i, serverMessage) >= 0);
        // receive succssessed
        shooting.setInput(i, serverMessage);
      }else{
        // receive failed
        shooting.clearInput(i);
      }
	  }
    shooting.action();

		// debug messages
		dxout << serverMessage << dxendl;

		vector<int> clientMessage = graresource.getMessages();

		DrawBox(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, BLACK, 1);
		DrawFormatString(60, 60, WHITE, "access: %d", server.size());
		DrawFormatString(60, 80, WHITE, "game start", server.size());
		//DrawFormatString(60, 100, WHITE, clientMessage.c_str());
		ScreenFlip();

		server.send(clientMessage);
	  graresource.clear();
	  int term;
	  term = GetNowCount()-fpsTimer;
	  if(16-term>0){
			Sleep(16-term);
		}
	  fpsTimer = GetNowCount();

		if (!shooting.isValid()) break;
    // Windows 特有の面倒な処理をDXライブラリにやらせる
    // -1 が返ってきたらループを抜ける
    if( ProcessMessage() < 0 ) break ;

    // もしESCキーが押されていたらループから抜ける
    if( CheckHitKey( KEY_INPUT_ESCAPE ) ) break;
  }
}
Exemple #18
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudMenu::Paint()
{
	if ( !m_bMenuDisplayed )
		return;

	// center it
	int x = 20;

	Color	menuColor = m_MenuColor;
	Color itemColor = m_ItemColor;

	int c = m_Processed.Count();

	int border = 20;

	int wide = m_nMaxPixels + border;
	int tall = m_nHeight + border;

	int y = ( ScreenHeight() - tall ) * 0.5f;

	DrawBox( x - border/2, y - border/2, wide, tall, m_BoxColor, m_flSelectionAlphaOverride / 255.0f );

	//DrawTexturedBox( x - border/2, y - border/2, wide, tall, m_BoxColor, m_flSelectionAlphaOverride / 255.0f );

	menuColor[3] = menuColor[3] * ( m_flSelectionAlphaOverride / 255.0f );
	itemColor[3] = itemColor[3] * ( m_flSelectionAlphaOverride / 255.0f );

	for ( int i = 0; i < c; i++ )
	{
		ProcessedLine *line = &m_Processed[ i ];
		Assert( line );

		Color clr = line->menuitem != 0 ? itemColor : menuColor;

		bool canblur = false;
		if ( line->menuitem != 0 &&
			m_nSelectedItem >= 0 && 
			( line->menuitem == m_nSelectedItem ) )
		{
			canblur = true;
		}
		
		vgui::surface()->DrawSetTextColor( clr );

		int drawLen = line->length;
		if ( line->menuitem != 0 )
		{
			drawLen *= m_flTextScan;
		}

		vgui::surface()->DrawSetTextFont( line->menuitem != 0 ? m_hItemFont : m_hTextFont );

		PaintString( &g_szMenuString[ line->startchar ], drawLen, 
			line->menuitem != 0 ? m_hItemFont : m_hTextFont, x, y );

		if ( canblur )
		{
			// draw the overbright blur
			for (float fl = m_flBlur; fl > 0.0f; fl -= 1.0f)
			{
				if (fl >= 1.0f)
				{
					PaintString( &g_szMenuString[ line->startchar ], drawLen, m_hItemFontPulsing, x, y );
				}
				else
				{
					// draw a percentage of the last one
					Color col = clr;
					col[3] *= fl;
					vgui::surface()->DrawSetTextColor(col);
					PaintString( &g_szMenuString[ line->startchar ], drawLen, m_hItemFontPulsing, x, y );
				}
			}
		}

		y += line->height;
	}
}
void CQuitBox::Draw(void)
{
	float mx=MouseX(mouse->lastx);
	float my=MouseY(mouse->lasty);

	glDisable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glDisable(GL_ALPHA_TEST);

	// Large Box
	glColor4f(0.2f,0.2f,0.2f,guiAlpha);
	DrawBox(box);

	// resign and quit Box on mouse over
	if(InBox(mx,my,box+resignQuitBox)){
		glColor4f(0.7f,0.2f,0.2f,guiAlpha);
		DrawBox(box+resignQuitBox);
	}

	// resign Box on mouse over
	if(InBox(mx,my,box+resignBox)){
		glColor4f(0.7f,0.2f,0.2f,guiAlpha);
		DrawBox(box+resignBox);
	}

	// give away Box on mouse over
	if(InBox(mx,my,box+giveAwayBox)){
		glColor4f(0.7f,0.2f,0.2f,guiAlpha);
		DrawBox(box+giveAwayBox);
	}
	// cancel Box on mouse over
	if(InBox(mx,my,box+cancelBox)){
		glColor4f(0.7f,0.2f,0.2f,guiAlpha);
		DrawBox(box+cancelBox);
	}
	// quit Box on mouse over
	if(InBox(mx,my,box+quitBox)){
		glColor4f(0.7f,0.2f,0.2f,guiAlpha);
		DrawBox(box+quitBox);
	}


	glColor4f(0.2f,0.2f,0.2f,guiAlpha);
	DrawBox(box+teamBox);


	glEnable(GL_TEXTURE_2D);
	glColor4f(1,1,0.4f,0.8f);
	font->glPrintAt(box.x1+0.045f,box.y1+0.62f,0.7f,"Do you want to ...");
	glColor4f(1,1,1,0.8f);
	font->glPrintAt(box.x1 + resignQuitBox.x1 + 0.025f,
	                box.y1 + resignQuitBox.y1 + 0.005f, 1, "Quit and resign");
	font->glPrintAt(box.x1 + resignBox.x1     + 0.025f,
	                box.y1 + resignBox.y1     + 0.005f, 1, "Resign");
	font->glPrintAt(box.x1 + giveAwayBox.x1   + 0.025f,
	                box.y1 + giveAwayBox.y1   + 0.005f, 1, "Give everything to ...");
	font->glPrintAt(box.x1 + cancelBox.x1     + 0.025f,
	                box.y1 + cancelBox.y1     + 0.005f, 1, "Cancel");
	font->glPrintAt(box.x1 + quitBox.x1       + 0.025f,
	                box.y1 + quitBox.y1       + 0.005f, 1, "Quit");

	for(int team=0;team<gs->activeTeams-1;++team){
		int actualTeam=team;
		if (team >= gu->myTeam) {
			actualTeam++;
		}
		if (gs->Team(actualTeam)->gaia) continue;

		if (shareTeam == actualTeam) {
			glColor4f(1,1,1,0.8f);
		} else {
			glColor4f(1,1,1,0.4f);
		}

		string teamName = gs->players[gs->Team(actualTeam)->leader]->playerName;

		string ally, dead;
		if (gs->Ally(gu->myAllyTeam, gs->AllyTeam(actualTeam))) {
			ally = " <Ally>)";
		} else {
			ally = " <Enemy>";
		}
		if(gs->Team(actualTeam)->isDead) {
			dead = " <Dead>";
		}
		if (actualTeam == gs->gaiaTeamID) {
			teamName = "Gaia";
			ally   = " <Gaia>";
		}
		font->glPrintAt(box.x1 + teamBox.x1 + 0.002f,
		                box.y1 + teamBox.y2 - 0.025f - team * 0.025f, 0.7f,
		                "Team%i (%s)%s%s", actualTeam,
		                teamName.c_str(), ally.c_str(), dead.c_str());
	}
}
Exemple #20
0
inline void MODEL :: displayHp(){
	DrawBox(400, 10, 600, 30, GetColor(125, 255, 0), FALSE);
	if(hp < 0)
		hp = 0;
	DrawBox(400, 10, 400+hp*2, 30, GetColor(125, 255, 0), TRUE);
}
Exemple #21
0
void CProduct::Product(){
	//debug.Print("%",);
	//DEBUG_PRINT_VALUE();

	cursor.Setm();
	cursor.Setc();
	screen.MoveAdj(sNum);

	openednow = false;

	produced = false;

	
	if (Event.LMouse.GetClick(100, 50, 100 + GRID_L*MAP_W, 50 + GRID_L*MAP_H) && stage.GetTownOwner(cursor.Getcx() + screen.adjX, cursor.Getcy() + screen.adjY) == turn.GetCountry() && !(openwin || cant[0] || cant[1]) && !UnitOnTown()){

		forcheck = 1;

		while (forcheck <= UNIT_NUM){
			if (battle.unitm.country[turn.GetCountry()].unit[forcheck].GetunitX() == -100){
				openwin = true;
				openednow = true;
				locationX = cursor.Getcx() + screen.adjX;
				locationY = cursor.Getcy() + screen.adjY;

				forcheck = UNIT_NUM + 100;
			}
			else {
				forcheck++;
			}
		}

		if (forcheck != UNIT_NUM + 100){
			cant[0] = true;
			openednow = true;
		}
	}

	if (cant[0]){
		DrawGraph(350, 250, picture.cannot[0], true);

		DrawGraph(425, 300, picture.ok, true);

		if(Event.LMouse.GetClick(424,299,475,325)){
			cant[0] = false;
		}
	}

	if(cant[1]){
		DrawGraph(350, 250, picture.cannot[1], true);

		DrawGraph(425, 300, picture.ok, true);

		if(Event.LMouse.GetClick(424,299,475,325)){
			cant[1] = false;
		}
	}


	if (openwin){
		DrawGraph(100, 50, picture.productScr, true);

		for (int j = 0; j < 2; j++){
			for (int i = 0; i < 3; i++){
				DrawGraph(307 + j * 270, 73, picture.coin, true);

				DrawGraph(328 + 20 * i + j * 270, 70, picture.strength[i], true);
			}
		}

		for(int i=0;i<UTYPE_NUM;i++){
			DrawGraph(150 + (i / 5) * 270, 95 + 50 * (i % 5), picture.unitPic[i], true);

			DrawFormatString(180 + (i / 5) * 270, 100 + 50 * (i % 5), BLACK, file.name[i + 1]);

			draw.DrawNumber(295 + (i / 5) * 270, 100 + 50 * (i % 5), GRAY, file.cost[i + 1]);
			
			draw.DrawNumber(320 + (i / 5) * 270, 100 + 50 * (i % 5), RED, file.strength[i + 1]);
			
			draw.DrawNumber(340 + (i / 5) * 270, 100 + 50 * (i % 5), GREEN, file.rangedStrength[i + 1]);
			
			draw.DrawNumber(360 + (i / 5) * 270, 100 + 50 * (i % 5), BLUE, file.siegeStrength[i + 1]);
			
			if (cursor.Getmx()>140 + (i / 5) * 270 && cursor.Getmx()<390 + (i / 5) * 270 && cursor.Getmy()>95 + (i % 5) * 50 && cursor.Getmy()<125 + (i % 5) * 50){
				DrawBox(140 + (i / 5) * 270, 90 + (i % 5) * 50, 390 + (i / 5) * 270, 125 + (i % 5) * 50, RED, false);
			}
			
			if (Event.LMouse.GetClick(145 + (i / 5) * 270, 95 + (i % 5) * 50, 390 + (i / 5) * 270, 125 + (i % 5) * 50) && !openednow){
				for(int n=1;n<=UNIT_NUM;n++){
					if(battle.unitm.country[turn.GetCountry()].unit[n].GetunitX()==-100 && !produced){
						if (battle.unitm.country[turn.GetCountry()].CanPay(file.cost[i + 1])){
							battle.unitm.country[turn.GetCountry()].unit[n].Product(locationX,locationY,i+1);
							battle.unitm.country[turn.GetCountry()].Pay(file.cost[i+1]);
						}else{
							cant[1]=true;
						}
						produced=true;
					}
				}

				openwin=false;
			}

		}

		DrawGraph(770,50,picture.close,true);

		if(Event.LMouse.GetClick(770,50,800,80)){
			openwin = false;
		}
	}

	if(openwin){
		battle.unitm.ProductScr(true,true);
	}
	else{
		battle.unitm.ProductScr(cant[0],cant[1]);
	}

	if(turn.Getskip()){
		openwin=false;
		cant[0]=false;
		cant[1]=false;
	}

	for (int i = 1; i <= COUNTRY_NUM; i++){
		if (stage.GetTNum(i) != 0){
			battle.unitm.country[i].ShowMoney(i);
		}else{
			battle.unitm.country[i].GameOver();
		}
	}

	Income();

	if (Event.RMouse.GetClick(100, 50, 100 + GRID_L*MAP_W, 50 + GRID_L*MAP_H) || Event.LMouse.GetClick(100, 50, 100 + GRID_L*MAP_W, 50 + GRID_L*MAP_H)){
		DamageTown(cursor.Getcx() + screen.adjX, cursor.Getcy() + screen.adjY, battle.GetTDamage(), turn.GetCountry());
	}

	HealTown();

	SetTownOwner();

	turn.SkipTurn();

}
Exemple #22
0
/**
 * @function RotValDraw
 * @brief rotary value draw function
 * @param void *_g_obj: generic object
 * @param void *_obj: rot val object
 * @return none
 */
static void RotValDraw(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  rot_val_st *rval;
  rect_st lrec, absRec;
  color_t colBack, colText, colSetText;
  uint8_t digitId, len, glyph, str[MAX_VAL_STR], typeBox = 0;
  bool bNeg;
  surfaceId_t idSurface = SURFACE_LCD;

  /*retrieve generic & specific object*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    rval = (rot_val_st*) _obj;

    /*try to create a double buffer in RAM*/
    absRec = g_obj->rec;
    absRec.x = 0;
    absRec.y = 0;
    idSurface = P2D_SurfaceCreate(&absRec);
    if(idSurface != SURFACE_LCD) {
      P2D_SetDest(idSurface);
    }
    else {
      absRec = g_obj->rec;
    }

    /*color selection*/
    if(GUI_ObjIsDisabled(g_obj)) {
      SetLut(G_LUT_DISABLED);
      colBack = GetColor(G_COL_E_BACKGROUND);
      colText = GetColor(G_COL_D_TEXT);
      colSetText = GetColor(G_COL_D_TEXT);
      typeBox = 2;
    }
    else if(GUI_ObjIsPressed(g_obj)) {
      SetLut(G_LUT_NORMAL);
      colBack = GetColor(G_COL_E_BACKGROUND);
      colText = rval->colorText;
      colSetText = GetColor(G_COL_SPECIAL);
    }
    else {
      SetLut(G_LUT_NORMAL);
      colBack = GetColor(G_COL_E_BACKGROUND);
      colText = rval->colorText;
      if(rval->lock != 0) colSetText = rval->colorText;
      else colSetText = GetColor(G_COL_SPECIAL);
    }

    /*P2D configuration*/
    P2D_SetDisplayMode(DISPLAY_SOLID);
    P2D_SetLineType(LINE_SOLID);
    SetFont(rval->font);

    /*background*/
    P2D_SetColors(colBack, colBack);
    lrec = absRec;
    P2D_SetColors(COLOR_LIGHT_GREY, COLOR_LIGHT_GREY);
    DrawBox(&lrec, typeBox);

    /*sprite*/
    P2D_SetDisplayMode(DISPLAY_TRANSPARENT);
    if(rval->img != 0) {
      Sprite(lrec.x + 4, lrec.y + ((int32_t)lrec.h - SpriteGetHeight(rval->img)) / 2, rval->img);
    }

    /*display the value's unit string*/
    lrec.x += 1; lrec.y += 1;
    lrec.w -= 2; lrec.h -= 2;
    P2D_SetColors(colText, colBack);
    lrec.y = absRec.y + ((coord_t)absRec.h - P2D_GetTextHeight()) / 2;
    P2D_PutText(absRec.x + rval->xUnit, lrec.y, rval->strUnit);

    /*format value*/
    (void) snprintf( (char *)str, MAX_VAL_STR, "%d", *(rval->pVar));
    len = gstrlen(str);
    bNeg = *(rval->pVar) < 0 ? true : false;

    /*display each digit, one by one, from right to left*/
    for(digitId = 0; IsValidDigit(rval, digitId) == true; digitId++) {

      /*get the x coord of the current digit*/
      lrec.x = absRec.x + GetDigitCoord(rval, digitId);

      /*special color + highlighted if the current digit is the selected one*/
      if(digitId == rval->selectedDigit && rval->lock == false) {
        P2D_SetColors(colSetText, colBack);
      }
      else {
        P2D_SetColors(colText, colBack);
      }

      /*display the snprintf content, excepting the '-'*/
      if(digitId < len) {
        glyph = str[len - digitId - 1];
        if(glyph == (uint8_t)'-') glyph = (uint8_t)'0'; /*will be displayed at end*/
      }
      /*for small value (i.e. digitId >= strlen), fill with '0'*/
      else {
        glyph = (uint8_t)'0';
      }

      P2D_PutGlyph(lrec.x, lrec.y, glyph);
    }

    /*display the sign, only if negative*/
    if(bNeg) {
      P2D_SetColors(colText, colBack);
      lrec.x = absRec.x + GetDigitCoord(rval, digitId);
      P2D_PutGlyph(lrec.x, lrec.y, (uint8_t)'-');
    }

    /*display the dot, if any*/
    if(rval->posDot > 0) {
      P2D_SetColor(colText);
      lrec.x = absRec.x + GetDigitCoord(rval, rval->posDot - 1) - rval->spacing;
      P2D_SetColors(colText, colBack);
      P2D_PutGlyph(lrec.x, lrec.y, (uint8_t) '.');
    }

    /*if the double buffer was active, flip it to the screen*/
    if(idSurface != SURFACE_LCD) {
      P2D_SetDest(SURFACE_LCD);
      P2D_CopySurface(idSurface, &absRec, &(g_obj->rec));
      P2D_SurfaceDelete(idSurface);
    }
  }
}
Exemple #23
0
void Input::Draw()
{
    {
        int alpha = active() ? 255 : 150;

        if (reverse_color_) {
            SetDrawBlendMode(DX_BLENDMODE_INVSRC, alpha);
        } else {
            SetDrawBlendMode(DX_BLENDMODE_ALPHA, alpha);
        }

        DrawGraph(x_, y_, *input_bg_image_handle_[0], TRUE);
        DrawGraph(x_ + width_ - 12, y_, *input_bg_image_handle_[1], TRUE);
        DrawGraph(x_, y_ + height_ - 12, *input_bg_image_handle_[2], TRUE);
        DrawGraph(x_ + width_ - 12, y_ + height_ - 12, *input_bg_image_handle_[3], TRUE);

        DrawRectExtendGraphF(x_ + 12, y_,
                             x_ + width_ - 12, y_ + 12,
                             0, 0, 1, 12, *input_bg_image_handle_[1], TRUE);

        DrawRectExtendGraphF(x_ + 12, y_ + height_ - 12,
                             x_ + width_ - 12, y_ + height_,
                             0, 0, 1, 12, *input_bg_image_handle_[3], TRUE);

        DrawRectExtendGraphF(x_, y_ + 12,
                             x_ + 12, y_ + height_ - 12,
                             0, 0, 12, 1, *input_bg_image_handle_[2], TRUE);

        DrawRectExtendGraphF(x_ + width_ - 12, y_ + 12,
                             x_ + width_, y_ + height_ - 12,
                             0, 0, 12, 1, *input_bg_image_handle_[3], TRUE);

        DrawRectExtendGraphF(x_ +  12, y_ + 12,
                             x_ + width_ - 12, y_ + height_ - 12,
                             0, 0, 1, 1, *input_bg_image_handle_[3], TRUE);

        SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
    }

    {
        int internal_x = x_ + INPUT_MARGIN_X;
        int internal_y = y_ + INPUT_MARGIN_Y;
        // int internal_width = width_ - INPUT_MARGIN * 2;
        // int internal_height = height_ - INPUT_MARGIN * 2;

        // 選択範囲の背景を描画
        //int current_line = 0;
        //for (auto it = selecting_lines_.begin(); it != selecting_lines_.end(); ++it) {
        //    auto line = *it;
        //    if (line.first < line.second) {
        //        SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);
        //        DrawBox(internal_x + line.first,
        //                internal_y + current_line * font_height_,
        //                internal_x + line.second,
        //                internal_y + (current_line + 1) * font_height_,
        //                GetColor(255, 0, 255), TRUE);
        //        SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
        //    }
        //    current_line++;
        //}

       int current_line = 0;
       for (auto it = clause_lines_.begin(); it != clause_lines_.end(); ++it) {
            auto line = *it;
            if (line.first < line.second) {
                SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);
                DrawBox(internal_x + line.first,
                        internal_y + current_line * font_height_,
                        internal_x + line.second,
                        internal_y + (current_line + 1) * font_height_,
                        GetColor(0, 255, 255), TRUE);
                SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
            }
            current_line++;
        }

        current_line = 0;
        candidate_x_ = -1, candidate_y_ = -1;
       for (auto it = selecting_clause_lines_.begin(); it != selecting_clause_lines_.end(); ++it) {
            auto line = *it;
            if (line.first < line.second) {
                SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);
                DrawBox(internal_x + line.first,
                        internal_y + current_line * font_height_,
                        internal_x + line.second,
                        internal_y + (current_line + 1) * font_height_,
                        GetColor(255, 0, 255), TRUE);
                SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);

                if (candidate_x_ < 0) {
                    candidate_x_ = line.first;
                    candidate_y_ = (current_line + 1) * font_height_;
                }
            }
            current_line++;
        }

        int text_color = reverse_color_ ? GetColor(255, 255, 255) : GetColor(0, 0, 0);
        current_line = 0;

        if (message_lines_.size() > 0) {
            for (auto it = message_lines_.begin(); it != message_lines_.end(); ++it) {
                auto line = *it;
                SetDrawBlendMode(DX_BLENDMODE_ALPHA, 140);
                DrawStringToHandle(internal_x,
                    internal_y + current_line * font_height_ - 3, line.c_str(),
                        text_color, font_handle_);
                SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
                current_line++;
            }
        }

        for (auto it = lines_.begin(); it != lines_.end(); ++it) {
            auto line = *it;
            DrawStringToHandle(internal_x, internal_y + current_line * font_height_,
                    line.c_str(), text_color, font_handle_);
            current_line++;
        }

        // カーソルを描画
        if (clause_lines_.size() <= 0 && active() && blink_count_ < 30) {
            DrawBox(internal_x + cursor_x_, internal_y + cursor_y_,
                    internal_x + cursor_x_ + 2,
                    internal_y + cursor_y_ + font_height_, text_color,
                    TRUE);
        }
    }

    {
        int internal_x = x_ + INPUT_MARGIN_X;
        int internal_y = y_ + INPUT_MARGIN_Y;

        if (selecting_candidate_ >= 0) {

            int start_index = (selecting_candidate_ / IME_MAX_PAGE_SIZE)
                    * IME_MAX_PAGE_SIZE;
            int end_index = std::min(start_index + IME_MAX_PAGE_SIZE,
                    static_cast<int>(candidates_.size() - 1));

            int x = candidate_x_;
            int y;
            int width = IME_MIN_WIDTH;
            int height = (end_index - start_index) * font_height_;

            for (int i = start_index; i < end_index; i++) {
                auto candidate = candidates_[i];
                width = std::max(width,
                        GetDrawStringWidthToHandle(candidate.c_str(),
                                candidate.size(), font_handle_));
            }

            int screen_height;
            GetScreenState(nullptr, &screen_height, nullptr);

            if (internal_y + height + candidate_x_ >= screen_height - IME_MARGIN_Y * 2) {
                y = candidate_y_ - font_height_ - height - IME_MARGIN_Y;
            } else {
                y = candidate_y_ + IME_MARGIN_Y;
            }

            if (height > 0) {
                int base_x = internal_x + x - IME_MARGIN_BASE;
                int base_y = internal_y + y - IME_MARGIN_BASE;
                int base_width = width + IME_MARGIN_BASE * 2;
                int base_height = height + IME_MARGIN_BASE * 2;

                DrawGraph(base_x, base_y, *ime_image_handle_[0], TRUE);
                DrawGraph(base_x + base_width - 12, base_y, *ime_image_handle_[1], TRUE);
                DrawGraph(base_x, base_y + base_height - 12, *ime_image_handle_[2], TRUE);
                DrawGraph(base_x + base_width - 12, base_y + base_height - 12,
                        *ime_image_handle_[3], TRUE);

                DrawRectExtendGraphF(base_x + 12, base_y, base_x + base_width - 12,
                        base_y + 12, 0, 0, 1, 12, *ime_image_handle_[1], TRUE);

                DrawRectExtendGraphF(base_x + 12, base_y + base_height - 12,
                        base_x + base_width - 12, base_y + base_height, 0, 0, 1, 12,
                        *ime_image_handle_[3], TRUE);

                DrawRectExtendGraphF(base_x, base_y + 12, base_x + 12,
                        base_y + base_height - 12, 0, 0, 12, 1, *ime_image_handle_[2],
                        TRUE);

                DrawRectExtendGraphF(base_x + base_width - 12, base_y + 12,
                        base_x + base_width, base_y + base_height - 12, 0, 0, 12, 1,
                        *ime_image_handle_[3], TRUE);

                DrawRectExtendGraphF(base_x + 12, base_y + 12, base_x + base_width - 12,
                        base_y + base_height - 12, 0, 0, 1, 1, *ime_image_handle_[3],
                        TRUE);
            }

            int line_top = 0;
            for (int i = start_index; i < end_index; i++) {
                if (i == selecting_candidate_) {
                    SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);
                    DrawBox(internal_x + x - 2,
                            internal_y + line_top + y,
                            internal_x + x + width + 2,
                            internal_y + line_top + y + font_height_,
                            GetColor(255, 0, 255), TRUE);
                    SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
                }
                DrawStringToHandle(internal_x + x,
                        internal_y + line_top + y,
                        candidates_[i].c_str(), GetColor(0, 0, 0),
                        font_handle_);
                line_top += font_height_;
            }
        }
    }
}
Exemple #24
0
	void VrmlGame::Draw3DFromVRML(openvrml::node *obj)
	{
		try
		{
			//可能抛出openvrml::unsupported_interface异常
			const openvrml::field_value &fv_appearance = obj->field("appearance");
			if (fv_appearance.type() == openvrml::field_value::sfnode_id)
			{
				//std::cout<<"appearance"<<std::endl;
				const openvrml::sfnode &sfn = dynamic_cast<const openvrml::sfnode&>(fv_appearance);
				openvrml::vrml97_node::appearance_node *vrml_app =
					static_cast<openvrml::vrml97_node::appearance_node*>(sfn.value.get()->to_appearance());
				const openvrml::node_ptr &vrml_material_node = vrml_app->material();
				const openvrml::node_ptr &vrml_texture_node = vrml_app->texture();

				const openvrml::vrml97_node::material_node *vrml_material =
					dynamic_cast<const openvrml::vrml97_node::material_node *>(vrml_material_node.get());
				if (vrml_material != NULL)
				{
					GLfloat temp_material_mat[4];
					temp_material_mat[0] = vrml_material->ambient_intensity();
					temp_material_mat[1] = vrml_material->ambient_intensity();
					temp_material_mat[2] = vrml_material->ambient_intensity();
					temp_material_mat[3] = 1.0;
					glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, temp_material_mat);
					temp_material_mat[0] = vrml_material->diffuse_color().r();
					temp_material_mat[1] = vrml_material->diffuse_color().g();
					temp_material_mat[2] = vrml_material->diffuse_color().b();
					temp_material_mat[3] = 1.0;
					glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, temp_material_mat);
					temp_material_mat[0] = vrml_material->emissive_color().r();
					temp_material_mat[1] = vrml_material->emissive_color().g();
					temp_material_mat[2] = vrml_material->emissive_color().b();
					temp_material_mat[3] = 1.0;
					glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, temp_material_mat);
					temp_material_mat[0] =vrml_material->specular_color().r();
					temp_material_mat[1] =vrml_material->specular_color().g();
					temp_material_mat[2] =vrml_material->specular_color().b();
					temp_material_mat[3] = 1.0;
					glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, temp_material_mat);
					glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, vrml_material->shininess());

					if (vrml_material->transparency() > 0.0f)
					{
						//设置透明性
					}
					else
					{

					}
					//std::cout<<"material"<<std::endl;
				}

				//bind texture
				const openvrml::vrml97_node::image_texture_node *vrml_texture = 
					dynamic_cast<const openvrml::vrml97_node::image_texture_node *>(vrml_texture_node.get());
				if (vrml_texture != 0)
				{
					const openvrml::field_value &texture_url_fv = vrml_texture->field("url");
					const openvrml::mfstring &mfs = dynamic_cast<const openvrml::mfstring &>(texture_url_fv);

					std::pair<set<std::string>::iterator, bool> ret;

					//修改后缀为bmp
					std::string url = mfs.value[0];
					std::string dot(".");
					std::size_t found;
					found = url.find(dot);
					if (found != std::string::npos)
					{
						std::string bmp("bmp");
						url.replace(found+1,3,bmp);
						ret = textureUrls.insert(url);
						//std::cout<< url.c_str() << std::endl;
					}
					if (ret.second == true)  //如果url插入成功了,即来了一个新的url,则设置isBindTexture,使得之后生成新的纹理
					{
						isBindTexture = false;
					}

					//即查找现在的url为第一个纹理
					int count = 0;
					for (std::set<std::string>::iterator it=textureUrls.begin(); it!=textureUrls.end(); it++,count++)
					{
						if (*it == *ret.first)
						{
							textureNum = count;
							//std::cout<< count << std::endl;
							break;
						}
					}
					//绑定纹理
					if (!isBindTexture)
					{
						glBindTexture(GL_TEXTURE_2D, texture[textureNum]);
						AUX_RGBImageRec *texImage;
						texImage = auxDIBImageLoad(url.c_str());

						if (texImage == NULL)
						{
							std::cout << "no texture file,please convert rgb file to bmp file"<< std::cout;
							return;
						}
						glTexImage2D(GL_TEXTURE_2D, 0, 3,texImage->sizeX, texImage->sizeY,
							0, GL_RGB, GL_UNSIGNED_BYTE, texImage->data);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

						if(texImage)
						{
							if(texImage->data)
							{
								free(texImage->data);
							}
							free(texImage);
						}
						//std::cout<< texture << std::endl;
						//std::cout<<"bind texture ok"<<std::endl;
						isBindTexture = true;
					}
					
					//读rgb文件有问题,暂时用bmp文件代替 
					//用read_texture函数返回的结果有问题,都是空格
					//int width = 180;
					//int height = 180;
					//int components = 4;
					//GLubyte *texels = (GLubyte *)read_texture(url.c_str(),&width,&height,&components);
					//std::cout<< url.c_str() << std::endl;
					//std::cout<< *read_texture(url.c_str(),&width,&height,&components) << std::endl;
				}
			}
		}
		catch(openvrml::unsupported_interface&)
		{

		}
		

		std::string name = obj->id();
		if (obj->type.id == "Group")
		{
			//std::cout<<"Group"<<std::endl;
			openvrml::vrml97_node::group_node *vrml_group;
			vrml_group = dynamic_cast<openvrml::vrml97_node::group_node *>(obj);

			try
			{
				const openvrml::field_value &fv = obj->field("children");

				if (fv.type() == openvrml::field_value::mfnode_id)
				{
					const openvrml::mfnode &mfn = dynamic_cast<const openvrml::mfnode &>(fv);
					for (unsigned int i=0; i<mfn.value.size(); i++)
					{
						openvrml::node *node = mfn.value[i].get();
						Draw3DFromVRML(node);
					}
				}
			}
			catch (openvrml::unsupported_interface&)
			{
				//no children
			}
		}
		else if (obj->type.id == "Transform")
		{
			//std::cout<<"Transform"<<std::endl;
			openvrml::vrml97_node::transform_node* vrml_transform;
			vrml_transform = dynamic_cast<openvrml::vrml97_node::transform_node*>(obj);

			openvrml::mat4f vrml_m = vrml_transform->transform();

			//opengl 添加转换
			glPushMatrix();
			GLfloat temp_trans[] = {vrml_m[0][0], vrml_m[0][1], vrml_m[0][2], vrml_m[0][3], vrml_m[1][0], vrml_m[1][1], vrml_m[1][2], vrml_m[1][3], vrml_m[2][0], vrml_m[2][1], vrml_m[2][2], vrml_m[2][3], vrml_m[3][0], vrml_m[3][1], vrml_m[3][2], vrml_m[3][3]};
			//glMultTransposeMatrixf(temp_trans);  
			glMultMatrixf(temp_trans);	//不需要转制,列优先

			//add 12.9
			glMatrixMode(GL_TEXTURE);
			glActiveTextureARB(GL_TEXTURE7);
			glPushMatrix();
			glMultMatrixf(temp_trans);
			try
			{
				const openvrml::field_value &fv = obj->field("children");

				if (fv.type() == openvrml::field_value::mfnode_id)
				{
					const openvrml::mfnode &mfn = dynamic_cast<const openvrml::mfnode &>(fv);
					for (unsigned int i=0; i<mfn.value.size(); i++)
					{
						openvrml::node *node = mfn.value[i].get();
						Draw3DFromVRML(node);
					}
				}
			}
			catch(openvrml::unsupported_interface&)
			{
				//no children
			}
			glPopMatrix();
			glMatrixMode(GL_MODELVIEW);
			glPopMatrix();
		}
		else if(obj->type.id == "Shape")
		{
			const openvrml::field_value &fv = obj->field("geometry");
			if (fv.type() == openvrml::field_value::sfnode_id)
			{
				const openvrml::sfnode &sfn = dynamic_cast<const openvrml::sfnode&>(fv);

				openvrml::vrml97_node::abstract_geometry_node* vrml_geom =
					static_cast<openvrml::vrml97_node::abstract_geometry_node*>(sfn.value.get()->to_geometry());

				if (openvrml::vrml97_node::indexed_face_set_node* vrml_ifs = dynamic_cast<openvrml::vrml97_node::indexed_face_set_node *>(vrml_geom))
				{
					DrawIndexedFaceSet(vrml_ifs);
				}
				else if (openvrml::vrml97_node::box_node* vrml_box = dynamic_cast<openvrml::vrml97_node::box_node*>(vrml_geom))
				{
					//opengl box
					//const openvrml::vec3f& size = static_cast<const openvrml::sfvec3f&>(vrml_box->field("size")).value;
					std::cout<<"box"<<std::endl;
					DrawBox(vrml_box);
				}
				else if (openvrml::vrml97_node::sphere_node* vrml_sphere = dynamic_cast<openvrml::vrml97_node::sphere_node*>(vrml_geom))
				{
					//sphere
					std::cout<<"sphere"<<std::endl;
					DrawSphere(vrml_sphere);
				}
				else if (openvrml::vrml97_node::cone_node* vrml_cone = dynamic_cast<openvrml::vrml97_node::cone_node*>(vrml_geom))
				{
					//cone
				}
				else if (openvrml::vrml97_node::cylinder_node* vrml_cylinder = dynamic_cast<openvrml::vrml97_node::cylinder_node*>(vrml_geom))
				{
					//cylinder
				}
				else
				{

				}
			}
		}
	}
Exemple #25
0
void CglList::Draw()
{
	// dont call Mouse[XY] if we're being used in CPreGame (when gu or mouse is still NULL)
	float mx = (gu && mouse) ? MouseX(mouse->lastx) : 0;
	float my = (gu && mouse) ? MouseY(mouse->lasty) : 0;

	glDisable(GL_TEXTURE_2D);
	glDisable(GL_ALPHA_TEST);
	glEnable(GL_BLEND);
	glLoadIdentity();
	glColor4f(0.2f,0.2f,0.2f,guiAlpha);
	DrawBox(box);

	font->Begin();

	font->SetTextColor(1,1,0.4f,0.8f);
	font->glPrint(box.x1 + 0.01f, box.y2 - 0.05f, itemFontScale*0.7f, FONT_SCALE | FONT_NORM, name);

	/****************************************
	* Insert Robert Diamond's section here *
	* <*****@*****.**> *
	****************************************/

	/****************************************
	* TODO: *
	* *
	* This part of the code will need some *
	* math, and it's been a while since I *
	* did any 3D coding... the idea is to *
	* keep the selected item in the middle *
	* 60% of the screen, but don't scroll *
	* till we reach one end, or the other *
	* of that boundary. We'd also need the *
	* "oldPlace" variable to do this *
	* properly. *
	* *
	****************************************
	// Get screen res, so that the selected item is always within the middle 60% of screen
	const int iResX = gu->viewSizeX;
	const int iResY = gu->viewSizeY;

	// Keep tabs on the last place. change this ONLY AFTER a scroll
	static int siOldPlace = place;

	if (we're scrolling up) siOldPlace = place;
	if (we're scrolling down) siOldPlace = place;
	if (we're not scrolling) siOldPlace = siOldPlace;

	**************************************
	* Hey remove me when TODO is done XD *
	**************************************/

	int nCurIndex = 0; // The item we're on
	int nDrawOffset = 0; // The offset to the first draw item
	ContainerBox b = box;

	b.x1 += 0.01f;
	b.x2 -= 0.01f;

	// Get list started up here
	std::vector<std::string>::iterator ii = filteredItems->begin();
	// Skip to current selection - 3; ie: scroll
	while ((nCurIndex + 7) <= place && nCurIndex+13 <= filteredItems->size()) { ii++; nCurIndex++; }

	font->SetTextColor(); //default
	font->SetOutlineColor(0.0f, 0.0f, 0.0f, 1.0f);
	for (/*ii = items.begin()*/; ii != filteredItems->end() && nDrawOffset < 12; ii++)
	{
		b.y2 = box.y2 - 0.06f - (nDrawOffset * 0.06f);
		b.y1 = b.y2 - 0.05f;

		// TODO lots of this should really be merged with GuiHandler.cpp
		// (as in, factor out the common code...)

		glColor4f(1,1,1,0.1f);
		DrawBox(b, GL_LINE_LOOP);

		if (nCurIndex == place) {
			glBlendFunc(GL_ONE, GL_ONE); // additive blending
			glColor4f(0.2f,0,0,1);
			DrawBox(b);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glColor4f(1,0,0,0.5f);
			glLineWidth(1.49f);
			DrawBox(b, GL_LINE_LOOP);
			glLineWidth(1.0f);
		} else if (InBox(mx, my, b)) {
			glBlendFunc(GL_ONE, GL_ONE); // additive blending
			glColor4f(0,0,0.2f,1);
			DrawBox(b);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
			glColor4f(1,1,1,0.5f);
			glLineWidth(1.49f);
			DrawBox(b, GL_LINE_LOOP);
			glLineWidth(1.0f);
		}

		const float xStart = box.x1 + itemXMargin;
		const float yStart = (b.y1 + b.y2) * 0.5f;

		font->glPrint(xStart, yStart, itemFontScale, FONT_VCENTER | FONT_SHADOW | FONT_SCALE | FONT_NORM, *ii);

		// Up our index's
		nCurIndex++; nDrawOffset++;
	}
	/**************
	* End insert *
	**************/

	font->End();
}
Exemple #26
0
// Update toolbar cache
BOOL GetToolBarCache(ToolBarInfo *toolbar,BOOL real)
{
	short depth,width,height,num,x,y;
	short last_width=0,last_height=0;
	Cfg_Button *button;
	struct TagItem tags[4];
	struct Rectangle rect;

	// Invalid toolbar?
	if (!toolbar) return 0;

	// Free existing cache
	FreeToolBarCache(toolbar);

	// Remap toolbar if this is for real
	if (real && !toolbar->done_remap)
	{
		// Do remap
		RemapToolBar(toolbar);
		toolbar->done_remap=1;
	}

	// Initialise tags
	tags[0].ti_Tag=IM_Depth;
	tags[0].ti_Data=1;
	tags[1].ti_Tag=IM_Width;
	tags[1].ti_Data=0;
	tags[2].ti_Tag=IM_Height;
	tags[2].ti_Data=0;
	tags[3].ti_Tag=TAG_DONE;

	// Minimum depth
	depth=1;

	// Count items in toolbar
	for (button=(Cfg_Button *)toolbar->buttons->buttons.lh_Head,toolbar->count=0;
		button->node.ln_Succ;
		button=(Cfg_Button *)button->node.ln_Succ,toolbar->count++);

	// Allocate position array
	if (!(toolbar->button_array=AllocVec(sizeof(struct Rectangle)*(toolbar->count+2),MEMF_CLEAR)))
	{
		FreeToolBarCache(toolbar);
		return 0;
	}

	// Go through buttons again
	for (button=(Cfg_Button *)toolbar->buttons->buttons.lh_Head,num=0,toolbar->max_width=0;
		button->node.ln_Succ;
		button=(Cfg_Button *)button->node.ln_Succ,num++)
	{
		Cfg_ButtonFunction *func;
		short width,height,x;

		// Get left button image
		if ((func=(Cfg_ButtonFunction *)
			FindFunctionType((struct List *)&button->function_list,FTYPE_LEFT_BUTTON)) &&
			func->image)
		{
			// Get depth and other info
			GetImageAttrs(func->image,tags);

			// Biggest depth so far?
			if (tags[0].ti_Data>depth)
				depth=tags[0].ti_Data;

			// Get size
			width=tags[1].ti_Data;
			height=tags[2].ti_Data;
		}

		// Or textual button?
		else
		if (!(button->button.flags&BUTNF_GRAPHIC) && func)
		{
			struct TextExtent extent;

			// Get length of label
			TextExtent(&GUI->screen_pointer->RastPort,func->label,strlen(func->label),&extent);

			// Get size
			width=extent.te_Width;
			height=extent.te_Height;
		}

		// Use last size
		else
		{
			width=last_width;
			height=last_height;
		}

		// Minimum size
		if (width<2) width=8;
		if (height<2) height=8;

		// Save size
		last_width=width;
		last_height=height;

		// Increase size for border
		if (!(toolbar->buttons->window.flags&BTNWF_BORDERLESS))
		{
			width+=2;
			height+=2;
		}

		// Biggest width so far?
		if (width>toolbar->max_width)
			toolbar->max_width=width;

		// Get last position
		x=(num>0)?toolbar->button_array[num-1].MaxX+1:0;

		// Store position in array
		toolbar->button_array[num].MinX=x;
		toolbar->button_array[num].MinY=0;
		toolbar->button_array[num].MaxX=x+width-1;
		toolbar->button_array[num].MaxY=height-1;
	}

	// No actual buttons?
	if (toolbar->count<1 || depth<1)
	{
		FreeToolBarCache(toolbar);
		return 0;
	}

	// Store rows/cols
	toolbar->cols=toolbar->count;
	toolbar->rows=1;

	// Valid toolbar arrow?
	if (GUI->toolbar_arrow_image)
	{
		short width,height;

		// Get size of the arrow button
		GetImageAttrs(GUI->toolbar_arrow_image,tags);

		// Biggest depth so far?
		if (tags[0].ti_Data>depth)
			depth=tags[0].ti_Data;

		// Get size
		width=tags[1].ti_Data;
		height=tags[2].ti_Data;

		// Increase size for border
		if (!(toolbar->buttons->window.flags&BTNWF_BORDERLESS))
		{
			width+=2;
			height+=2;
		}

		// Store size in array
		toolbar->button_array[toolbar->count].MaxX=width-1;
		toolbar->button_array[toolbar->count].MaxY=height-1;

		// Add to maximum width
		toolbar->max_width+=width;
	}

	// Get height of toolbar
	for (num=0,height=0;num<=toolbar->count;num++)
	{
		if ((width=RECTHEIGHT(&toolbar->button_array[num]))>height)
			height=width;
	}

	// Store toolbar height
	toolbar->button_height=height;

	// Get cache size
	toolbar->width=toolbar->button_array[toolbar->count-1].MaxX+1;
	toolbar->height=toolbar->button_height;

	// Don't want cache?
	if (!real) return 1;

	// Allocate cache bitmap
	if (!(toolbar->bitmap=
		NewBitMap(
			toolbar->width,
			toolbar->height,
			depth,
			BMF_CLEAR,
			GUI->screen_pointer->RastPort.BitMap)))
//			0)))
	{
		// Failed
		FreeToolBarCache(toolbar);
		return 0;
	}

	// Initialise RastPort
	InitRastPort(&toolbar->rp);
	toolbar->rp.BitMap=toolbar->bitmap;

	// Got cache successfully
	toolbar->cache=1;

	// Set pens and font
	SetAPen(&toolbar->rp,1);
	SetBPen(&toolbar->rp,0);
	SetFont(&toolbar->rp,GUI->screen_pointer->RastPort.Font);

	// Initialise draw tags
	tags[0].ti_Tag=IM_Rectangle;
	tags[0].ti_Data=(ULONG)&rect;
	tags[1].ti_Tag=IM_ClipBoundary;
	tags[1].ti_Data=(toolbar->buttons->window.flags&BTNWF_BORDERLESS)?0:2;
	tags[2].ti_Tag=IM_NoIconRemap;
	tags[2].ti_Data=(environment->env->desktop_flags&DESKTOPF_NO_REMAP)?TRUE:FALSE;
	tags[3].ti_Tag=TAG_DONE;

	// Go through buttons
	for (button=(Cfg_Button *)toolbar->buttons->buttons.lh_Head,x=0,y=0,num=0;
		button->node.ln_Succ;
		button=(Cfg_Button *)button->node.ln_Succ,num++)
	{
		Cfg_ButtonFunction *func;
		BOOL ok=0;

		// Get button rectangle
		rect=toolbar->button_array[num];

		// Get left button image
		if ((func=(Cfg_ButtonFunction *)FindFunctionType((struct List *)&button->function_list,FTYPE_LEFT_BUTTON)) &&
			func->image)
		{
			// Draw button image
			RenderImage(&toolbar->rp,func->image,0,0,tags);
			ok=1;
		}

		// Or textual button?
		else
		if (!(button->button.flags&BUTNF_GRAPHIC) &&
			func &&
			func->label && *func->label)
		{
			// Draw label
			Move(&toolbar->rp,x,y+toolbar->rp.TxBaseline);
			Text(&toolbar->rp,func->label,strlen(func->label));
			ok=1;
		}

		// Draw button border
		if (!ok || !(toolbar->buttons->window.flags&BTNWF_BORDERLESS))
			DrawBox(&toolbar->rp,&rect,GUI->draw_info,0);
	}

	return 1;
}
void Game_DollUniteManager::DrawUnitedDollStatus(int _x, int _y, BYTE _presetColorIndex, int _alpha) const{

	// 文字描画用
	TCHAR buf[32];
	TCHAR buf2[16];
	TCHAR buf3[16];

	int param = 0;
	int dltParam = 0;
	bool useParamBonus = false;

	// 枠の描画
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, _alpha*192/255);
	DrawBox(_x, _y, 
		_x+UNITEMANAGER_STATUS_WIDTH,
		_y+UNITEMANAGER_STATUS_HEIGHT, 
		GetColor(32,32,32), 1);
	
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, _alpha);

	/* // 名前無かった…。
	// 人形の名前の描画
	unitedCampDoll.DrawName(
		_x, _y,
		NAMECHAR_INFO, 
		GetPresetColor(_presetColorIndex, COLORSET_COLOR_NORMAL),
		ALIGN_CENTER, 460);
		*/

	// 人形の種類の描画
	DrawUnitedDollType(_x, _y+8, _presetColorIndex,
		ALIGN_CENTER, UNITEMANAGER_STATUS_WIDTH);

	// PLvの描画
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, _alpha);
	wsprintf(buf, _T("PLv:%4d"), unitedCampDoll.GetPLevel());
	DrawStringByPresetColor(
		_x + 150 + 0, _y + 40,
		buf, g_font.hInfo,
		_presetColorIndex, COLORSET_COLOR_NORMAL);

	// Lvの描画
	SetDrawBlendMode(DX_BLENDMODE_ALPHA, _alpha);
	wsprintf(buf, _T("Lv:%1d"), unitedCampDoll.GetLevel());
	DrawStringByPresetColor(
		_x + 280 + 0, _y + 40,
		buf, g_font.hInfo,
		_presetColorIndex, COLORSET_COLOR_NORMAL);


	SetDrawBlendMode(DX_BLENDMODE_ALPHA, _alpha);
	// ステータス項目の描画
	for(int n=0; n<DOLL_PARAM_MAX; n++){
		switch(n){
		case DOLL_PARAM_HP:
			strcpy_s(buf, 32-1, _T("最大HP:"));
			param = unitedCampDoll_NoBonus.GetMaxHP();
			dltParam = unitedCampDoll.GetMaxHP() - unitedCampDoll_NoBonus.GetMaxHP();
			break;
		case DOLL_PARAM_ATK:
			strcpy_s(buf, 32-1, _T("攻撃:"));
			param = unitedCampDoll_NoBonus.GetAtk();
			dltParam = unitedCampDoll.GetAtk() - unitedCampDoll_NoBonus.GetAtk();
			break;
		case DOLL_PARAM_SPD:
			strcpy_s(buf, 32-1, _T("敏捷:"));
			param = unitedCampDoll_NoBonus.GetSpd();
			dltParam = unitedCampDoll.GetSpd() - unitedCampDoll_NoBonus.GetSpd();
			break;
		case DOLL_PARAM_MGC:
			strcpy_s(buf, 32-1, _T("魔力:"));
			param = unitedCampDoll_NoBonus.GetMgc();
			dltParam = unitedCampDoll.GetMgc() - unitedCampDoll_NoBonus.GetMgc();
			break;
		case DOLL_PARAM_TEC:
			strcpy_s(buf, 32-1, _T("技巧:"));
			param = unitedCampDoll_NoBonus.GetTec();
			dltParam = unitedCampDoll.GetTec() - unitedCampDoll_NoBonus.GetTec();
			break;
		}
		useParamBonus = CheckBonusForParam(n);

		// 数字のコピー
		wsprintf(buf2, _T("%3d"), param);
		wsprintf(buf3, _T("+%d"), dltParam);

		if(n == DOLL_PARAM_HP){
			// 文字列の描画
			DrawStringByPresetColor(
				_x + 150 + 0,
				_y + UNITEMANAGER_STATUS_PARAM_Y + (FONTSIZE_INFO+4) * n,
				buf, g_font.hInfo,
				_presetColorIndex, COLORSET_COLOR_NORMAL);
			DrawStringByPresetColor(
				_x + 254 + 0,
				_y + UNITEMANAGER_STATUS_PARAM_Y + (FONTSIZE_INFO+4) * n,
				buf2, g_font.hInfo,
				_presetColorIndex, COLORSET_COLOR_NORMAL);
			if(useParamBonus){
				DrawStringByPresetColor(
					_x + 264 + 1.8*FONTSIZE_INFO,
					_y + UNITEMANAGER_STATUS_PARAM_Y + (FONTSIZE_INFO+4) * n,
					buf3, g_font.hInfo,
					_presetColorIndex, COLORSET_COLOR_POSITIVE);
			}
		}else{
			// 文字列の描画
			DrawStringByPresetColor(
				_x + 90 + 160 * ((n-1)%2),
				_y + UNITEMANAGER_STATUS_PARAM_Y + (FONTSIZE_INFO+4) * ((n-1)/2 + 1),
				buf, g_font.hInfo,
				_presetColorIndex, COLORSET_COLOR_NORMAL);
			DrawStringByPresetColor(
				_x + 160 + 160 * ((n-1)%2),
				_y + UNITEMANAGER_STATUS_PARAM_Y + (FONTSIZE_INFO+4) * ((n-1)/2 + 1),
				buf2, g_font.hInfo,
				_presetColorIndex, COLORSET_COLOR_NORMAL);
			if(useParamBonus){
				DrawStringByPresetColor(
					_x + 160 + 1.8*FONTSIZE_INFO + 160 * ((n-1)%2),
					_y + UNITEMANAGER_STATUS_PARAM_Y + (FONTSIZE_INFO+4) * ((n-1)/2 + 1),
					buf3, g_font.hInfo,
					_presetColorIndex, COLORSET_COLOR_POSITIVE);
			}
		}
	}

	// 描画を元に戻す
	SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
}
Exemple #28
0
void CQuitBox::Draw(void)
{
    float mx=MouseX(mouse->lastx);
    float my=MouseY(mouse->lasty);

    glDisable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glDisable(GL_ALPHA_TEST);

    // Large Box
    glColor4f(0.2f,0.2f,0.2f,guiAlpha);
    DrawBox(box);

    // resign Box on mouse over
    if(InBox(mx,my,box+resignBox)) {
        glColor4f(0.7f,0.2f,0.2f,guiAlpha);
        DrawBox(box+resignBox);
    }
    // save Box on mouse over
    if(InBox(mx,my,box+saveBox)) {
        glColor4f(0.7f,0.2f,0.2f,guiAlpha);
        DrawBox(box+saveBox);
    }
    // give away Box on mouse over
    if(InBox(mx,my,box+giveAwayBox)) {
        glColor4f(0.7f,0.2f,0.2f,guiAlpha);
        DrawBox(box+giveAwayBox);
    }
    // cancel Box on mouse over
    if(InBox(mx,my,box+cancelBox)) {
        glColor4f(0.7f,0.2f,0.2f,guiAlpha);
        DrawBox(box+cancelBox);
    }
    // quit Box on mouse over
    if(InBox(mx,my,box+quitBox)) {
        glColor4f(0.7f,0.2f,0.2f,guiAlpha);
        DrawBox(box+quitBox);
    }


    glColor4f(0.2f,0.2f,0.2f,guiAlpha);
    DrawBox(box+teamBox);

    if (hasScroll) {
        glColor4f(0.1f, 0.1f, 0.1f, guiAlpha);
        DrawBox(box + scrollbarBox);

        float sz = scrollbarBox.y2 - scrollbarBox.y1;
        float tsz = sz / (float)(MAX_QUIT_TEAMS);
        float psz = tsz * (float)numTeamsDisp;

        scrollBox.y2 = scrollbarBox.y2 - startTeam * tsz;
        scrollBox.y1 = scrollBox.y2 - psz;

        glColor4f(0.8f, 0.8f, 0.8f, guiAlpha);
        DrawBox(box + scrollBox);
    }

    glEnable(GL_TEXTURE_2D);
    glColor4f(1,1,0.4f,0.8f);
    font->glPrint(box.x1+0.045f,box.y1+0.58f,0.7f, FONT_VCENTER | FONT_SCALE | FONT_NORM,"Do you want to ...");
    glColor4f(1,1,1,0.8f);
    font->glPrint(box.x1 + resignBox.x1     + 0.025f,
                  box.y1 + (resignBox.y1 + resignBox.y2)/2, 1, FONT_VCENTER | FONT_SCALE | FONT_NORM, "Resign");
    font->glPrint(box.x1 + saveBox.x1   + 0.025f,
                  box.y1 + (saveBox.y1 + saveBox.y2)/2, 1, FONT_VCENTER | FONT_SCALE | FONT_NORM, "Save");
    font->glPrint(box.x1 + giveAwayBox.x1   + 0.025f,
                  box.y1 + (giveAwayBox.y1 + giveAwayBox.y2)/2, 1, FONT_VCENTER | FONT_SCALE | FONT_NORM, "Give everything to ...");
    font->glPrint(box.x1 + cancelBox.x1     + 0.025f,
                  box.y1 + (cancelBox.y1 + cancelBox.y2)/2, 1, FONT_VCENTER | FONT_SCALE | FONT_NORM, "Cancel");
    font->glPrint(box.x1 + quitBox.x1       + 0.025f,
                  box.y1 + (quitBox.y1 + quitBox.y2)/2, 1, FONT_VCENTER | FONT_SCALE | FONT_NORM, "Quit");

    int teamPos = 0;
    for(int team = startTeam; team < MAX_QUIT_TEAMS && teamPos < numTeamsDisp; ++team, ++teamPos) {
        int actualTeam=team;
        if (team >= gu->myTeam) {
            actualTeam++;
        }
        if (teamHandler->Team(actualTeam)->gaia) continue;

        if (shareTeam == actualTeam) {
            glColor4f(1,1,1,0.8f);
        } else {
            glColor4f(1,1,1,0.4f);
        }

        std::string teamName;
        if (teamHandler->Team(actualTeam)->leader >= 0)
            teamName = playerHandler->Player(teamHandler->Team(actualTeam)->leader)->name;
        else
            teamName = "uncontrolled";

        std::string ally, dead;
        if (teamHandler->Ally(gu->myAllyTeam, teamHandler->AllyTeam(actualTeam))) {
            ally = " <Ally>)";
        } else {
            ally = " <Enemy>";
        }
        if(teamHandler->Team(actualTeam)->isDead) {
            dead = " <Dead>";
        }
        if (actualTeam == teamHandler->GaiaTeamID()) {
            teamName = "Gaia";
            ally   = " <Gaia>";
        }
        font->glFormat(box.x1 + teamBox.x1 + 0.002f,
                       box.y1 + teamBox.y2 - 0.025f - teamPos * 0.025f, 0.7f,  FONT_SCALE | FONT_NORM,
                       "Team%i (%s)%s%s", actualTeam,
                       teamName.c_str(), ally.c_str(), dead.c_str());
    }
}
Exemple #29
0
// -----------------------------------------------------------
// Find nearest ray 2
// -----------------------------------------------------------
int KDTree::FindNearestToRay2( Ray& vRay, Vec3 &tmin, Vec3 &tmax, RayIntersectCallback callback, Matrix4x4 * temp )
{
	static bool bOutput = false;
	float tnear = 0;
	float tfar = ( tmax - tmin ).Length();
	int retval = 0;
	float D[3];
	float O[3];
	VecToFloatArray( vRay.m_Direction, D );
	VecToFloatArray( vRay.m_Origin, O );
	// We assume ray fits in extents
	// clip ray segment to box
	static AABB bbox;
	static int aa = 0;
	bbox.Set( tmin, tmax );
	if( !bbox.IntersectRay( vRay, tnear, tfar ) )
		return 0;
	if( tnear < 0 || 
		tfar < 0 || 
		tnear > tfar )
		return 0;
	stack< RayFindStruct > nodeStack;
	vector< KDTreeNode * > nodesToCheck;
	g_Boxes.clear();
	nodeStack.push( RayFindStruct( m_Root, tnear, tfar ) );
	while( nodeStack.size() > 0 )
	{
		RayFindStruct curSearch = nodeStack.top();
		nodeStack.pop();
		DrawBox( curSearch.node->bounds.m_Bounds[0], curSearch.node->bounds.m_Bounds[1], temp );
		
		while( curSearch.node->pntidx < 0 )//is not a leaf
		{
			int dim = curSearch.node->axis;
			float tSplit = (curSearch.node->key - O[dim]) / D[dim];
			KDTreeNode * first = m_Root + curSearch.node->leftIdx;
			KDTreeNode * second = m_Root + curSearch.node->rightIdx;
			//check dimension
			if( D[dim] < 0 )
			{
				//swap
				KDTreeNode * temp;
				temp = first;
				first = second;
				second = temp;
			}
			if( tSplit >= curSearch.tmax 
				//|| tSplit < 0 
				)
			{
				curSearch.node = first;
			}
			else 
				if( tSplit <= curSearch.tmin )
			{
				curSearch.node = second;
			}
			else
			{
				nodeStack.push( RayFindStruct( second, tSplit, curSearch.tmax ) );
				curSearch.node = first;
				curSearch.tmax = tSplit;
			}
			DrawBox( curSearch.node->bounds.m_Bounds[0], curSearch.node->bounds.m_Bounds[1], temp );
		}
		assert( curSearch.node != NULL );
		//check triangles
		nodesToCheck.push_back( curSearch.node );
		bool bresult = (*callback)( nodesToCheck );
		if( bresult )
		{
			return 1;
		}
		nodesToCheck.clear();
	}
	return 0;
	if( tnear == tfar )
	{
		return 0;
	}
	nodesToCheck.clear();
	nodesToCheck.push_back( m_Root );
	bool bresult = (*callback)( nodesToCheck );
	if( bresult )
	{
		if( g_Boxes.size() > 0 && aa < 5 
			&&
			vRay.m_Origin.z > 1000 )
		{
			OutputDebugString("RAYDEBUG START----------------------\n");
			for( int i = 0; i < (int)g_Boxes.size(); i++ )
			{
				static DWORD msgHash_AddAxisAlignedBox = CHashString(_T("AddAxisAlignedBox")).GetUniqueID();
				EngineGetToolBox()->SendMessage(msgHash_AddAxisAlignedBox,sizeof(g_Boxes[i]), &g_Boxes[i] );
				OutputDebugString("Box:\t");
				OutputVector(	g_Boxes[i].min, "Min" );
				OutputVector(	g_Boxes[i].max, "Max" );
			}
			g_Boxes.clear();
			aa++;
			static CHashString h(_T("none"));
			ADDLINEPARAMS LineParam;
			LineParam.name = &h;
			LineParam.start = (*temp)*vRay.m_Origin;
			LineParam.end =  vRay.m_Origin + vRay.m_Direction*10000;
			LineParam.end = (*temp)*LineParam.end;
			LineParam.red = 0;
			LineParam.blue = 0;
			LineParam.green = 255;
			static DWORD msgHash_AddLine = CHashString(_T("AddLine")).GetUniqueID();
			EngineGetToolBox()->SendMessage(msgHash_AddLine,sizeof(LineParam), &LineParam );
		}
        return 1;
	}
	return 0;
}
Exemple #30
0
void CTeris_1View::OnDraw(CDC* pDC)
{
	CTeris_1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	
	
	if( (  (CBox *)pDoc->box.GetAt(0)  )->isLive()){
		
		/*
		if((CBox *)pDoc->box.GetSize()!=0)
			DrawBox(pDC);
		else{
			
			DrawXX(pDC);
			
		}*/
		if(pDoc->mode!=XMXX)
			DrawBox(pDC);
		else{
		//	MessageBox("s");
			DrawXX(pDC);
			
		}

		
	}
	
	else{
		if(GetDocument()->score > this->topNum){
			SetRecord();
		}
		else{
			this->again();
		}
		
	}
	
	switch(GetDocument()->mode){
	case GK:
		GkCheck();
		break;
	case NORMAL:
		
		break;
	case QPZ:
		QPZCheck();
		break;
	case LIFE:
		break;
	case REVERSE:
		ReverseCheck();
		break;
	case CXY:
		
		CXYCheck();
		break;
	case XMXX:
		XMXXCheck();
		break;
		
	}
	
	
	
	
}