void moveAI(world *gWorld) { int x = 0, y = 0, move; box tmpbox = gWorld->ais[0].box; int length = calculateLengthToMove(tmpbox, gWorld->ais[0].direction); if ((abs(startx - gWorld->ais[0].box.x)) < MAX_X) { switch (gWorld->ais[0].direction) { case left : x -= length; tmpbox.x += x; break; case right : x += length; tmpbox.x += x; break; } printf("Try to move AI to coordinate [%d, %d]\n", tmpbox.x, tmpbox.y); move = moveObjects(gWorld, tmpbox, -1, -1, x, y); if (move == -1) { gWorld->ais[0].box = tmpbox; } else { swithDirection(gWorld); } } else { swithDirection(gWorld); } }
int main(void) { GLFWwindow* window; //WskaŸnik na obiekt reprezentuj¹cy okno std::cout << "lol"<<std::endl; glfwSetErrorCallback(error_callback);//Zarejestruj procedurê obs³ugi b³êdów if (!glfwInit()) { //Zainicjuj bibliotekê GLFW fprintf(stderr, "Nie mo¿na zainicjowaæ GLFW.\n"); exit(EXIT_FAILURE); } window = glfwCreateWindow(700, 700, "OpenGL", NULL, NULL); //Utwórz okno 500x500 o tytule "OpenGL" i kontekst OpenGL. if (!window) //Je¿eli okna nie uda³o siê utworzyæ, to zamknij program { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); //Od tego momentu kontekst okna staje siê aktywny i polecenia OpenGL bêd¹ dotyczyæ w³aœnie jego. glfwSwapInterval(1); //Czekaj na 1 powrót plamki przed pokazaniem ukrytego bufora glfwSetKeyCallback(window, key_callback); if (glewInit() != GLEW_OK) { //Zainicjuj bibliotekê GLEW fprintf(stderr, "Nie mo¿na zainicjowaæ GLEW.\n"); exit(EXIT_FAILURE); } initOpenGLProgram(window); //Operacje inicjuj¹ce float angle = 0; //K¹t obrotu torusa glfwSetTime(0); //Wyzeruj licznik czasu initTargets(); //G³ówna pêtla while (!glfwWindowShouldClose(window)) //Tak d³ugo jak okno nie powinno zostaæ zamkniête { //std::cout << glfwGetTime()<<std::endl; ship.moveCamera(glfwGetTime(), nextMove); rotateTargets(glfwGetTime()); addObjects(); moveObjects(); checkForCollision(); glfwSetTime(0); drawScene(window,angle); //Wykonaj procedurê rysuj¹c¹ glfwPollEvents(); //Wykonaj procedury callback w zaleznoœci od zdarzeñ jakie zasz³y. //Wyzeruj licznik czasu } glfwDestroyWindow(window); //Usuñ kontekst OpenGL i okno glfwTerminate(); //Zwolnij zasoby zajête przez GLFW exit(EXIT_SUCCESS); }
void TinyGameLibrary::mainLoop() { m_run = true; while (m_run) { SDL_RenderClear(m_renderer); readKeys(); moveObjects(); renderLevel(); SDL_RenderPresent(m_renderer); SDL_Delay(1000 / 30); } }
int MyDirectXWindow::run() { init(); // Main message loop MSG msg = { 0 }; while (WM_QUIT != msg.message) { if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { //clean render target float clearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; mDeviceContext->ClearRenderTargetView(mRenderTargetView, clearColor); //clean depthStencil Buffer mDeviceContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); //setup Camera mCamera.renderSetup(mDeviceContext); //randomic Translation to each object moveObjects(); //render Objects renderObjects(); //swap buffers mSwapChain->Present(0, 0); } } return msg.wParam; }
void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glLoadIdentity (); /* clear the matrix */ /* viewing transformation */ gluLookAt (cam.eye[0], cam.eye[1], cam.eye[2], cam.look[0] + cam.eye[0], cam.look[1] + cam.eye[1], cam.look[2] + cam.eye[2], cam.up[0], cam.up[1],cam.up[2]); moveObjects(); // collisionsSphereBottom(); collSpherePlanes(); drawObjects(); glPushMatrix(); glPopMatrix(); glutSwapBuffers(); }
void Pong::play() { draw(); moveObjects(); }
MoveObjectsCommand* MoveObjectsCommand::moveEntity(Model::MapDocument& document, Model::Entity& entity, const Vec3f& delta, bool lockTextures) { Model::EntityList entities; entities.push_back(&entity); return moveObjects(document, entities, Model::EmptyBrushList, delta, lockTextures); }