void Playfield::on_primary_button_press(int x, int y) { x -= rect.left; y -= rect.top; if (session) { current_pingu = current_pingu_find(state.screen2world(Vector2i(x,y))); if (current_pingu) { server->send_pingu_action_event(current_pingu, session->get_action_name()); } } }
void Playfield::update(float delta) { // FIXME: This should be delta dependant if (!mouse_scrolling) { current_pingu = current_pingu_find(state.screen2world(mouse_pos)); cap.set_pingu(current_pingu); } else { if (drag_drop_scrolling) { state.set_pos(old_state_pos + (scroll_center - mouse_pos)); } else { state.set_pos(Vector2f(state.get_pos().x - float(scroll_center.x - mouse_pos.x) * 0.2f, state.get_pos().y - float(scroll_center.y - mouse_pos.y) * 0.2f)); } } if (auto_scrolling && (fullscreen_enabled || SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)) { // FIXME: May need to modify this function if it's not gradient enough. scroll_speed = static_cast<int>(800 * delta); //std::cout << "scroll_speed: " << scroll_speed << std::endl; if (mouse_pos.x < 10) { state.set_pos(state.get_pos() - Vector2i(scroll_speed, 0)); } else if (mouse_pos.x > Display::get_width() - 10) { state.set_pos(state.get_pos() + Vector2i(scroll_speed, 0)); } if (mouse_pos.y < 10) { state.set_pos(state.get_pos() - Vector2i(0, scroll_speed)); } else if (mouse_pos.y > Display::get_height() - 10) { state.set_pos(state.get_pos() + Vector2i(0, scroll_speed)); } } }
void Playfield::update(float delta) { // FIXME: This should be delta dependant if (!mouse_scrolling) { current_pingu = current_pingu_find(state.screen2world(mouse_pos)); capture_rectangle.set_pingu(current_pingu); } else { if (globals::drag_drop_scrolling) { state.set_pos(old_state_pos + (scroll_center - mouse_pos)); } else { state.set_pos(Vector2i(state.get_pos().x - static_cast<int>(static_cast<float>(scroll_center.x - mouse_pos.x) * 0.2f), state.get_pos().y - static_cast<int>(static_cast<float>(scroll_center.y - mouse_pos.y) * 0.2f))); } } if (globals::auto_scrolling && (globals::fullscreen_enabled || SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)) { scroll_speed = static_cast<int>(800 * delta); if (mouse_pos.x < 10) { state.set_pos(state.get_pos() - Vector2i(scroll_speed, 0)); } else if (mouse_pos.x > Display::get_width() - 10) { state.set_pos(state.get_pos() + Vector2i(scroll_speed, 0)); } if (mouse_pos.y < 10) { state.set_pos(state.get_pos() - Vector2i(0, scroll_speed)); } else if (mouse_pos.y > Display::get_height() - 10) { state.set_pos(state.get_pos() + Vector2i(0, scroll_speed)); } } }