https://blog.csdn.net/tzheng2008/article/details/7257446 位操作 c++reference不知道怎么搜 沃日
看的什么gamedevelopment cookbook
源码 gayhub https://github.com/hablocher/cppgamedevcookbook
pretty cool huh? both you guys are idiots But thanks anyway
https://blog.csdn.net/willtom/article/details/24740305 stringstream用法,其实就是个string流
and its member function .i saw this in the book and figure out what the following means
std::stringstream theStream ;
theStream<<_value<<std::ends;
std::ends enables the _values to be a string.
string ToString(const T& _value) |
{ |
strstream theStream; |
theStream << _value << ends; |
return (theStream.str()); |
}
LRESULT CALLBACK WindowProc(HWND _hwnd, UINT _msg, WPARAM _wparam, LPARAM _lparam)
{
// This is the main message handler of the system.
PAINTSTRUCT ps; // Used in WM_PAINT
HDC hdc; // Handle to a device context
if ((GetAsyncKeyState(VK_LEFT) & 0x8000) == 0x8000)
IS_LEFT_PRESSED = TRUE; else IS_LEFT_PRESSED = FALSE;
if ((GetAsyncKeyState(VK_RIGHT) & 0x8000) == 0x8000)
IS_RIGHT_PRESSED = TRUE; else IS_RIGHT_PRESSED = FALSE;
if ((GetAsyncKeyState(VK_UP) & 0x8000) == 0x8000)
IS_UP_PRESSED = TRUE; else IS_UP_PRESSED = FALSE;
if ((GetAsyncKeyState(VK_DOWN) & 0x8000) == 0x8000)
IS_DOWN_PRESSED = TRUE; else IS_DOWN_PRESSED = FALSE;
still don't understand why this shit use &operator probably the state is binary
switch (_msg)
{
case WM_CREATE:
{
// Do initialization stuff here.
// Return success
return(0);
}
break;
case WM_PAINT:
{
// Simple validate the window
hdc = BeginPaint(_hwnd, &ps); //yeh,you 've got permission
InvalidateRect(_hwnd, g_prect, FALSE); //shits!
string temp;
int iYDrawPos = 15; // i guess this is where the mouse cursor starts?
int iXDrawPos = 30;
COLORREF red = RGB(255, 0, 0); // i prefer light green
SetTextColor(hdc, red); //you love that red, right?
LPCWSTR a;
temp = "MOUSE X: "; //start moving that mouse cursor
temp += ToString((g_pos.x));
while (temp.size() < 14) //why 14 my friend? probably a pixel 's height or width?
{
temp += " ";
}
TextOut(hdc, iXDrawPos, iYDrawPos, wstring(temp.begin(), temp.end()).c_str(), static_cast<int>(temp.size())); //time to check out the static_cast
iYDrawPos += 13;
temp = "MOUSE Y: ";
temp += ToString((g_pos.y));
while (temp.size() < 14)
{
temp += " ";
}
TextOut(hdc, iXDrawPos, iYDrawPos, wstring(temp.begin(), temp.end()).c_str(), static_cast<int>(temp.size()));
iYDrawPos += 13;
string text = "";
if (IS_LEFT_PRESSED == TRUE) text = "LEFT IS PRESSED"; else text = "LEFT IS NOT PRESSED";
TextOut(hdc, iXDrawPos, iYDrawPos, wstring(text.begin(), text.end()).c_str(), text.length());
iYDrawPos += 13;
if (IS_RIGHT_PRESSED == TRUE) text = "RIGHT IS PRESSED"; else text = "RIGHT IS NOT PRESSED";
TextOut(hdc, iXDrawPos, iYDrawPos, wstring(text.begin(), text.end()).c_str(), text.length());
iYDrawPos += 13;
if (IS_DOWN_PRESSED == TRUE) text = "DOWN IS PRESSED"; else text = "DOWN IS NOT PRESSED";
TextOut(hdc, iXDrawPos, iYDrawPos, wstring(text.begin(), text.end()).c_str(), text.length());
iYDrawPos += 13; //why do iYDrawPos add 13 ?why not x coordinate?
if (IS_UP_PRESSED == TRUE) text = "UP IS PRESSED"; else text = "UP IS NOT PRESSED";
TextOut(hdc, iXDrawPos, iYDrawPos, wstring(text.begin(), text.end()).c_str(), text.length());
TextOut(hdc, static_cast<int>(200 + (sin(ang) * 200)), static_cast<int>(200 + (sin(ang) * 200)), L"O", 1);
EndPaint(_hwnd, &ps);
// Return success
return(0);
}
break;
wtf is that ? 丢?alright I ' fucking calm down.huh?
let me exlain that line by line
pretty cool huh?
"validate the windows" that sounds wierd ,cause validate 在我中文中像一个犯人被validate一样,but anyway validate 也有确认的意思。it's like someone just get permission to do some shits.
let's look above ,I just find out I can command on that scripts and that's awsome.
点击打开链接 static 和dynamic cast的异同 为了看的懂这个异同 我又要去看一下虚函数
https://www.zhihu.com/question/23971699 虚函数的解释,看了那个大一的小朋友的解释我终于懂了,God damn it!跟之前的cherno的解释差不多
case WM_MOUSEMOVE:
{
GetCursorPos(&g_pos); //here we go
// Here is your coordinates
int x = g_pos.x;
int y = g_pos.y;
return(0);
}
先发表吧,emmm