Beautify blog and summaries today

xiaoxiao2021-03-06  39

Plus a calendar with a calendar and a weather notice in Shenzhen before 12 o'clock. The practicality has grown a little bit. I just made the CGRAPH class to do it. Added a function of BLT, BLTFAST, and a function of CLS, CountFPS. Now Demo is a picture followed by mouse movement, and the FPS is 21 in window mode, and the full screen is about 40. Tomorrow I want to officially start the GUI interface part. First, the parent class COBJECT first, then inherit the first level ... COBJECT, CWND, CFORM, CControl, Clabel, CTextbox, Cbutton, Chscroll, Cvscroll, CMenu, CRADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CHADIO, CCHECKBOX, CMENU, CMESSAGEBOX ... Well, it seems to see beautiful Prospect ... Haha puts the code of cgraph. The 3 functions of the BLT may still have some Dongdong needs to be changed, and the lost page has not been processed. There is also the code of CGAME. By the way, where should I put it to deal with ...

//Graph.cpp#include "stdafx.h"

#include "./graph.h"

// Test page LPDIRECTDRAWSURFACE LPDDSZHAOYUN;

Cgraph :: CGRAPH (Void): M_WinHeight (0), M_WINWIDTH (0), M_ColorDepth (0), M_WINLEFT (0), M_wintop (0), m_nframes (0) {}

CGRAPH :: ~ cgraph (void) {}

// Initialize DirectDrawBool ​​CGRAPH :: Initddraw (int NWidth, Int NHEIGHT, INT NCOLORDEPTH, BOOL BFULLSCREEN) {IF (DirectDrawCreate (Null, & LPDD, NULL)! = DD_OK) Return False;

// Set CooperativeLevel DWORD dwFlags; if (bFullScreen) {dwFlags = DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT; this-> bIsWindowMode = false;} else {dwFlags = DDSCL_NORMAL; this-> bIsWindowMode = true;} if (lpDD-> SetCooperativeLevel (hWnd , dwflags)! = DD_OK) Return False;

// set displaymode m_winheight = nHEight; m_winwidth = nwidth;

If (! bfullscreen) {getwindowRect (hwnd, & review); Rectwin.top = 23;} else {recthwin.Left = 0; Rectwin.top = 0; Rectwin.bittom = NHEight; Rectwin.right = nWidth;}

M_ColorDepth = ncolorDepth; if (bfullscreen) IF (LPDD-> setDisplaymode (nwidth, nheight, ncolorDepth)! = dd_ok) Return False;

// set window style setWindowStyle ();

// init primary and back buffers ddsurfacedesc ddsd; hResult ddrval;

if (bFullScreen) {// Fullscreen modeZeroMemory (& ddsd, sizeof (ddsd)); ddsd.dwSize = sizeof (ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1;

// Create Primary Surface. Ddrval = LPDD-> CreateSurface (& DDSD, & LPDDSPRIMARY, NULL); if (DDRVAL! = DD_OK) RETURN FALSE

// Create Backbuffer Surface Ddsd.ddscaps.dwcaps = DDSCAPS_BACKBuffer; if (LPDDSPRIMARY-> GetAttachedSurface (& DDSD.DDSCAPS, & LPDDSBACK)! = DD_OK RETURN FALSE

} else {

// window mode ddsd.dwsize = sizeof (ddsd); ddsd.dwflags = ddsd_caps; ddsd.ddscaps.dwcaps = DDSCAPS_PRIMARYSURFACE;

// Create Primary Surface. IF (LPDD-> CreateSurface (& DDSD, & LPDDSPRIMARY, NULL)! = DD_OK) {Return False;}

// Create BackBuffer surface ZeroMemory (& ddsd, sizeof (ddsd)); ddsd.dwSize = sizeof (ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; ddsd.dwWidth = m_WinWidth; Ddsd.dwheight = m_winheight; if (LPDD-> CreateSurface (& DDSD, & LPDDSBACK, NULL)! = DD_OK) {Return False;}

// Set key color setColorKey (LPDDSBACK, RGB_32bit (255, 0, 255));

}

// Establish a crop CreateClipper ();

