Skip to content

Commit ef436bb

Browse files
committed
Update typing
1 parent bf82fb8 commit ef436bb

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

make_spritesheet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
SPRITE_SIZE = 512
1212

1313

14-
def load_spritesheet_from_filelist(files_path: str) -> list[pg.Surface]:
14+
def load_spritesheet_from_filelist(files_path: str) -> list[pg.surface.Surface]:
1515
sprite_table = []
1616
if not os.path.isdir(files_path):
1717
print(f"Directory {files_path} doesnt exists.")

make_tileset.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from pysurvive.utils import load_image
1010

1111

12-
def load_tile_from_filelist(files_path: str, tile_size: int) -> list[pg.Surface]:
12+
def load_tile_from_filelist(
13+
files_path: str, tile_size: int
14+
) -> list[pg.surface.Surface]:
1315
tile_table = []
1416
if not os.path.isdir(files_path):
1517
print(f"Directory {files_path} doesnt exists.")

pysurvive/game/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Screen:
1414

1515
_screen = None
1616

17-
def __new__(cls, rect: pg.Rect = None):
17+
def __new__(cls, rect: pg.rect.Rect = None):
1818
if cls._screen is None:
1919
cls._screen = super().__new__(cls)
2020
if rect:

pysurvive/game/loop.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/usr/bin/env python
22
# coding=utf-8
33
import pygame as pg
4-
from pygame.locals import K_ESCAPE, KEYDOWN, MOUSEBUTTONDOWN, MOUSEBUTTONUP, QUIT
4+
from pygame.locals import (
5+
K_ESCAPE,
6+
KEYDOWN,
7+
MOUSEBUTTONDOWN,
8+
MOUSEBUTTONUP,
9+
MOUSEMOTION,
10+
QUIT,
11+
)
512

613
from pysurvive.config import FPS, GRAY_LIGHT2, MAP_DIR, RED_LIGHT
714
from pysurvive.game.core import Camera, Screen
@@ -29,14 +36,16 @@ def __init__(self) -> None:
2936
pg.display.set_caption("pysurvive")
3037
pg.transform.set_smoothscale_backend("SSE")
3138
# Turn off the mouse cursor.
32-
pg.mouse.set_visible(0)
39+
pg.mouse.set_visible(True)
3340
# Limit the number of allowed pygame events.
34-
pg.event.set_allowed([QUIT, KEYDOWN, K_ESCAPE, MOUSEBUTTONDOWN, MOUSEBUTTONUP])
41+
# pg.event.set_allowed(
42+
# [QUIT, KEYDOWN, K_ESCAPE, MOUSEBUTTONDOWN, MOUSEBUTTONUP, MOUSEMOTION]
43+
# )
3544

3645
self.fps_font = pg.font.SysFont("Arial", 14)
3746

3847
# Absolute (start) position of the player (camera) in game world.
39-
self.camera = Camera(0, 0)
48+
self.camera = Camera(300, 300)
4049

4150
# Prepare the shadow surface / screen.
4251
# self.screen_shadow = pg.Surface(self.screen.size)

pysurvive/map/objects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class MapObject(pg.sprite.Sprite):
1010
def __init__(
11-
self, _x: int, _y: int, _image: pg.Surface, rotation: bool = False
11+
self, _x: int, _y: int, _image: pg.surface.Surface, rotation: bool = False
1212
) -> None:
1313
super().__init__()
1414
self.image = _image
@@ -20,7 +20,7 @@ def __init__(
2020
self.rect.x = self.x
2121
self.rect.y = self.y
2222

23-
def init_rotation(self, angle: int) -> pg.Surface:
23+
def init_rotation(self, angle: int) -> pg.surface.Surface:
2424
"""Return rotated surfaces based on the original one."""
2525
return pg.transform.rotate(
2626
self.image,

pysurvive/map/tileset.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,22 @@ def get_tile_index(self, tile_id: int) -> int:
6767
"""Returns the tile index of the table by id."""
6868
return tile_id - self.first_gid
6969

70-
def get_tile(self, tile_id: int) -> pg.Surface:
70+
def get_tile(self, tile_id: int) -> pg.surface.Surface:
7171
"""Returns the tile (image) by id."""
7272
return self.table[tile_id - self.first_gid]
7373

7474
@staticmethod
75-
def _load(tileset_file: str, tile_width: int, tile_height: int) -> list[pg.Surface]:
75+
def _load(
76+
tileset_file: str, tile_width: int, tile_height: int
77+
) -> list[pg.surface.Surface]:
7678
"""
7779
Load a tileset from single file and split it into a table.
7880
The tileset consists of several tiles arranged in a row.
7981
"""
8082
logger.info("Loading tileset from file %s.", tileset_file)
8183
image, _ = load_image(tileset_file, alpha=True)
8284
image_width, image_height = image.get_size()
83-
tile_table: list[pg.Surface] = []
85+
tile_table: list[pg.surface.Surface] = []
8486
for tile_x in range(0, image_width // tile_width):
8587
rect = (
8688
tile_x * tile_width,

pysurvive/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def play(self) -> None:
1818

1919
def load_image(
2020
filename: str, alpha: bool = False, colorkey: tuple[int, int, int] = None
21-
) -> tuple[pg.Surface, pg.Rect]:
21+
) -> tuple[pg.surface.Surface, pg.rect.Rect]:
2222
"""
2323
Load an image from disk.
2424

tests/test_screen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class TestScreen:
1111
@pytest.fixture()
1212
def singleton(self):
13-
def _wrapper(rect: pg.Rect = None):
13+
def _wrapper(rect: pg.rect.Rect = None):
1414
return Screen(rect)
1515

1616
return _wrapper

0 commit comments

Comments
 (0)