void mykeyboard1(unsigned char k, int x, int y) { float m; int abc; int l; float xxx; abc=(int)k; // printf("%d",abc); if(abc==32) { m=(b1-b3)/(a1-a3); glBegin(GL_LINES); glColor3f(1.0f,1.0f,1.0f); glVertex2i(a3,b3); xxx=a3-((b3-480)/m); glVertex2i(xxx,480); glEnd(); glFlush(); polygon1(a1,b1,a2,b2,a3,b3,a4,b4); for(l=0;l<90000000;l++); for(l=0;l<5;l++) { /* if(((cir[l].y+cir[l].rr)<b3)&&((cir[l].x+cir[l].rr)>a2)&&((((cir[l].x-cir[l].rr)>a2)&&((cir[l].x-cir[l].rr)<a4))||(((cir[l].x+cir[l].rr)>a2)||((cir[l].x+cir[l].rr)<a4)))) */ /* { */ /* lose=1; */ /* } */ // if(((cir[l].y-cir[l].rr)<480)&&(xxx<((cir[l].x)+cir[l].rr))&&(xxx>((cir[l].x)-cir[l].rr))) if((pdistance(cir[l].x,cir[l].y,a3,b3,xxx,480)-cir[l].rr)<0) { init1(l); if(lose==0) score=score+10; } } } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Creating window WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); if (!RegisterClassEx(&wcex)) { return 1; } hInst = hInstance; hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL ); if (!hWnd) { return 1; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Win32 init finished contextPtr = r2d::CreateRenderContext(hWnd); contextPtr->Init(); factoryPtr = contextPtr->GetFactory(); cameraPtr = factoryPtr->CreateCamera(Rect(-400.0f, -300.0f, 400.0f, 300.0f)); // Init graphics //std::auto_ptr<r2d::IMaterial> graphicMaterialPtr = factoryPtr->CreateMaterial( //) //factoryPtr->CreateGraphicObject( // Init physics p2d::Material material; p2d::BodyInitialMotion motion; Polygon2d polygon1(Rect(-300.0f, -50.0f, 300.0f, 0.0f)); ; Polygon2d polygon2; polygon2 << vec2(-200.0f, -200.0f) << vec2(-180.0f, -300.0f) << vec2(-100.0f, -250.0f) << vec2(0.0f, -300.0f) << vec2(100.0f, -100.0f) << vec2(200.0f, -250.0f); polygon2 += vec2(-200.0f, 90.0f); motion.m_angle = 0.2f; physicsBodies.push_back( std::auto_ptr<p2d::IBody>(new p2d::SimpleBody( *physicsWorld, std::auto_ptr<p2d::IShape>(new p2d::PolygonShape(polygon1, material)), p2d::IBody::ptStatic, material, motion )) ); motion.m_angle = 0.0f; physicsBodies.push_back( std::auto_ptr<p2d::IBody>(new p2d::SimpleBody( *physicsWorld, std::auto_ptr<p2d::IShape>(new p2d::ChainShape(polygon2, material)), p2d::IBody::ptStatic, material, motion )) ); material.m_restitution = 0.5f; motion.m_position = vec2(0.0f, 300.0f); physicsBodies.push_back( std::auto_ptr<p2d::IBody>(new p2d::SimpleBody( *physicsWorld, std::auto_ptr<p2d::IShape>(new p2d::CircleShape(Circle(40.0f, vec2(0.0f, 0.0f)), material)), p2d::IBody::ptDynamic, material, motion )) ); material.m_restitution = 1.0f; motion.m_position = vec2(100.0f, 300.0f); physicsBodies.push_back( std::auto_ptr<p2d::IBody>(new p2d::SimpleBody( *physicsWorld, std::auto_ptr<p2d::IShape>(new p2d::CircleShape(Circle(10.0f, vec2(0.0f, 0.0f)), material)), p2d::IBody::ptDynamic, material, motion )) ); physicsJoints.push_back( std::auto_ptr<p2d::IJoint>(new p2d::LengthJoint( *physicsWorld, physicsBodies[2], physicsBodies[3], physicsBodies[2].GetPosition() + vec2(0.0f, 15.0f), physicsBodies[3].GetPosition() + vec2(0.0f, 5.0f) )) ); // // //boost::thread* renderThread = new boost::thread(renderScene); // Dispatching messages MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); renderScene(); } complete = true; //renderThread->join(); contextPtr->Deinit(); // Exit return (int) msg.wParam; }