// Test page Initialization LPDDSZHAOYun = LoadBitmap (LPDD, "ZHAOYun.BMP", 0, 0); setColorKey (LPDDSBACK, RGB_32bit (255, 0)); setColorKey (LPDDSZHAOYUN, RGB_32bit (255, 0, 255));

Return True;

}

// Release DirectDraw object void cgraph :: freeddraw (void) {if (lpdd! = Null) {_RELEASE (lpddsback); _RELEASE (LPDDSPRIMARY); _RELEASE (LPDD);}

// Set the current display window style pattern matching bool CGraph :: SetWindowStyle (void) {if (this-> bIsWindowMode) {SetWindowLong (hWnd, GWL_EXSTYLE, WS_EX_OVERLAPPEDWINDOW); SetWindowLong (hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW & ~ WS_MAXIMIZEBOX); SetWindowPos ( hWnd, HWND_NOTOPMOST, 0,0, m_WinWidth, m_WinHeight, SWP_SHOWWINDOW | SWP_NOMOVE);} else {SetWindowLong (hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); SetWindowLong (hWnd, GWL_STYLE, WS_POPUP); SetWindowPos (hWnd, HWND_TOPMOST, 0,0, GetSystemMetrics ( SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), SWP_SHOWWINDOW);} return true;} // build clipper bool CGraph :: CreateClipper (void) {if (lpDD-> CreateClipper (0, & lpClipper, NULL) = DD_OK) {#ifdef! _Debug mytrace.write ("cgraph :: createclipper () CreateClipper error! / N"); #ndif returse;}

