void Bullet::initialize( int id, const Vector3& from, const Vector3& angle, const Robo* shooter, const Robo* opponent, bool is_homing) { assert(id >= 0); owner_id_ = id; age_ = 0; is_homing_ = is_homing; previous_point_ = from; current_point_ = from; if (!is_homing_) { Matrix44 rotation; rotation.rotate(angle); velocity_ = Vector3(0.0, 0.0, Speed0); rotation.multiply(&velocity_); } else { velocity_ = *opponent->center(); velocity_.subtract(from); velocity_.normalize(Speed0); } shooter_ = shooter; target_robo_ = opponent; }
//what to do when the image has to be draw void Game::render(void) { //set the clear color (the background color) glClearColor(0.0, 0.0, 0.0, 1.0); // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //set the camera as default camera->enable(); //set flags glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); //create model matrix for cube Matrix44 m; m.rotate(time, Vector3(0, 1, 0)); if(shader) { //enable shader shader->enable(); //upload uniforms shader->setUniform("u_color", Vector4(1,1,1,1)); shader->setUniform("u_viewprojection", camera->viewprojection_matrix ); shader->setUniform("u_texture", texture); shader->setUniform("u_model", m); shader->setUniform("u_time", time); //do the draw call mesh->render( GL_TRIANGLES ); //disable shader shader->disable(); } //Draw the floor grid drawGrid(); //render the FPS, Draw Calls, etc drawText(2, 2, getGPUStats(), Vector3(1, 1, 1), 2); //swap between front buffer and back buffer SDL_GL_SwapWindow(this->window); }