std::string unit_test_mark_as_tested(const modal_dialog& dialog) { std::vector<std::string>& list = unit_test_registered_window_list(); list.erase( std::remove(list.begin(), list.end(), dialog.window_id()) , list.end()); return dialog.window_id(); }
void gameover() { pause = true; std::wstring message = L"スコア "; message += std::to_wstring(score); message += L"\nもう一度遊びますか?"; dialog.set_text(message.c_str()); dialog.show(); }
std::string unit_test_mark_as_tested(const modal_dialog& dialog) { std::set<std::string>& list = unit_test_registered_window_list(); list.erase(dialog.window_id()); return dialog.window_id(); }
shooting(main_window *w): window(*w), config(keyconfig::get_instance()), holder(std::make_shared<resource_holder>()), player_(holder) { register_resource(holder.get()); register_object(&dialog); dialog.set_button_text(0, L"はい"); dialog.set_button_handler(0, [this](){ this->dialog.hide(); on_hide(); on_show(); }); dialog.set_button_text(1, L"いいえ"); dialog.set_button_handler(1, [this](){ this->dialog.hide(); this->window.select_scene(main_window::scene::title); }); dialog.set_size(paint::size(300, 200)); dialog.set_position(paint::point(250, 200)); add_keyboard_handler([this](unsigned keycode, bool push){ config->set_keyboard_state(keycode, push); }, keycode_range(0, 255)); add_timer_handler([this](...){ if(pause) return; auto state = config->get_state(); vector v; const float velocity = 7.f; if(state.up){ v[1][0] -= velocity; } if(state.down){ v[1][0] += velocity; } if(state.left){ v[0][0] -= velocity; } if(state.right){ v[0][0] += velocity; } player_.set_vector(v); auto now = std::chrono::system_clock::now(); if(state.b && now - bullet_time >= std::chrono::milliseconds(192)){ auto it = std::find(bullets.begin(), bullets.end(), false); if(it != bullets.end()){ float r = it->get_radius(); it->set_position(player_.get_center()); it->set_vector(vector(0, -10)); it->set_active(); auto trans = transform::scale(1.f, 1.01f); if(state.a){ trans = transform::rotation(to_rad(-0.5)) * trans; } if(state.c){ trans = transform::rotation(to_rad(0.5)) * trans; } it->set_transform(trans); } bullet_time = now; } if(now - enemy_time >= enemy_duration){ enemy_duration = std::chrono::milliseconds(this->rand() % 750 + 250); enemy_time = now; enemies.push_back(new enemy1(holder)); enemies.back()->set_position(paint::point(static_cast<float>(this->rand() % 800), -50)); } move(); this->window.repaint(); }, timer_id); }