Skip to content

Commit

Permalink
fix: code
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPJT committed Mar 10, 2024
1 parent b3c27a2 commit fd53d0f
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 184 deletions.
157 changes: 46 additions & 111 deletions Library/PAX_GRAPHICA/Key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,21 @@ namespace paxs {
paxs::EquirectangularDeg(paxs::Vector2<double>(135, 35)), // 韓国 128, 37
//paxs::Vector2(135.0, getLatitudeToMercatorY(35.0)),
200.0); // マップ座標の中央
double width = 12.0; // マップの幅
double height = 12.0; // マップの高さ

// 平城京
//Coordinate center = Coordinate(135.807, 37.009/*getLatitudeToMercatorY(35)*/, 200.0); // マップ座標の中央
//double width = 0.1; // マップの幅
// マップの最大幅
double max_width =

// マップの最大高さ
double max_height =
#ifdef PAXS_MAHOROBA
30.0;
#else
300.0;
180.0;
#endif
double min_width = 0.005; // マップの最小幅
double height = (width) / double(paxg::Window::width()) * double(paxg::Window::height()); // マップの高さ
double min_height = 0.005; // マップの最小高さ
double width = (height) / double(paxg::Window::height()) * double(paxg::Window::width()); // マップの高さ
double expansion_size = 50.0; // マップの拡大量
std::vector<Key> enl_keys; // 拡大キー
std::vector<Key> esc_keys; // 縮小キー
Expand All @@ -269,9 +269,9 @@ namespace paxs {
void update() {
// マウスホイールで地図の拡大・縮小
{
width *= (1.0 + (paxg::Mouse::getInstance()->getWheelRotVol() / 10.0));
width = (std::clamp)(width, min_width, max_width);
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
height *= (1.0 + (paxg::Mouse::getInstance()->getWheelRotVol() / 10.0));
height = (std::clamp)(height, min_height, max_height);
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
#ifdef __ANDROID__
static int old_touch_num = 0;
Expand All @@ -282,11 +282,11 @@ namespace paxs {
if (paxg::Mouse::getInstance()->pressedLeft2()) {
center.setX(
center.getX() +
width / static_cast<double>(paxg::Window::width()) *
height / static_cast<double>(paxg::Window::height()) *
static_cast<double>(paxg::Mouse::getInstance()->getPosXBefore1Frame() - paxg::Mouse::getInstance()->getPosX()));
center.setY(
center.getY() +
width / static_cast<double>(paxg::Window::width()) *
height / static_cast<double>(paxg::Window::height()) *
static_cast<double>(paxg::Mouse::getInstance()->getPosY() - paxg::Mouse::getInstance()->getPosYBefore1Frame()));

if (center.getX() < -180.0) {
Expand Down Expand Up @@ -324,10 +324,10 @@ namespace paxs {

if (old_touch_num == 1 && touch_num == 1) {
center.setX(center.getX() +
width / static_cast<double>(paxg::Window::width()) *
height / static_cast<double>(paxg::Window::height()) *
static_cast<double>(old_pos[0].x - pos[0].x));
center.setY(center.getY() +
width / static_cast<double>(paxg::Window::width()) *
height / static_cast<double>(paxg::Window::height()) *
static_cast<double>(pos[0].y - old_pos[0].y));

if (center.getX() < -180.0) {
Expand All @@ -351,60 +351,60 @@ namespace paxs {
const int sub = std::abs(len - old_len);

if (len > old_len) {
if (width > min_width) {
width -= ((width * (1.0 + (sub / 6000.0))) / expansion_size);
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height > min_height) {
height -= ((height * (1.0 + (sub / 6000.0))) / expansion_size);
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
if (width < min_width) {
width = min_width;
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height < min_height) {
height = min_height;
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
}
else if (len < old_len) {
// 画面広く
if (width < max_width) {
width += ((width * (1.0 + (sub / 6000.0))) / expansion_size);
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height < max_height) {
height += ((height * (1.0 + (sub / 6000.0))) / expansion_size);
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
if (width > max_width) {
width = max_width;
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height > max_height) {
height = max_height;
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
}

}
#endif

center.update(width);
center.update(height);
if (pressed(enl_keys)) {
if (width > min_width) {
width -= (width / expansion_size);
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height > min_height) {
height -= (height / expansion_size);
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
if (width < min_width) {
width = min_width;
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height < min_height) {
height = min_height;
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
}
if (pressed(esc_keys)) {
if (width < max_width) {
width += (width / expansion_size);
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height < max_height) {
height += (height / expansion_size);
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
if (width > max_width) {
width = max_width;
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height > max_height) {
height = max_height;
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
}

// 位置調整
if (width < min_width) {
width = min_width;
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height < min_height) {
height = min_height;
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}
if (width > max_width) {
width = max_width;
height = (width) / double(paxg::Window::width()) * double(paxg::Window::height());
if (height > max_height) {
height = max_height;
width = (height) / double(paxg::Window::height()) * double(paxg::Window::width());
}

#ifdef PAXS_MAHOROBA
Expand All @@ -431,7 +431,7 @@ namespace paxs {
if (center.getY() - height / 2 < south_max) {
center.setY(south_max + height / 2);
}



} // Update
Expand Down Expand Up @@ -460,71 +460,6 @@ namespace paxs {
}
};

// キーボード入力を更新(どの入力が必要か未確定なのでまだクラス化前)
void updateKey(
double& map_view_center_x, // マップ座標の中央 X
double& map_view_center_y, // マップ座標の中央 Y
double& map_view_width, // マップの幅
double& map_view_max_width, // マップの最大幅
double& map_view_min_width, // マップの最小幅
double& map_view_height, // マップの高さ
double& map_view_movement_size, // マップの移動量
double& map_view_expansion_size // マップの拡大量
) {
// #ifdef PAXS_USING_SIV3D
// 西へ移動
if (SIV3D_KEY_A.pressed() || SIV3D_KEY_LEFT.pressed()) {
map_view_center_x -= (map_view_width / map_view_movement_size);
if (map_view_center_x < -180.0) {
map_view_center_x += 360.0;
}
}
// 東へ移動
if (SIV3D_KEY_D.pressed() || SIV3D_KEY_RIGHT.pressed()) {
map_view_center_x += (map_view_width / map_view_movement_size);
if (map_view_center_x >= 180.0) {
map_view_center_x -= 360.0;
}
}
// 南へ移動
if (SIV3D_KEY_S.pressed() || SIV3D_KEY_DOWN.pressed()) {
map_view_center_y -= (map_view_width / map_view_movement_size);
if (map_view_center_y < -180.0) {
map_view_center_y = -180.0;
}
}
// 北へ移動
if (SIV3D_KEY_W.pressed() || SIV3D_KEY_UP.pressed()) {
map_view_center_y += (map_view_width / map_view_movement_size);
if (map_view_center_y > 180.0) {
map_view_center_y = 180.0;
}
}
// 地図を拡大
if (SIV3D_KEY_Q.pressed()) {
if (map_view_width > map_view_min_width) {
map_view_width -= (map_view_width / map_view_expansion_size);
map_view_height = (map_view_width) / double(paxg::Window::width()) * double(paxg::Window::height());
}
if (map_view_width < map_view_min_width) {
map_view_width = map_view_min_width;
map_view_height = (map_view_width) / double(paxg::Window::width()) * double(paxg::Window::height());
}
}
// 地図を縮小
if (SIV3D_KEY_E.pressed()) {
if (map_view_width < map_view_max_width) {
map_view_width += (map_view_width / map_view_expansion_size);
map_view_height = (map_view_width) / double(paxg::Window::width()) * double(paxg::Window::height());
}
if (map_view_width > map_view_max_width) {
map_view_width = map_view_max_width;
map_view_height = (map_view_width) / double(paxg::Window::width()) * double(paxg::Window::height());
}
}
// #endif
}

}

#endif // !PAX_SAPIENTICA_SIV3D_KEY_HPP
9 changes: 7 additions & 2 deletions Library/PAX_GRAPHICA/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ namespace paxg {

#elif defined(PAXS_USING_DXLIB)
int texture = -1;
int x = 1;
int y = 1;

Texture(const paxg::String& path) {
// svgの場合は読み込めないので、pngに拡張子を変換する
std::string path_str = path.string;
paxs::StringExtensions::replace(path_str, ".svg", ".png");

texture = DxLib::LoadGraph(path_str.c_str());
DxLib::GetGraphSize(texture, &x, &y);
}
Texture(const std::string& path) {
// svgの場合は読み込めないので、pngに拡張子を変換する
std::string path_str = path;
paxs::StringExtensions::replace(path_str, ".svg", ".png");

texture = DxLib::LoadGraph(path_str.c_str());
DxLib::GetGraphSize(texture, &x, &y);
}
operator bool() const { return (texture != -1); }

Expand Down Expand Up @@ -222,9 +226,10 @@ namespace paxg {
}
#elif defined(PAXS_USING_DXLIB)
void resizedDrawAt(const int resize, const paxg::Vec2i & pos) const {
const int resize_x = resize * this->x / this->y;
DxLib::DrawExtendGraph(
pos.x() - (resize / 2), pos.y() - (resize / 2),
pos.x() + (resize / 2), pos.y() + (resize / 2),
pos.x() - (resize_x / 2), pos.y() - (resize / 2),
pos.x() + (resize_x / 2), pos.y() + (resize / 2),
texture, TRUE);
}
#elif defined(PAXS_USING_SFML)
Expand Down
4 changes: 2 additions & 2 deletions Library/PAX_MAHOROBA/Calendar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ namespace paxs {
else
#endif
if (jdn.cgetDay() != (std::numeric_limits<int>::max)()) {
jdn += (365.2425 / 6.0);//(0.8 / 30.0); //(365.2425 / 12.0);//365.2425;//1.0;// ユリウス日を繰り上げ(次の日にする)
jdn += (365.2425 / 18.0);//(0.8 / 30.0); //(365.2425 / 12.0);//365.2425;//1.0;// ユリウス日を繰り上げ(次の日にする)
calcDate(); // 日付計算
}
}
// 時間を逆行している場合
else if (go_back_in_time) {
if (jdn.cgetDay() != (std::numeric_limits<int>::max)()) {
jdn -= (365.2425 / 6.0);//(0.8 / 30.0); //(365.2425 / 12.0);//365.24252;//1.0;// ユリウス日を繰り上げ(次の日にする)
jdn -= (365.2425 / 18.0);//(0.8 / 30.0); //(365.2425 / 12.0);//365.24252;//1.0;// ユリウス日を繰り上げ(次の日にする)
calcDate(); // 日付計算
}
}
Expand Down
3 changes: 2 additions & 1 deletion Library/PAX_MAHOROBA/InitLogo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ namespace paxs {
#endif

// PAX SAPIENTICA 用の背景
const paxg::Color paxs_color = paxg::Color(140, 180, 250); //
const paxg::Color paxs_color = paxg::Color(145, 190, 240); // 水色
//const paxg::Color paxs_color = paxg::Color(140, 180, 250); // 元青
//const paxg::Color paxs_color = paxg::Color(255, 255, 255); // 白
paxg::Window::setBackgroundColor(paxs_color);
paxg::Window::setLetterbox(paxs_color);
Expand Down
Loading

0 comments on commit fd53d0f

Please sign in to comment.