Browse Source

定数化

ofotukuy
みてるぞ 6 months ago
parent
commit
b6ae21bb59
2 changed files with 19 additions and 10 deletions
  1. +8
    -2
      common_const.py
  2. +11
    -8
      main.py

+ 8
- 2
common_const.py View File

@@ -3,6 +3,12 @@ class CWindow:
HEIGHT: int = 768


class CMath:
PI: float = 3.14159265358979323846
class CKita:
WIDTH: float = CWindow.HEIGHT / 3.84
HEIGHT: float = WIDTH


class CJojoko:
WIDTH: float = CKita.HEIGHT * .75
HEIGHT: float = WIDTH


+ 11
- 8
main.py View File

@@ -96,11 +96,11 @@ class Main:

# き太く陽
kita: pygame.Surface = pygame.transform.scale (
pygame.image.load ('sun.png'), (200, 200))
pygame.image.load ('sun.png'), (CKita.WIDTH, CKita.HEIGHT))

# 大月ヨヨコ
jojoko: pygame.Surface = pygame.transform.scale (
pygame.image.load ('moon.png'), (200, 200))
pygame.image.load ('moon.png'), (CJojoko.WIDTH, CJojoko.HEIGHT))

# 音声再生器の初期化
pygame.mixer.init (frequency = 44100)
@@ -270,7 +270,7 @@ class Main:
+ '...')),
True,
(192, 0, 0)),
(100, 200 + 384) if goatoh_mode else (100 + (64 if (double_mode and not goatoh_talking) else 0), 200))
(100, 200 + CWindow.HEIGHT / 2) if goatoh_mode else (100 + (64 if (double_mode and not goatoh_talking) else 0), 200))

pygame.display.update ()

@@ -359,9 +359,10 @@ class Main:
jojoko: pygame.Surface = cls.get_jojoko (jojoko_original,
moon_days_old, moon_alt, moon_az)

# TODO: 大月と重複多いため修正すること
x = CWindow.WIDTH * (sun_az - 80) / 120
y = ((CWindow.HEIGHT / 2)
- (CWindow.HEIGHT / 2 + 100) * math.sin (math.radians (sun_alt)) / math.sin ( math.radians (60)))
- (CWindow.HEIGHT / 2 + CKita.HEIGHT / 2) * math.sin (math.radians (sun_alt)) / math.sin ( math.radians (60)))
arg = math.degrees (math.atan2 (y - cls.kita_y, x - cls.kita_x))

cls.kita_x = x
@@ -416,19 +417,21 @@ class Main:

jojoko.set_colorkey ((0, 255, 0))

for i in range (200):
for i in range (int (CJojoko.HEIGHT)):
# TODO: 冗長かつ可読性に缺けるため修正すること
if 1 <= moon_days_old < 15:
pygame.gfxdraw.bezier (jojoko, ((0, 100 + i), (100, 180 * moon_days_old / 7 - 80 + i), (200, 100 + i)), 3, (0, 255, 0))
pygame.gfxdraw.bezier (jojoko, ((0, CJojoko.HEIGHT / 2 + i), (CJojoko.WIDTH / 2, (CJojoko.HEIGHT * 0.9) * moon_days_old / 7 - CJojoko.HEIGHT * 0.4 + i), (CJojoko.WIDTH, CJojoko.HEIGHT / 2 + i)), 3, (0, 255, 0))
elif moon_days_old < 16:
pass
elif moon_days_old < 30:
pygame.gfxdraw.bezier (jojoko, ((0, 100 - i), (100, 180 * (moon_days_old - 15) / 7 - 80 - i), (200, 100 - i)), 3, (0, 255, 0))
pygame.gfxdraw.bezier (jojoko, ((0, CJojoko.HEIGHT / 2 - i), (CJojoko.WIDTH / 2, (CJojoko.HEIGHT * 0.9) * (moon_days_old - 15) / 7 - CJojoko.HEIGHT * 0.4 - i), (CJojoko.WIDTH, CJojoko.HEIGHT / 2 - i)), 3, (0, 255, 0))
else:
jojoko.fill ((0, 255, 0))

# TODO: き太く陽生成と重複多いため外出しすること
x = CWindow.WIDTH * (moon_az - 80) / 120
y = ((CWindow.HEIGHT / 2)
- (CWindow.HEIGHT / 2 + 100) * math.sin (math.radians (moon_alt)) / math.sin (math.radians (60)))
- (CWindow.HEIGHT / 2 + CJojoko.HEIGHT / 2) * math.sin (math.radians (moon_alt)) / math.sin (math.radians (60)))
arg = math.degrees (math.atan2 (y - cls.jojoko_y, x - cls.jojoko_x))

cls.jojoko_x = x


Loading…
Cancel
Save