Handles mouse input (prototype)
This commit is contained in:
1 parent
fe9fc14849
commit
0e3f07938c
5 files changed
+76
-6
No files matched your search
+14
-3
@@ -8,10 +8,11 @@ from components import (
|
||||
SpaceShipMarker,
|
||||
Target,
|
||||
)
|
||||
from random import randint, sample
|
||||
from random import choice, randint, sample
|
||||
from settings import (
|
||||
MIN_PLANET_RADIUS,
|
||||
MAX_PLANET_RADIUS,
|
||||
PLANET_COLORS,
|
||||
SCREEN_WIDTH,
|
||||
SCREEN_HEIGHT,
|
||||
SPACESHIP_COLOR,
|
||||
@@ -58,8 +59,8 @@ def generate_random_planet(world: World) -> int:
|
||||
radius: int = randint(MIN_PLANET_RADIUS, MAX_PLANET_RADIUS)
|
||||
x: int = randint(radius, SCREEN_WIDTH - radius)
|
||||
y: int = randint(radius, SCREEN_HEIGHT - radius)
|
||||
color = (randint(0, 255), randint(0, 255), randint(0, 255), 255)
|
||||
|
||||
# color = (randint(0, 255), randint(0, 255), randint(0, 255), 255)
|
||||
color = choice(PLANET_COLORS) + (255,)
|
||||
return create_planet(world, x, y, radius, color)
|
||||
|
||||
|
||||
@@ -94,3 +95,13 @@ def generate_random_spaceship(world: World) -> int:
|
||||
_planet_sample = sample(planets, 2)
|
||||
|
||||
return create_travelling_spaceship(world, *_planet_sample)
|
||||
|
||||
|
||||
def load_items(path: str) -> list[str]:
|
||||
with open(path) as f:
|
||||
data = [l.rstrip("\n") for l in f.readlines()]
|
||||
return data
|
||||
|
||||
|
||||
def normalize_name(name: str) -> str:
|
||||
return name.replace("_", " ").title()
|
||||
Reference in new issue
Block a user