IF (lpclipper-> setwnd (0, hwnd)! = dd_ok) {#ifdef _debug myTrace.write ("cgraph :: createclipper () sethwnd error! / n"); #ndif returnaf false;}

IF (LPDDSPRIMARY-> SetClipper (LPCLIPPER)! = DD_OK) {#ifdef _debug mytrace.write ("cgraph :: createclipper () setClipper error! / n"); #ndif returnaf false;} return true;}

// Set key color HRESULT CGRAPH :: setColorKey * PDDS, ColorRef RGB) {DDCOLORKEY DDCK;

DDCK.DWCOLORSPACLOWVALUE = Colormatch (PDDS, RGB); DDCK.DWCOLORSPACEHIGHVALUE = DDCK.DWCOLORSPACLOWVALUE; RETURN PDDS-> SetColorKey (DDCKEY_SRCBLT, & DDCK);}

// Get the palette index of the specified color DWORD CGRAPH :: ColorMatch (iDirectdrawSurface * PDDS, ColorRef RGB) {ColorRef RGBT; HDC HDC; DWORD DW = CLR_INVALID; DDSURFACEDESC DDSD; HRESULT HRES;

IF (RGB! = CLR_INVALID && PDDS-> Getdc (& HDC) == DD_OK) {RGBT = getpixel (HDC, 0, 0); // Save the current value setpixel (HDC, 0, 0, RGB); PDDS-> ReleaseDC (HDC); DDSD.DWSIZE = SizeOf (DDSD); while ((hres = pdd, 0, null) == DDERR_WASSTILLDRAWING); if (hres == dd_ok) {dw = * ( DWORD *) DDSD.LPSURFACE; // Translate into DWORD DW & = (1 << DDSD.DDPFPixelformat.dwrgbbitcount) -1; // Mask It to bpp PDDS-> UNLOCK (NULL);}

IF (RGB! = CLR_INVALID && PDDS-> Getdc (& HDC) == DD_OK) {setpixel (HDC, 0, 0, RGBT); // Restore the original value PDDS-> ReleaseDC (HDC);

Return dw;}

// Create a Surface bmp images off-screen and loaded into the page IDirectDrawSurface * CGraph :: LoadBitmap (IDirectDraw * pdd, LPCSTR szBitmap, int dx, int dy) {HBITMAP hbm; BITMAP bm; DDSURFACEDESC ddsd; IDirectDrawSurface * pdds;

// First attempt to load HBM = (hbitmap) loadImage (getModuleHandle (NULL), SZBITMAP, Image_bitMap, DX, DY, LR_CREATEDIBSECTION); // Load IF (HBM == NULL) HBM = (HBitmap) ) LoadImage (null, szbitmap, image_bitmap, dx, dy, lr_loadfromfile | lr_createdibsection);

IF (hbm == null) Return NULL;

/ / Get image size getObject (HBM, SIZEOF (BM), & BM);

// Create Surface ZeroMemory (& ddsd, sizeof (ddsd)); ddsd.dwSize = sizeof (ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; ddsd.dwWidth = bm.bmWidth DDSD.DWHEIGHT = BM.BMHEIGHT;

IF (PDD-> CreateSurface (& DDSD, & PDDS, NULL)! = DD_OK) Return Null; // Create Surface Failed // Load Picture Copybitmap (PDDS, HBM, 0, 0, 0, 0); DeleteObject (HBM);

Return PDDS;

// Copy the bitmap to the target hbm SurfaceHRESULT CGraph :: CopyBitmap (IDirectDrawSurface * pdds, HBITMAP hbm, int x, int y, int dx, int dy) {HDC hdcImage; HDC hdc; BITMAP bm; DDSURFACEDESC ddsd; HRESULT hr;

IF (HBM == NULL || PDDS == NULL) RETURN E_FAIL;

PDDS-> restore ();

// Create a Memory Device Context HDCImage = CreateCompatibleDc (NULL) related to the current screen; if (! Hdcimage) OutputDebugstring ("CreateCompatible DC Failed / N); SelectObject (HDCIMAGE, HBM);

// Get BMP size getObject (HBM, SIZEOF (BM), & BM); DX = DX == 0? Bm.bmwidth: DX; // As long as the parameter specifies the size, use the specified size, otherwise the image default size DY = DY == 0? bm.bmheight: DY;

// Get the page size ddsd.dwsize = sizeof (ddsd); ddsd.dwflags = ddsd_height | DDSD_WIDTH; PDDS-> GetSurfaceDesc (& DDSD); if ((HR = PDDS-> Getdc (& HDC)) == DD_OK) {///// Zoom BLT Stretchblt (HDC, 0, 0, DDSD.dwwidth, ddsd.dwheight, hdcimage, x, y, dx, dy, srccopy); PDDS-> ReleaseDC (HDC);

Deletedc (HDCIMAGE);

Return hr;}

// Load a Bitmap to the page (and LoadBitmap difference is that this function does not create the Surface) HRESULT CGraph :: ReloadBitmap (IDirectDrawSurface * pdds, LPCSTR szBitmap) {HBITMAP hbm; HRESULT hr; // comments see LoadBitmap function, very close HBM = (HBitmap) loading (getModuleHandle (NULL), SZBITMAP, Image_bitMap, 0, 0, Lr_created;

IF (HBM == NULL) HBM = (hbitmap) loadImage (null, szbitmap, image_bitmap, 0, 0, lr_loadfromfile | lr_created); if (hbm == null) {char str [128]; Sprintf (STR, "Handle IS NULL [% s] / n ", szbitmap; outputdebugstring (str); return e_fail;}

HR = CopyBitmap (PDDS, HBM, 0, 0, 0, 0); if (HR! = DD_OK) {OutputDebugstring ("DDCopyBitmap Failed / N");}

DeleteObject (HBM); Return Hr;}

// Output string to the specified page position Void CGRAPH :: DDSPrint (iDirectdrawsurface * lpdds, int x, int y, char * szmsg, ...) {

VA_LIST VA; CHAR STR [512] = ""

VA_Start (Va, SZMSG); VSPrintf (STR, SZMSG, VA); VA_END (VA);

HDC DC; LPDDS-> GETDC (& DC); SetBKMode (DC, Transparent); SetTextColor (DC, RGB (255, 255, 255)); Textout (DC, X, Y, Str, (int) strlen (STR)); LPDDS-> ReleaseDC (DC);

}

