void glut_key_action(unsigned char key, int x, int y) { switch (key) { case 'q': case 27: exit(0); case 's': save_image(-1); break; case 'r': recording ^= 1; if (recording) printf("Recording ON\n"); else printf("Recording OFF\n"); break; case ',': case '+': animating = 0; step_forward(); break; case '.': case '-': animating = 0; step_back(); break; case ' ': animating = !animating; break; case '<': animating = 1; dt = -tStep; break; case '>': animating = 1; dt = tStep; break; } }
void ghost::update_position(level l){ xpos += xvel; ypos += yvel; while (collides_with_map(l)){ step_back(); //std::cout << "colliding" << std::endl; //std::cout << "vel " << xvel << " " << yvel << std::endl; //std::cout << "pos " << xpos << " " << ypos << std::endl; } if (xpos < -10){ xpos = 515; turn_timer.restart(); } if (xpos > 515){ //std::cout << xpos << std::endl; xpos = -10; turn_timer.restart(); } sprite.setPosition(xpos, ypos); collision_box = sprite.getGlobalBounds(); }