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


C++ Snake::Draw方法代码示例

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


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

示例1: main

int main()
{
	sf::RenderWindow Window;
	Window.create(sf::VideoMode(900, 900), "Snake", sf::Style::Default);
	Window.setKeyRepeatEnabled(false);
	Snake *snake = new Snake();

	while (Window.isOpen())
	{
		sf::Event Event;

		while (Window.pollEvent(Event))
		{
			switch (Event.type)
			{
			case(sf::Event::Closed):
					Window.close();
				break;
			}
		}

		Window.clear();
		snake->Draw(Window);
		Window.display();
	}

	system("pause");
	return 0;
}
开发者ID:caldi5,项目名称:Snake,代码行数:29,代码来源:main.cpp

示例2: display

void display()
{
	glClearColor( 1, 1 , 1 , 0 );
	glClear( GL_COLOR_BUFFER_BIT );

	drawBG() ;
	if ( gameState == RUN ) {
	snake.Draw() ;
	food.Draw();
	} else if ( gameState == GAMEOVER ) {
		glColor3f(0,0,1) ;
		vprint2(-80, -180, 0.2, "GAME OVER" ) ;
	}
 
	glutSwapBuffers();
}
开发者ID:baturalppppp,项目名称:OpenGL,代码行数:16,代码来源:template.cpp

示例3: WndProc

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_CREATE:
		hdc = GetDC(hWnd);
		SetMapMode(hdc, MM_LOMETRIC);
		POINT p[1];
		p[0].x = 1000;
		p[0].y = -1000;
		LPtoDP(hdc, p, 1);
		DeleteDC(hdc);
		SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, p[0].x + 10, p[0].y + 52, NULL); //Padding na ramkê
		SetTimer(hWnd, TIMER, 25, (TIMERPROC)NULL);
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: Add any drawing code here...
		SetMapMode(hdc, MM_LOMETRIC);					//ustaw gruboϾ na 0,1 mm
		SelectObject(hdc, hPen);						//wybierz utworzone pióro
		snake.Draw(hdc);
		EndPaint(hWnd, &ps);
		break;
	case WM_USER:
		DeleteObject(hPen);								//usuñ pióro
		PostQuitMessage(0);
		break;
	case WM_TIMER:
		snake.Move();									//wykonaj ruch wê¿em
		RedrawWindow(hWnd,  NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_NOCHILDREN);	//i odœwie¿ okno
		break;
	case WM_DESTROY:
		DeleteObject(hPen);								//usuñ pióro
		PostQuitMessage(0);
		break;
	case WM_KEYDOWN:
		switch(wParam)
		{
		case VK_LEFT:
			snake.Turn(LEFT);
			break;
		case VK_RIGHT:
			snake.Turn(RIGHT);
			break;
		case VK_DOWN:
			PostMessage(HWND_BROADCAST, GORIGHT, 0, 0);
			break;
		default:
			break;
		}
		break;
	default:
		break;
	}
	if(message == GOLEFT)
	{
		snake.Add(wParam);
		snake.SetDirection(LEFT);
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}
开发者ID:kali11,项目名称:Winapi,代码行数:91,代码来源:WinApi.cpp


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