// with the specified color fill target page void CGraph :: CLS (IDirectDrawSurface * lpDDS, DWORD color) {DDBLTFX ddbltfx; ddbltfx.dwSize = sizeof (ddbltfx); ddbltfx.dwFillColor = color; lpDDS-> Blt (NULL, NULL, NULL , DDBLT_COLORFILL, & DDBLTFX);} // Direct DC DC DC DC {CLS (LPDDSBACK, RGB_32bit (0, 0));} // Setting Window Coordinate Void CGRAPH :: Setwinpos (int NLEFT , int nTop) {RectWin.left = nLeft; RectWin.top = nTop; RectWin.right = RectWin.left m_WinWidth; RectWin.bottom = RectWin.top m_WinHeight;} // flip function, to the inverting BackBuffer PrimaryBuffervoid CGraph :: flip (void) {HRESULT DDRVAL; if (! Biswindowmode) {// full screen mode While (1) {ddrval = lpddsprimary-> flip (null, 0); if (ddrval == dd_ok) {Break;} IF DDRVAL == DDERR_SURFACELOST) {if (lpddsprimary) DDRVAL = lpddsprimary-> restore (); if (lpddsback) DDRVAL = LPDDSBACK DDRVAL = LPDDSBACK-> RESTORE (); // Do you want to reply to other pages? If (ddrval! = dd_ok) {Break }}}} (DDRVAL! = DDERR_WASSTILLDRAWING) {Break;}}} else {// window mode LPDDSPRIMARY-> BLT (& Rectwin, LPDDSBA CK, NULL, DDBLT_WAIT, NULL);} m_nframes ;} // Returns the current FPS value, add M_nframesint CGRAPH :: Countfps (void) {Static Long Old_Clock, Ret; Long New_Clock;

New_clock = timegettime (); if (new_clock> OLD_CLOCK 1000) {old_clock = new_clock; ret = m_nframes; m_nframes = 0;} Return Ret;} // will perform LPDDSSRC-> BLT (), and automatic adjustment according to the screen size Blt's parameters, without scaling HRESULT CGraph :: Blt (int x, int y, IDirectDrawSurface * lpDDSDest, LPRECT lpSrcRect, IDirectDrawSurface * lpDDSSrc, DWORD Flags) {HRESULT ddrval; LPRECT myRect; myRect = lpSrcRect; if (myRect == NULL ) {MyRect = New Rect;

