亚洲AV免费看深爱成人|日韩av另类一级特黄片在线|中国免费一级黄片|国产av一二三区|亚洲有码AV在线|久久亚洲国产日韩欧美|成人免费AV网站|婷婷一区综合一区|亚洲AV无码导航|高级欧美成人网站

高校合作1:010-59833514 ?咨詢(xún)電話(huà):400-810-1418 服務(wù)與監(jiān)督電話(huà):400-810-1418轉(zhuǎn)接2

c++框架游戲開(kāi)發(fā)(想學(xué)習(xí)C/C++來(lái)寫(xiě)游戲程序么?大神告訴你游戲框架怎么寫(xiě))

發(fā)布時(shí)間:2023-11-27 04:22:28 瀏覽量:121次

?想學(xué)習(xí)C/C++來(lái)寫(xiě)游戲程序么?大神告訴你游戲框架怎么寫(xiě)

c++框架游戲開(kāi)發(fā)(想學(xué)習(xí)C/C++來(lái)寫(xiě)游戲程序么?大神告訴你游戲框架怎么寫(xiě))

對(duì)這方面感興趣或者想學(xué)習(xí)C/C++可以加群:558502932,有問(wèn)題可以在群內(nèi)大家一起交流學(xué)習(xí)。

對(duì)于正在學(xué)習(xí)C/C++的同學(xué)或者朋友來(lái)說(shuō),如何用C/C++寫(xiě)程序都有些模糊的概念,畢竟如果只是學(xué)習(xí)C/C++的理論知識(shí),很多人甚至都不知道C/C++學(xué)了能干嘛。

有很多人都想去往游戲方面發(fā)展,畢竟能寫(xiě)出一個(gè)游戲供大家學(xué)習(xí)是一件特別自豪的事情。但是要寫(xiě)出一個(gè)游戲,不是那么容易的事情,今天我就來(lái)分享一下,我們講師寫(xiě)過(guò)的一個(gè)游戲框架,希望能對(duì)你們有所幫助。

對(duì)這方面感興趣或者想學(xué)習(xí)C/C++可以加群:558502932

代碼如下:

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//

// WindowsFrame.cpp: This is a Windows-Game Forms

// Author: MOYG

// Date: Dec-19-2015

// Version 1.0

//

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// INCLUDEs ////////////////////////////////////////////////////////////////////////////////////////////////////

#include "windows.h"

#include "time.h“

// DEFINES ////////////////////////////////////////////////////////////////////////////////////////////////////

#define WINDOW_WIDTH 800 //Window width of a macro definition

#define WINDOW_HEIGHT 600 //Window height of a macro definition

#define WINDOW_TITLE L"【潭州教育】程序核心框架" //The window title of marco definition

// GLOBALS /////////////////////////////////////////////////////////////////////////////////////////////////////

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam ); //The process window function

// WINMAIN /////////////////////////////////////////////////////////////////////////////////////////////////////

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)

{

//【1】 窗口創(chuàng)建四部曲之一:開(kāi)始設(shè)計(jì)一個(gè)完整的窗口類(lèi)

//【First】 One of the windows to create tetralogy:Start to design a whole window calss

WNDCLASSEX wndClass = { 0 }; //With WNDCALSSEX definition of a window class

wndClass.cbSize = sizeof(WNDCLASSEX); //Number of bytes to set up the structure size

wndClass.style = CS_HREDRAW | CS_VREDRAW; //Set the window style

wndClass.lpfnWndProc = WndProc; //Set the pointer to the window procedure function

wndClass.cbClsExtra = 0; //Additional memory window class

wndClass.cbWndExtra = 0; //Additional memory window

wndClass.hInstance = hInstance; //Specified contains the window handle to an instance of the process of program

//Local load custom ico

wndClass.hIcon = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);

wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); //Specifies the window handle of the cursor

wndClass.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); //The handle of Brush

wndClass.lpszMenuName = NULL; //Specify the menu resource

wndClass.lpszClassName = L"ForTheDreamOfGameDevelop";

//【2】窗口創(chuàng)建四部曲之二:注冊(cè)窗口類(lèi)

//【Second】 Second of the window to create tetralogy: RegisterClass

if (!RegisterClassEx(&wndClass))

return -1;

//【3】窗口創(chuàng)建四部曲之三:正式創(chuàng)建窗口

//【Third】 Third of the window to create tetralogy:Formal creation window

c++框架游戲開(kāi)發(fā)(想學(xué)習(xí)C/C++來(lái)寫(xiě)游戲程序么?大神告訴你游戲框架怎么寫(xiě))

HWND hwnd = CreateWindow(L"ForTheDreamOfGameDevelop",

WINDOW_TITLE, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,

WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL);

//【4】窗口創(chuàng)建四部曲之四:窗口移動(dòng)、顯示與更新

//【Four】 Fourth of the window to create tetralogy:Windows moblie,display and update

MoveWindow(hwnd, 250, 80, WINDOW_WIDTH, WINDOW_HEIGHT, true); //In the left corner of the window(250,70);

ShowWindow(hwnd,nShowCmd); //Display window

UpdateWindow(hwnd); //Update window

//【5】消息循環(huán)過(guò)程

//windows information rotation

MSG msg = { 0 }; //init msg

while (msg.message != WM_QUIT)

{

//查看應(yīng)用程序消息隊(duì)列,有消息時(shí)將隊(duì)列中消息派發(fā)出去

if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))

{

TranslateMessage(&msg); //將虛擬消息轉(zhuǎn)換為字符信息

DispatchMessage(&msg); //分發(fā)一個(gè)消息給窗口程序

}

}

//【6】窗口類(lèi)的注銷(xiāo)

//【Sixth】 logout window class

UnregisterClass(L"ForDearmOfGameClassDevelop", wndClass.hInstance);

return 0;

}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

switch (message)

{

case WM_PAINT: //重繪消息

ValidateRect(hwnd, NULL); //更新客戶(hù)的顯示

break;

case WM_KEYDOWN: //若是鍵盤(pán)按下任意鍵消息

if (wParam == VK_ESCAPE) //如果按下的是ESC鍵

DestroyWindow(hwnd); //銷(xiāo)毀窗口,并發(fā)送一條WM_DESTORY消息

break;

case WM_DESTROY: //若是窗口銷(xiāo)毀消息

PostQuitMessage(0); //像系統(tǒng)表示有個(gè)線(xiàn)程有終止請(qǐng)求,用來(lái)響應(yīng)WM_DESTROY消息

break;

default:

return DefWindowProc(hwnd, message, wParam, lParam); //調(diào)用默認(rèn)的窗口過(guò)程

}

return 0;

}

以上,就是游戲框架設(shè)計(jì)的源程序,希望對(duì)你們有所幫助,當(dāng)然,你們?nèi)绻信d趣可以運(yùn)行試試,如果有什么問(wèn)題,可以加群:558502932,把問(wèn)題發(fā)到群里,或者找群內(nèi)管理問(wèn)一下,會(huì)幫你解答的。

希望你們學(xué)習(xí)C/C++都能學(xué)有所成。

c++框架游戲開(kāi)發(fā)(想學(xué)習(xí)C/C++來(lái)寫(xiě)游戲程序么?大神告訴你游戲框架怎么寫(xiě))

熱門(mén)課程推薦

熱門(mén)資訊

請(qǐng)綁定手機(jī)號(hào)

x

同學(xué)您好!

您已成功報(bào)名0元試學(xué)活動(dòng),老師會(huì)在第一時(shí)間與您取得聯(lián)系,請(qǐng)保持電話(huà)暢通!
確定