예제 #1
0
void animation_loop(GtkWidget *darea)
{
	Init_Session();
	Game_Counter=0;

	do
	{   /* loop on number of games here */
		Init_Game();
//		Reset_Screen(cr); // Moved to set initial vals
		Loop_Counter=0;
		do
		{
			gtk_widget_queue_draw(darea);
			while(gtk_events_pending())
			{
    		gtk_main_iteration_do(TRUE); // Redraw the frame
			}
		}
		while(!Restart_Flag&&!End_Flag&&(Loop_Counter < One_Game_Loops));
		Initialized_Graphics = 0;
		Game_Counter++;
//		printf("Died, restart ? %d end? %d \n", Restart_Flag, End_Flag);
		// Close_Graphics(cr); // Not sure if closing is appropiate (it's impossible to close
		// in this part of the program because we don't have acces to GTK cairo context)
	}
	while(!Restart_Flag && !End_Flag);

	// And the clean up here (close graphics)
}
예제 #2
0
Game::Game():
running(true),
game_status(MENU),
screen(NULL),
map(NULL) 
{
	Init_Game();
	
	
}
예제 #3
0
int main(void)
{
    struct BadgeState *game_state;
    char sample_i = 0, sample_val = 0;

    InitializeSystem();

    #if defined(USB_INTERRUPT)
        USBDeviceAttach();
    #endif

    #if defined(GAME_MODE)
        game_state = Init_Game();
    #endif
    while(1)
    {
        if((play_count & 0x0fff) && play_count & 0x8000)
        {
            //LATBbits.LATB2 = 1;
            //LATBbits.LATB3 = 1;

            getNextSample( &sample_i, &sample_val);
            LATAbits.LATA9 = sample_val;
            play_count++;
        }
        else
            play_count = play_count & 0x8000;

        #if defined(USB_POLLING)
		// Check bus status and service USB interrupts.
        USBDeviceTasks(); // Interrupt or polling method.  If using polling, must call
        				  // this function periodically.  This function will take care
        				  // of processing and responding to SETUP transactions 
        				  // (such as during the enumeration process when you first
        				  // plug in).  USB hosts require that USB devices should accept
        				  // and process SETUP packets in a timely fashion.  Therefore,
        				  // when using polling, this function should be called 
        				  // regularly (such as once every 1.8ms or faster** [see 
        				  // inline code comments in usb_device.c for explanation when
        				  // "or faster" applies])  In most cases, the USBDeviceTasks() 
        				  // function does not take very long to execute (ex: <100 
        				  // instruction cycles) before it returns.
        #endif
    				  

		// Application-specific tasks.
		// Application related code may be added here, or in the ProcessIO() function.
        ProcessIO();
    #if defined(GAME_MODE)
         Run_Game(&game_state);
        //welcome(game_state);
    #endif
    }//end while
}//end main
예제 #4
0
Game::Game():
running(true),
game_status(MENU),
App(NULL),
map(NULL),
textureManager(NULL)
{
	Init_Game();
	
	
}
예제 #5
0
void set_initial_vals()
{
	Loop_Counter = 0;
	intv_t1 = 0;
	intv_t2 = 0;
	t0 = 0;
	jitter_switch = 1;
//	Terminal_State = 0;
	Init_Game();
	// Select_Mine_Menus();

//	cairo_path_t *empty_path = cairo_copy_path(cr);
//	PrevShip = empty_path;
//	for(int i = 0; i < MAX_NO_OF_MISSILES; i++)
//	{
//		PrevMissile[i] = empty_path;
//	}
	Reset_Screen();

}
예제 #6
0
///////ウインドウプロシージャ関数//////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	// 画像を読み込む準備
	HDC hdc;		// デバイスコンテキストハンドル
	PAINTSTRUCT ps; // ペイント構造体

	// バックバッファ用コンテキストハンドルと、ビットマップハンドルの準備
	static HDC hdc_back;	// 裏画面(バックバッファ)用デバイスコンテキストハンドル
	static HBITMAP hb_back;	// 裏画面(バックバッファ)用ビットマップハンドル

	switch (msg)
	{


	case WM_USER + 1:	// ゲームループ(SendMessageから呼ばれる)

		// 結果の再描画 WM_PAINTを実行する
		InvalidateRect(hWnd, NULL, false);
		return 0;

	case WM_PAINT:	// 画面を描画する時の処理

		hdc = BeginPaint(hWnd, &ps);	// 描画の開始
		Paint(hdc_back);				// Paint関数へ

		//バックバッファに保存された画像を表画面に描画
		BitBlt(hdc, 0, 0, 1100, 500, hdc_back, 0, 0, SRCCOPY);




		EndPaint(hWnd, &ps);			// 描画の終了
		return 0;

	case WM_CREATE:


		Init_Game();

		// 描画の開始
		hdc = GetDC(hWnd);
		// 互換デバイスコンテキストの作成
		hdc_back = CreateCompatibleDC(hdc);
		// 互換ビットマップの作成
		hb_back = CreateCompatibleBitmap(hdc, 1100, 500);
		// オブジェクトの選択
		SelectObject(hdc_back, hb_back);
		// 描画の終了
		ReleaseDC(hWnd, hdc);

		// ビットマップハンドルに画像データを読み込み保存しておく
		//シーン
		title_hb = (HBITMAP)LoadImage(NULL, TEXT("title.bmp"), IMAGE_BITMAP,
			0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		end_hb = (HBITMAP)LoadImage(NULL, TEXT("end.bmp"), IMAGE_BITMAP,
			0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		player_hb = (HBITMAP)LoadImage(NULL, TEXT("player.bmp"), IMAGE_BITMAP,
			0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		//キャラクター
		hb_Player = (HBITMAP)LoadImage(NULL, TEXT("Player.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk_Right = (HBITMAP)LoadImage(NULL, TEXT("run1_right.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk2_Right = (HBITMAP)LoadImage(NULL, TEXT("run2_right.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk3_Right = (HBITMAP)LoadImage(NULL, TEXT("run3_right.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk4_Right = (HBITMAP)LoadImage(NULL, TEXT("run4_right.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk_Left = (HBITMAP)LoadImage(NULL, TEXT("run1_left.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk2_Left = (HBITMAP)LoadImage(NULL, TEXT("run2_left.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk3_Left = (HBITMAP)LoadImage(NULL, TEXT("run3_left.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Walk4_Left = (HBITMAP)LoadImage(NULL, TEXT("run4_left.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Jump = (HBITMAP)LoadImage(NULL, TEXT("Jump.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
		hb_Tackl = (HBITMAP)LoadImage(NULL, TEXT("Tackl.bmp"),
			IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
	


		return 0;

	case WM_DESTROY:	// 最後にウインドウが閉じられた時の処理
		// デバイスコンテキストの解放
		DeleteDC(hdc_back);
		// オブジェクトの解放 
		DeleteObject(hb_back);
		DeleteObject(title_hb);
		DeleteObject(end_hb);
		PostQuitMessage(0);
		return 0;

	default:	// デフォルト処理
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}
}
예제 #7
0
int GameLoop()
{

    Init_Game();

    SDL_Event e;

    MM_Load();

    while(!Quit)
    {
        while(SDL_PollEvent(&e))
        {
            if(e.type == SDL_TEXTINPUT && TI_FLAG == true)
            {
                Returntext.push_back(*e.text.text);
                TI_Update_Text();
                break;
            }
            else if(e.type == SDL_MOUSEBUTTONDOWN)
            {
                double x = e.button.x;
                double y = e.button.y;
                double ax = (x / RES_WIDTH) * 1920;
                double ay = (y / RES_HEIGHT) * 1080;

                for(int y = Button_Stack.size() - 1; y >= 0; y--)
                {
                    for(int x = Button_Stack[y]->size() - 1; x >= 0; x--)
                    {
                        if(ax > Button_Stack.at(y)->at(x)->x && ax < Button_Stack.at(y)->at(x)->x + Button_Stack.at(y)->at(x)->w)
                        {
                            if(ay > Button_Stack.at(y)->at(x)->y && ay < Button_Stack.at(y)->at(x)->y + Button_Stack.at(y)->at(x)->h)
                            {
                                if(Button_Stack.at(y)->at(x)->type == BASIC)
                                {
                                    Button_Stack.at(y)->at(x)->funct();
                                    x = 0;
                                    y = 0;
                                }
                                else if(Button_Stack.at(y)->at(x)->type == LIST)
                                {
                                    Button_Stack.at(y)->at(x)->funct2(Button_Stack.at(y)->at(x)->L_Pos);
                                    x = 0;
                                    y = 0;
                                }
                                else if(Button_Stack.at(y)->at(x)->type == GRID)
                                {
                                    Button_Stack.at(y)->at(x)->funct3(Button_Stack.at(y)->at(x)->G_PosX, Button_Stack.at(y)->at(x)->G_PosY);
                                    x = 0;
                                    y = 0;
                                }
                            }
                        }
                    }
                }
            }
            else if(e.type == SDL_QUIT)
            {
                Quit = true;
            }
            else if(e.type == SDL_KEYDOWN && Key_Stack.size() > 0)
            {
                for(int x = 0; x < Key_Stack.size(); x++)
                {
                    if(Key_Stack.at(x)->input == e.key.keysym.sym)
                        Key_Stack.at(x)->funct();
                }
            }
        }

        for(int x = 0; x < Tx_Stack.size(); x++)
        {
            for(int y = 0; y < Tx_Stack[x]->size(); y++)
            {
                RenderTexture(Tx_Stack[x]->at(y));
            }
        }

        RenderTexture(wally);

        for(int x = 0; x < Text_Stack.size(); x++)
        {
            for(int y = 0; y < Text_Stack[x]->size(); y++)
            {
                RenderTexture(Text_Stack[x]->at(y));
            }
        }

        for(int x = 0; x < Funct_Stack.size(); x++)
        {
            Funct_Stack[x]();
        }

        SDL_RenderPresent(ren);
        SDL_RenderClear(ren);

        SDL_Delay(16);
    }


    App_Quit();


    return 0;
}