/ / Get the size of the target surface DDSurfaceDesc DDSD; DDSD.DWSIZE = SizeOf (DDRVAL = LPDDSRC-> GetSurfaceDesc (& DDSD); if (DDRVAL! = DD_OK) Return DDRVAL; // Transfer the entire target surface as the target BLT area MyRect -> left = 0; myRect-> TOP = 0; myRect-> Right = ddsd.dwwidth; myRect-> Bottom = DDSD.DWHEIGHT;}

// Check the left and right boundary if (x <0) {// If the bLT coordinate <0 So the left boundaries of the target page area X-x pixels mYRect-> left = myRect-> left - x; x = 0 } Else if (x myRect-> Right - MyRect-> LEFT> m_winwidth) {// If the target area exceeds the boundary of the window, the target right boundary is shifted to the left X pixel myRect-> Right = MyRect- > left m_winwidth - x;}

/ / Check the up and down boundary if (Y <0) {// Principles the same myRect-> TOP = MyRect-> Top - Y; Y = 0;} else if (y myRect-> bottom - myRect-> TOP> m_winheight) {MyRect-> bottom = myRect-> TOP M_WINHEIGHT - Y;}

// Execute a BLT operation Rest Desinter; destRect.Light = x; destRect.right = x myRect-> Right - myRect-> Left; destRect.top = Y; destRect.bottom = y myRect-> bottom - myRect-> Top;

While (1) {DDRVAL = LPDDSDEST-> BLT (& DesTRect, LPDDSSRC, MyRect, Flags, NULL); if (DDRVAL == DD_OK) BREAK;

If (DDRVAL == DDERR_SURFACELOST) {// Page is lost, restore all pages. #ifdef _debug mytrace.write ("cgraph-> blt () surface lost error./N"); #ndif break;} if (DDRVAL! = DDERR_WASSTILLDRAWING) break;} if (lpSrcRect == NULL) _DELETE (myRect); return ddrval;} // Blt function with the similar parameters DDraw Blt same with scaling HRESULT CGraph :: Blt (LPRECT lpDestRect, IDirectDrawSurface * lpDDSDest, LPRECT LPSRCRECT, IDIRECTDRAWSURFACE * LPDDSSRC, DWORD FLAGS) {HRESULT DDRVAL; LPRECT MyRect; MyRect = LPSRCRECT; IF (MyRect == Null) {MyRect = New RECT;

/ / Get the size of the target surface DDSurfaceDesc DDSD; DDSD.DWSIZE = SizeOf (DDRVAL = LPDDSRC-> GetSurfaceDesc (& DDSD); if (DDRVAL! = DD_OK) Return DDRVAL; // Transfer the entire target surface as the target BLT area MyRect -> left = 0; myRect-> TOP = 0; myRect-> Right = ddsd.dwwidth; myRect-> Bottom = DDSD.DWHEIGHT;}

// Check the left and right boundary if (LPDESTRECT-> Left <0) {// If the bLT coordinates <0 So the left boundary of the target page area X pixels mYRect-> LEFT = MyRect-> Left - LPDESTRECT- > Left; LPDESTRECT-> LEFT = 0;} else if (LPDESTRECT-> LEFT MyRect-> Right - MyRect-> LEFT> M_WINWIDTH) {// If the target area exceeds the boundary of the window, the target right boundary is left. Move X Pixel MYRECT-> Right = MyRect-> Left M_WINWIDTH - LPDESTRECT-> LEFT;}

// Check the up and down boundary if (LPDESTRECT-> TOP <0) {// Principle is above myRect-> TOP = myRect-> top - lpdestRect-> top; lpdestRect-> TOP = 0;} else} else} MyRect-> bottom - myRect-> TOP> m_winheight) {myRect-> bottom = myRect-> TOP M_WINHEIGHT - LPDESTRECT-> TOP;}

// Execute BLT operation While (1) {ddrval = lpddsdest-> BLT (LPDESTRECT, LPDDSSRC, MyRect, Flags, NULL); if (DDRVAL == DD_OK) Break;

If (DDRVAL == DDERR_SURFACELOST) {// Page is lost, restore all pages. #ifdef _debug mytrace.write ("cgraph-> blt () surface lost error./N"); #ndif break;} if (DDRVAL! = DDERR_WASSTILLDRAWING) BREAK;} if (lpsrcRect == null) _Delete (myRect);} // will execute LPDDSDEST-> BLTFAST (), and automatically adjust the parameter of BLT in the screen size HRESULT CGRAPH :: BLTfast (int " x, int y, IDirectDrawSurface * lpDDSDest, LPRECT lpSrcRect, IDirectDrawSurface * lpDDSSrc, DWORD Flags) {HRESULT ddrval; LPRECT myRect; myRect = lpSrcRect; if (myRect == NULL) {myRect = new RECT;

// Get the size of the source surface DDSurfaceDesc DDSD; ddsd.dwsize = sizeof (ddsd); ddrval = lpddssrc-> getSurfaceDesc (& DDSD); if (DDRVAL! = DD_OK) Return DDRVAL; // Transfer the entire target surface as the target BLT area MyRect -> left = 0; myRect-> TOP = 0; myRect-> Right = ddsd.dwwidth; myRect-> Bottom = DDSD.DWHEIGHT;}

// Check the left and right boundary if (x <0) {// If the bLT coordinate <0 So the left boundaries of the target page area X-x pixels mYRect-> left = myRect-> left - x; x = 0 } If (x myRect-> Right - myRect-> LEFT> M_WINWIDTH) {// If the target area exceeds the boundary of the window, the target right boundary is shifted to the left X pixel myRect-> Right = myRect-> LEFT M_WINWIDTH - X;} // Check the upper and lower boundary IF (Y <0) {// Principles the same mYRect-> TOP = myRect-> Top - Y; Y = 0;} f (y myRect-> bottom - MyRect -> Top> m_winheight) {myRect-> bottom = myRect-> TOP M_WINHEIGHT - Y;} // Execute Bltfast Operation While (1) {DDRVAL = LPDDSDEST-> BLTFAST (X, Y, LPDDSRC, MyRect, Flags); IF (DDRVAL == DD_OK) Break;

If (DDRVAL == DDERR_SURFACELOST) {// page is lost, restore all pages. #ifdef _debug mytrace.write ("cgraph-> bltfast () Surface Lost Error./N"); #ENDIF BREAK;} if (DDRVAL! = DDERR_WASSTILLDRAWING) BREAK;} if (lpsrcRect == null) _delete (myRect); return ddrval;} // Function test function void cgraph :: test (void) {

Rect r; r.Left = 0; r.right = 200; r.top = 0; R.BOTTOM = 100;

Point P; getCursorpos (& P);

BltFast (p.x-RectWin.left, p.y-RectWin.top, lpDDSBack, NULL, lpDDSZhaoyun, DDBLTFAST_SRCCOLORKEY); //lpDDSBack->BltFast(p.x-RectWin.left, p.y-RectWin.top, lpDDSZhaoyun, NULL, DDBLTFAST_SRCCOLORKEY);

DDSPRINT (LPDDSBACK, 10, 16, "Current FPS:% D", Countfps ()); DDSPrint (LPDDSBACK, 10, 32, "Window Rect: (L:% D, R:% D) - (R:% D) , B:% D) ", Rectwin.right, Rectwin.bottom;} // game.cpp # incrude" stdafx.h "#include" ./game.h"#include " ./graph.h"#include "./global.h"#include" ./trace.h "

CGAME :: Cgame (Void): Bisrunning (false), bacTive (false), m_nwinwidth (0), m_nwinheight (0), m_bfullscreen (false), m_ncolordepth (0) {MyGraph = new cgraph (); BACTIVE = true;}

CGAME :: ~ cgame (void) {delete mygraph;}

// Initialization Game Variable Bool Cgame :: InitgameVariables (void) {m_nwinwidth = 800; m_nwinheight = 600; m_bfullscreen = true; m_ncolordepth = 24; Return true;}

// Start game int cgame :: start (void) {int RVAL; #ifdef _debug ctrace mytrace; mytrace.write ("------------------- ------------ / N "); MyTrace.write (" << New Instance Begin >> / N "); MyTrace.write (" --------- -------------------------- / n "); # Endif // Initialization Game Setting IITGAMEVARIABLES (); // Initializing DirectDraw IF ! myGraph-> InitDDraw (m_nWinWidth, m_nWinHeight, m_nColorDepth, m_bFullscreen)) {#ifdef _DEBUG myTrace.Write ( "Function call /" myGraph-> InitDDraw () / "Error./n"); #endif MessageBox (hWnd, " DirectDraw initialization failed. "," Error ", MB_OK; Return 0;}

// Start game bisrunning = true; rval = gameloop (); # ifdef _debug mytrace.write ("------ instance end. ------- / n"); # Endif Return RVAl;

}

// Game message loop HRESULT CGAME :: Gameloop (void) {

Msg msg; // char szdebug [200]; while (bisrunning) {if (PEEKMESSAG, NULL, 0, 0, PM_REMOVE) && msg.Message! = WM_PAINT) {if (msg.Message == WM_QUIT) {Bisrunning = false; // Exit the game Break;} TranslateMessage (& MSG); DispatchMessage (& MSG);} else if (bactage) {mainloop (); // Game main loop} else {waitmessage (); // Waiting message} // Sprintf (SZDebug, "MSG =% D, Active =% D / N", MSG.Message, Bactive); // outputdebugstring (szdebug);} // Return Msg.wParam; Return 0;} // Setting Whether Void CGAME :: SetActive (Bool Active) {BACTIVE = Active;}

// Game main loop, responsible for updating status, drawing page, response, etc. Void cgame :: mainloop (void) {MyGraph-> CLS (); // Cleaning buffer page / update data with black // // 1. Update Mouse coordinate / button status data // 2. Update keyboard input data // 3. Processing data / mouse command // / rendering scene / /// / 5 Patertaine scene map // 2. Patertranssenger, character // 3 GUI // / mygraph-> test (); // this test function simulates the painting process of buffer page

MYGRAPH-> flip (); // turn the page return;}

// End the game BOOL CGAME :: quit (void) {mygraph-> freeddraw (); return true;}

// Return to the game window width int CGAME :: getGamewInwidth (void) {return m_nwinwidth;}

// Return to the game window Height int CGAME :: getGamewinheight (void) {return m_nwinheight;}

/ / Pass to CGRAPH to make a flipping BLT area parameter in window mode Void CGAME :: setwinpos (INT NLEFT, INT NTOP) {MyGraph-> setwinpos (NLEFT, NTOP);

/ / Return to the full screen BOOL CGAME :: isfullscreen (void) {return m_bfullscreen;}

转载请注明原文地址:https://www.9cbs.com/read-58328.html

New Post(0)