Разработка игры "Frag the monster"
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
llIncX;(x, y, z);(GL_TEXTURE_2D, 0);(GL_LIST_BIT);(base);(strlen(text), GL_UNSIGNED_BYTE, text);();
}InitGL(GLvoid)
{(!LoadGLTextures())
{FALSE;
}(GL_TEXTURE_2D);(GL_SRC_ALPHA, GL_ONE);(0.0f, 0.0f, 0.0f, 0.0f);(1.0f);(GL_LEQUAL);(GL_DEPTH_TEST);(GL_SMOOTH);(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);();();::GetInstance()->Initialize();.setX(0);.setZ(-27);.setH(-180);= 1;TRUE;
}DrawGLScene(GLvoid)
{(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);();::GetInstance()->Update();timesec = CTimer::GetInstance()->GetTimeMSec() / 1000.0;x_m, y_m, z_m, u_m, v_m;xtrans = -player.getX();ztrans = -player.getZ();;ytrans = -walkbias-0.25f;sceneroty = 360.0f - yrot;numtriangles;(lookupdown, 1.0f, 0, 0);(sceneroty, 0, 1.0f, 0);(xtrans, ytrans, ztrans);(int i = 0; i < 4; i++)
{= sector[i].numtriangles;(int loop_m = 0; loop_m < numtriangles; loop_m++)
{(GL_TEXTURE_2D, texture[sector[i].triangle[loop_m].texture]);(GL_TRIANGLES);f(0.0f, 0.0f, 1.0f);_m = sector[i].triangle[loop_m].vertex[0].x;_m = sector[i].triangle[loop_m].vertex[0].y;_m = sector[i].triangle[loop_m].vertex[0].z;_m = sector[i].triangle[loop_m].vertex[0].u;_m = sector[i].triangle[loop_m].vertex[0].v;f(u_m,v_m); glVertex3f(x_m,y_m,z_m);_m = sector[i].triangle[loop_m].vertex[1].x;_m = sector[i].triangle[loop_m].vertex[1].y;_m = sector[i].triangle[loop_m].vertex[1].z;_m = sector[i].triangle[loop_m].vertex[1].u;_m = sector[i].triangle[loop_m].vertex[1].v;f(u_m,v_m); glVertex3f(x_m,y_m,z_m);_m = sector[i].triangle[loop_m].vertex[2].x;_m = sector[i].triangle[loop_m].vertex[2].y;_m = sector[i].triangle[loop_m].vertex[2].z;_m = sector[i].triangle[loop_m].vertex[2].u;_m = sector[i].triangle[loop_m].vertex[2].v;f(u_m,v_m); glVertex3f(x_m,y_m,z_m);();
}
}(weapon.active) {(weapon.getX(), -0.2f, weapon.getZ());(weapon.rotate, 1.0f,1.0f,1.0f);(GL_TEXTURE_2D, 6);(GL_QUADS);f( 0.2f, 0.2f,-0.2f);f(-0.2f, 0.2f,-0.2f);f(-0.2f, 0.2f, 0.2f);f( 0.2f, 0.2f, 0.2f);f( 0.2f,-0.2f, 0.2f);f(-0.2f,-0.2f, 0.2f);f(-0.2f,-0.2f,-0.2f);
glVertex3f( 0.2f,-0.2f,-0.2f);f( 0.2f, 0.2f, 0.2f);f(-0.2f, 0.2f, 0.2f);f(-0.2f,-0.2f, 0.2f);f( 0.2f,-0.2f, 0.2f);f( 0.2f,-0.2f,-0.2f);f(-0.2f,-0.2f,-0.2f);f(-0.2f, 0.2f,-0.2f);f( 0.2f, 0.2f,-0.2f);f(-0.2f, 0.2f, 0.2f);f(-0.2f, 0.2f,-0.2f);f(-0.2f,-0.2f,-0.2f);f(-0.2f,-0.2f, 0.2f);f( 0.2f, 0.2f,-0.2f); f( 0.2f, 0.2f, 0.2f);f( 0.2f,-0.2f, 0.2f);f( 0.2f,-0.2f,-0.2f);();.rotate += 0.8f;
}();(lookupdown, 1.0f, 0, 0);(sceneroty, 0, 1.0f, 0);(xtrans, ytrans, ztrans);(GL_FRONT_AND_BACK, GL_FILL);(int i = 0; i DrawModel(timesec);(i == enemy_count-1);();(lookupdown, 1.0f, 0, 0);(sceneroty, 0, 1.0f, 0);(xtrans, ytrans, ztrans);
}(enemy_count && rand()00 setMove(player.getX(), player.getZ());
}();(GL_DEPTH_BUFFER_BIT);(-16.0f, 11.0f, -30.0f, "FPS: %2.2f", CTimer::GetInstance()->GetFps());();(player.charged) {(-8.0f, -6.0f, -15.0f, "ATTACK!");
} else {(-8.0f, -6.0f, -15.0f, "GET A CUBE!");
}();(6.7f, -7.0f, -20.0f, "LIFES: %d", player.lifes);();(6.7f, -8.0f, -20.0f, "FRAGS: %d", player.killed);(frag_timer > 0) {((frag_timer + 3) GetTimeMSec() / 1000.0))_timer = 0;{();(-1.0f, 1.0f, -10.0f, "FRAG!");
}
}(life_timer > 0) {((life_timer + 3) GetTimeMSec() / 1000.0))_timer = 0;{();(-2.1f, -1.0f, -10.0f, "LOST LIFE!");
}
}(game_over > 0) {((game_over + 3) GetTimeMSec() / 1000.0))_over = 666;{();(-2.9f, 0.0f, -6.0f, "GAME OVER");
}
}(win > 0) {((win + 3) GetTimeMSec() / 1000.0))= 666;{();(-2.0f, -0.1f, -6.0f, "YOU WIN!");
}
}(start > 0) {((start + 5) GetTimeMSec() / 1000.0))= 0;{();(-10.0f, 5.0f, -19.0f, "FIND THE CUBE, THEN FRAG THE MONSTER!");();(-4.0f, -4.0f, -23.0f, "FRAG 5 MONSTERS");();();(-10.5f, -5.0f, -20.0f, "DON'T GET HIT BY THE MONSTER, OR YOU DIE!");
}
}true;
}KillGLWindow(GLvoid)
{(fullscreen)
{(NULL,0);(TRUE);
}(hRC)
{(!wglMakeCurrent(NULL,NULL))
{(NULL,(LPCWSTR)L"Release Of DC And RC Failed.",(LPCWSTR)L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}(!wglDeleteContext(hRC))
{(NULL,(LPCWSTR)L"Release Rendering Context Failed.",(LPCWSTR)L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}= NULL;
}(hDC && !ReleaseDC(hWnd,hDC))
{(NULL,(LPCWSTR)L"Release Device Context Failed.",(LPCWSTR)L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);= NULL;
}(hWnd && !DestroyWindow(hWnd))
{(NULL,(LPCWSTR)L"Could Not Release hWnd.",(LPCWSTR)L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);= NULL;
}(!UnregisterClass((LPCWSTR)L"OpenGL",hInstance))
{(NULL,(LPCWSTR)L"Could Not Unregister Class.",(LPCWSTR)L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);= NULL;
}
}CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{;;;;;.left= (long)0;.right= (long)width;.top= (long)0;.bottom= (long)height;= fullscreenflag;= GetModuleHandle(NULL);.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;.lpfnWndProc= (WNDPROC) WndProc;.cbClsExtra= 0;.cbWndExtra= 0;.hInstance= hInstance;.hIcon= LoadIcon(NULL, IDI_WINLOGO);.hCursor= LoadCursor(NULL, IDC_ARROW);.hbrBackground= NULL;.lpszMenuName= NULL;.lpszClassName= (LPCWSTR)L"OpenGL";(!RegisterClass(&wc))
{(NULL,(LPCWSTR)L"Failed To Register The Window Class.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}(fullscreen)
{dmScreenSettings;(&dmScreenSettings,0,sizeof(dmScreenSettings));.dmSize= sizeof(dmScreenSettings);.dmPelsWidth= width;.dmPelsHeight= height;.dmBitsPerPel= bits;.dmFields= DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{(MessageBox(NULL,(LPCWSTR)L"Полноэкранный режим не поддерживается вашей видеокартой\nЗапустить в оконном режиме?",(LPCWSTR)L"Внимание",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{= FALSE;
}
{(NULL,(LPCWSTR)L"Программа будет закрыта",(LPCWSTR)L"ERROR",MB_OK|MB_ICONSTOP);FALSE;
}
}
}(FALSE);(fullscreen)
{= WS_EX_APPWINDOW;= WS_POPUP;
} else {= WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;= WS_OVERLAPPEDWINDOW;
}(&WindowRect, dwStyle, FALSE, dwExStyle);if (!(hWnd=CreateWindowEx(dwExStyle,(LPCWSTR)L"OpenGL",
(LPCWSTR)L"Frag The Monster", dwStyle |WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0,WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top,NULL,NULL,hInstance,NULL)))
{();(NULL,(LPCWSTR)L"Ошибка создания окна.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}pfd=
{sizeof(PIXELFORMATDESCRIPTOR),1,PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, bits,
, 0, 0, 0, 0, 0, 0,0,0,0, 0, 0, 0,16,0,0,PFD_MAIN_PLANE,0,0, 0, 0
};(!(hDC = GetDC(hWnd)))
{();(NULL,(LPCWSTR)L"Can't Create A GL Device Context.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}(!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))
{();(NULL,(LPCWSTR)L"Can't Find A Suitable PixelFormat.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}(!SetPixelFormat(hDC,PixelFormat,&pfd))
{();(NULL,(LPCWSTR)L"Can't Set The PixelFormat.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}(!(hRC=wglCreateContext(hDC)))
{();(NULL,(LPCWSTR)L"Can't Create A GL Rendering Context.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}(!wglMakeCurrent(hDC,hRC))
{();(NULL,(LPCWSTR)L"Can't Activate The GL Rendering Context.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}(hWnd,SW_SHOW);(hWnd);(hWnd);(width, height);(!InitGL())
{();(NULL,(LPCWSTR)L"Initialization Failed.",(LPCWSTR)L"ERROR",MB_OK|MB_ICONEXCLAMATION);FALSE;
}TRUE;
}DI_Init()
{( DirectInput8Create( hInstance,_VERSION,_IDirectInput8,
(void**)&g_DI,) )
{(false);
}( g_DI->CreateDevice( GUID_SysKeyboard,
&g_KDIDev,) )
{(false);
}( g_KDIDev->SetDataFormat(&c_dfDIKeyboard) )
{(false);
}( g_KDIDev->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) )
{(false);
}(g_KDIDev)_KDIDev->Acquire();(false);(true);
}DX_End()
{(g_DI)
{(g_KDIDev)
{_KDIDev->Unacquire();_KDIDev->Release();_KDIDev = NULL;
}_DI->Release();_DI = NULL;
}
}CALLBACK WndProc(HWNDhWnd,UINTuMsg,WPARAMwParam, LPARAM lParam)
{(uMsg)
{WM_ACTIVATE:
{(!HIWORD(wParam))
{= TRUE;
}
{= FALSE;
}0;
}WM_SYSCOMMAND:
{(wParam)
{SC_SCREENSAVE:SC_MONITORPOWER:0;
};
}WM_CLOSE:
{(0);0;
}WM_SIZE:
{(LOWORD(lParam),HIWORD(lParam));0;
}
}DefWindowProc(hWnd,uMsg,wParam,lParam);
}WINAPI WinMain(HINSTANCEhInstance, HINSTANCEhPrevInstance, LPSTRlpCmdLine, intnCmdShow)
{;= false;(MessageBox(NULL,(LPCWSTR)L"Запуст