Browse Source

軽量化

pull/38/head
みてるぞ 1 week ago
parent
commit
9e28c1744e
1 changed files with 19 additions and 19 deletions
  1. +19
    -19
      main.py

+ 19
- 19
main.py View File

@@ -37,9 +37,9 @@ pygame.init ()

FPS = 30

SYSTEM_FONT = pygame.font.SysFont ('notosanscjkjp', 24, bold = True)
USER_FONT = pygame.font.SysFont ('notosanscjkjp', 32, italic = True)
DEERJIKA_FONT = pygame.font.SysFont ('07nikumarufont', 50)
SYSTEM_FONT = pygame.font.SysFont ('notosanscjkjp', 11, bold = True)
USER_FONT = pygame.font.SysFont ('notosanscjkjp', 15, italic = True)
DEERJIKA_FONT = pygame.font.SysFont ('07nikumarufont', 23)


def main (
@@ -49,10 +49,10 @@ def main (
balloon = Balloon (game)
deerjika = Deerjika (game, DeerjikaPattern.RELAXED,
x = CWindow.WIDTH * 3 / 4,
y = CWindow.HEIGHT - 120,
y = CWindow.HEIGHT - 56.25,
balloon = balloon)
snack_time = SnackTime (game)
CurrentTime (game, SYSTEM_FONT)
CurrentTime (game, DEERJIKA_FONT)

try:
broadcast = Broadcast (os.environ['BROADCAST_CODE'])
@@ -404,7 +404,7 @@ class Deerjika (Creature):
FPS = 30

height: int
scale: float = .8
scale: float = .375
surfaces: list[Surface]
width: int
talking: bool = False
@@ -572,22 +572,22 @@ class Balloon (GameObject):
query = self.query
if CommonModule.len_by_full (query) > 21:
query = CommonModule.mid_by_full (query, 0, 19.5) + '...'
answer = Surface ((800, ((CommonModule.len_by_full (self.answer) - 1) // 16 + 1) * 50),
answer = Surface ((375, ((CommonModule.len_by_full (self.answer) - 1) // 16 + 1) * 23.4375),
pygame.SRCALPHA)
for i in range (int (CommonModule.len_by_full (self.answer) - 1) // 16 + 1):
answer.blit (DEERJIKA_FONT.render (
CommonModule.mid_by_full (self.answer, 16 * i, 16), True, (192, 0, 0)),
(0, 50 * i))
(0, 23.4375 * i))
surface = self.surface.copy ()
surface.blit (USER_FONT.render ('>' + query, True, (0, 0, 0)), (120, 70))
y: int
surface.blit (USER_FONT.render ('>' + query, True, (0, 0, 0)), (56.25, 32.8125))
y: float
if self.frame < 30:
y = 0
elif self.frame >= self.length - 90:
y = answer.get_height () - 100
y = answer.get_height () - 46.875
else:
y = int ((answer.get_height () - 100) * (self.frame - 30) / (self.length - 120))
surface.blit (answer, (100, 150), Rect (0, y, 800, 100))
y = int ((answer.get_height () - 46.875) * (self.frame - 30) / (self.length - 120))
surface.blit (answer, (46.875, 70.3125), Rect (0, y, 375, 46.875))
self.game.screen.blit (surface, (0, 0))
super ().redraw ()

@@ -625,7 +625,7 @@ class KitaSun (GameObject):
game: Game,
):
super ().__init__ (game)
self.surface = pygame.transform.scale (pygame.image.load ('./assets/sun.png'), (200, 200))
self.surface = pygame.transform.scale (pygame.image.load ('./assets/sun.png'), (93.75, 93.75))
self.sun = Sun ()

def redraw (
@@ -658,7 +658,7 @@ class KitaSun (GameObject):
self,
) -> float:
return ((CWindow.HEIGHT / 2)
- ((CWindow.HEIGHT / 2 + 100) * math.sin (self.alt)
- ((CWindow.HEIGHT / 2 + 46.875) * math.sin (self.alt)
/ math.sin (math.radians (60))))

@property
@@ -689,7 +689,7 @@ class Jojoko (GameObject):
game: Game,
):
super ().__init__ (game)
self.base = pygame.transform.scale (pygame.image.load ('./assets/moon.png'), (200, 200))
self.base = pygame.transform.scale (pygame.image.load ('./assets/moon.png'), (93.75, 93.75))
self.moon = Moon ()
self.surface = self._get_surface ()

@@ -729,11 +729,11 @@ class Jojoko (GameObject):
jojoko = self.base.copy ()
for i in range (200):
if 1 <= self.phase < 15:
pygame.gfxdraw.bezier (jojoko, ((0, 100 + i), (100, 180 * self.phase / 7 - 80 + i), (200, 100 + i)), 3, (0, 255, 0))
pygame.gfxdraw.bezier (jojoko, ((0, (100 + i) * .468_75), (46.875, (180 * self.phase / 7 - 80 + i) * .468_75), (93.75, (100 + i) * .468_75)), 3, (0, 255, 0))
elif self.phase < 16:
pass
elif self.phase < 30:
pygame.gfxdraw.bezier (jojoko, ((0, 100 - i), (100, 180 * (self.phase - 15) / 7 - 80 - i), (200, 100 - i)), 3, (0, 255, 0))
pygame.gfxdraw.bezier (jojoko, ((0, (100 - i) * .468_75), (46.875, (180 * (self.phase - 15) / 7 - 80 - i) * .468_75), (93.75, (100 - i) * .468_75)), 3, (0, 255, 0))
else:
jojoko.fill ((0, 255, 0))
return jojoko
@@ -749,7 +749,7 @@ class Jojoko (GameObject):
self,
) -> float:
return ((CWindow.HEIGHT / 2)
- ((CWindow.HEIGHT / 2 + 100) * math.sin (self.alt)
- ((CWindow.HEIGHT / 2 + 46.875) * math.sin (self.alt)
/ math.sin (math.radians (60))))

@property


Loading…
Cancel
Save