Skip to content

Commit 3091641

Browse files
committed
2 parents 0b58dde + d396037 commit 3091641

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

horizons_data/planets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"\tMovement: Arrow Keys or WASD",
160160
"\tUse scanner: Hold Spacebar"
161161
],
162-
"scan_multiplier": 1.6,
162+
"scan_multiplier": 1.8,
163163
"asteroid": {
164164
"count": 12,
165165
"speed": 15,

static/scripts/asteroid.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def should_be_removed(self):
137137

138138

139139
class AsteroidAttack:
140-
def __init__(self, spritesheet, width: int, height: int, max_size_px: float, spawnrate: int = 500):
140+
def __init__(self, spritesheet, width: int, height: int, max_size_px: float, spawnrate: int = 500, spawn_at_player_chance: int = 10):
141141
self.sheet = spritesheet
142142
self.w = width
143143
self.h = height
@@ -150,7 +150,7 @@ def __init__(self, spritesheet, width: int, height: int, max_size_px: float, spa
150150
self._use_grow_rate = 6.0 # default growth rate (how fast they appear to approach the player)
151151
self._use_health = 450 # default durability (affects asteroids being destroyed by impacts w/ player)
152152
self._use_damage_mul = 1.0
153-
153+
self.spawn_at_player_chance = spawn_at_player_chance
154154
def _spawn_one(self):
155155
# Don't spawn if at the limit
156156
if len(self.asteroids) >= self._max_asteroids:
@@ -159,9 +159,13 @@ def _spawn_one(self):
159159
# Planet area (left side)
160160
planet_width = self.w * 0.3
161161
space_start_x = planet_width + 50
162-
163-
x = random.uniform(space_start_x, self.w)
164-
y = random.uniform(0, self.h)
162+
if random.randint(1, self.spawn_at_player_chance) == 1:
163+
print("spawning at player")
164+
x = window.player.x
165+
y = window.player.y
166+
else:
167+
x = random.uniform(space_start_x, self.w)
168+
y = random.uniform(0, self.h)
165169

166170
if x < (SCREEN_W / 2):
167171
velocity_x = random.uniform(-15, -5)

static/scripts/player.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,15 @@ def check_collision(self, asteroid: Asteroid):
259259
window.audio_handler.play_bang()
260260
window.debris.generate_debris(self.get_position(), Position(ast_x, ast_y))
261261

262-
def nudge_towards(self, pos: Position, momentum_amount: float) -> None:
262+
def nudge_towards(self, pos: Position, gravity_strength: float = 0.75) -> None:
263263
distance = self.get_position().distance(pos)
264264
if distance == 0: return
265265

266266
x_dir = (pos.x - self.x) / distance
267267
y_dir = (pos.y - self.y) / distance
268268

269-
self.x += x_dir * 0.75
270-
self.y += y_dir * 0.75
269+
self.x += x_dir * gravity_strength
270+
self.y += y_dir * gravity_strength
271271

272272
# x_dir = math.cos((pos.x - self.x )/(pos.y - self.y))
273273
# y_dir = math.sin((pos.x - self.x )/(pos.y - self.y))
@@ -400,7 +400,7 @@ def render_beam(self, ctx): # seprate function so it can go under the planet
400400

401401
player_x, player_y = self.player.get_position()
402402
origin_x = player_x - 150
403-
origin_y = player_y - 10
403+
origin_y = player_y - 15
404404

405405
# Create animated pulsing effect based on time
406406
pulse = (math.sin(time.time() * 8) + 1) / 2 # 0 to 1

static/scripts/scene_descriptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def check_special_level_interactions(self, timestamp: int):
278278
"""
279279
# nudge player in the direction of jupiter if on the left 2/3 of the screen
280280
if self.planet.name.lower() == "jupiter":
281-
get_player().nudge_towards(self.planet.get_position(), 0.6)
281+
get_player().nudge_towards(self.planet.get_position(), 0.5)
282282
elif self.planet.name.lower() == "mercury":
283283
get_player().health = max(0, get_player().health - (timestamp - self.last_timestamp) / 1_200_000)
284284

0 commit comments

Comments
 (0)