Tham khảo tài liệu 'c++ programming for games module ii phần 8', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | provides another function which can give us a handle to a device context associated with a window s client area the function is called GetDC Get a DC associated with the window s client area. HDC hWndDC GetDC mhWnd The GetDC function takes a parameter to a window handle hwnd which specifies the window with which we want to associate the device context. The GetDC function then returns a handle to such a device context. Tank Animation Sample Figure shows a screenshot of the Tank animation sample we will write in this section. Figure A screenshot of the Tank sample. The tank is drawn using a rectangle for the tank base an ellipse for the gun base and a thick line . pen width 1 for the gun. You can move the tank up and down and from side to side with the W S A and D keys. You can rotate the gun with the Q and E keys. Finally you can fire bullets with the spacebar key. The bullets are modeled using ellipses. 220 Be aware that this program uses a 2D vector class called Vec2. This class is remarkably similar to the Vector3 class we developed in Chapter 7 so please take a moment to review the vector mathematics discussed in that chapter if you do not recall the concepts. We will be using vectors to determine directions. For example we will need to determine the direction a bullet should travel. In addition we will sometimes interpret the components of vectors as points. Before we begin an analysis of the tank program let us first look at the global variables the program uses the comments explain their purpose HWND HINSTANCE HMENU ghMainWnd 0 Main window handle. ghAppInst 0 Application instance handle. ghMainMenu 0 Menu handle. The backbuffer we will render onto. BackBuffer gBackBuffer 0 The text that will appear in the main window s caption bar. string gWndCaption Game Institute Tank Sample Client rectangle dimensions we will use. const int gClientWidth 800 const int gClientHeight 600 Center point of client rectangle. const POINT gClientCenter .