当前位置: 首页>>代码示例>>C++>>正文


C++ Text::Init方法代码示例

本文整理汇总了C++中Text::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Text::Init方法的具体用法?C++ Text::Init怎么用?C++ Text::Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Text的用法示例。


在下文中一共展示了Text::Init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* args[]) {

	//initialize SDL_ttf
	if (TTF_Init() == -1) {
		cerr << "TTF_Init: " << TTF_GetError() << endl;
//exit(2);
	}

	SDL_Texture* backGroundTexture; // the new SDL_Texture variable
	SDL_Texture* backimageTexture;
// *****************



	SDL_Init( SDL_INIT_EVERYTHING);

	//Create window
	g_pWindow = SDL_CreateWindow("Easy_Rider", SDL_WINDOWPOS_UNDEFINED,
	SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);

	//Create Renderer
	g_pRenderer = SDL_CreateRenderer(g_pWindow, -1, SDL_RENDERER_ACCELERATED);

	//Load image from specified path
	SDL_Surface* loadedSurface = IMG_Load("image/background.png");

	//Create texture from surface pixels
	backGroundTexture = SDL_CreateTextureFromSurface(g_pRenderer,
			loadedSurface);

	SDL_Surface* riderSurface = SDL_LoadBMP("image/rider.bmp");

	//Color key image
	SDL_SetColorKey(riderSurface, SDL_TRUE,
			SDL_MapRGB(riderSurface->format, 102, 204, 255));

	//Create texture from surface pixels
	backimageTexture = SDL_CreateTextureFromSurface(g_pRenderer, riderSurface);

	//SDL_Rect rectRider = {320, 0, riderSurface->w};

// flipping a image
	Text txt;
	txt.Init(g_pRenderer);

	SDL_RenderClear(g_pRenderer);


	bool gamerunning = true;
	SDL_Event event;

	//	game loop
	while (gamerunning) {

		if (SDL_PollEvent(&event)!= 0) {
			if (event.type == SDL_QUIT)
				gamerunning = false;
		}
			SDL_RenderClear(g_pRenderer);
					SDL_RenderCopy(g_pRenderer, backGroundTexture, 0, 0);
					txt.Draw(g_pRenderer);
			        txt.UpDate(event);
					SDL_RenderPresent(g_pRenderer);



	}

	SDL_RenderPresent(g_pRenderer);

	//SDL_Delay(2000);

	return 0;
}
开发者ID:miroslavavramov,项目名称:Memory-Game,代码行数:74,代码来源:TextRendering.cpp

示例2: WinMain

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	dInstance = hInstance;
	// Windows structure
	WNDCLASSEX wcex;
	ZeroMemory(&wcex, sizeof(wcex));

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = dInstance;
    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName   = NULL;
    wcex.lpszClassName  = "gameDemoWindow";
    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

	// register a new type of window
	if (!RegisterClassEx(&wcex))
    {
        MessageBox(
        NULL,
        "Window Error",
        "Could not create window",
        NULL);
    }

	static TCHAR szWindowClass[] = "gameDemoWindow";
	static TCHAR szTitle[] = "Game Demo";

	hWnd = CreateWindow(
		szWindowClass,
		szTitle,
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, CW_USEDEFAULT,
		1920, 1080,
		NULL,
		NULL,
		dInstance,
		NULL);


	// Display the window
	ShowWindow(hWnd,nCmdShow);
	UpdateWindow(hWnd);

	int width;
	int height;
	bool windowed;

	

	
	//create engine, using MainCore
	MainCore* main_core = new MainCore();
	main_core->Startup(hWnd);

	//create pointer to access each core through MainCore
	AISystem* ai_core = main_core->GetAIManager();
	Sound* sound_core = main_core->GetAudioCoreSound();
	SoundEffect* sfx_core = main_core->GetAudioCoreSoundEffect();
	PhysicsInterface* physics_core = main_core->GetPhysicsManager();
	Input* input_core = main_core->GetInputManager();
	UI* ui_core = main_core->GetUIManager();
	ScriptingCore* script_core = main_core->GetScriptManager();
	EntityManager* entity_core = main_core->GetEntityManager();
	Clock* clock_manager = main_core->GetClock();

	width = script_core->width;
	height = script_core->height;
	windowed = true;
	Init(width, height);
	/*
	TO DO IN CASE 2
	setup UI and Graphics for game logic
	*/
	//load music stream
	sound_core->Load("Song1.ogg");
	//load sound effect
	sfx_core = new SoundEffect("Jump.wav"); //#5 to play
			
	//variables used for entity setups
	LPCSTR fileName;
	float pos[3];
	float rot[3];
	float scale[3];
	for(int i = 0; i < 3; i++)
	{
		pos[i] = 0;
		rot[i] = 0;
		scale[i] = .1;
	}
	rot[0] = 180;

	//setup for player
	//DO SOMETHING HERE
	Entity* player;
//.........这里部分代码省略.........
开发者ID:GSP420,项目名称:Engine,代码行数:101,代码来源:main.cpp

示例3: TextInit

    void TextInit(DWORD size, LPDIRECT3DDEVICE9 device) {

        text->Init(size, device);

    }
开发者ID:GSP420,项目名称:Graphics-Core,代码行数:5,代码来源:CoreManager.cpp


注:本文中的Text::Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。