AI generálta ütközés

This commit is contained in:
markojozsef
2026-10-10 17:45:59 +02:00
parent b77b110eb9
commit 45261b2c58
3 changed files with 99 additions and 17 deletions

View File

@@ -27,25 +27,26 @@ def start_battle(battle_id):
def switch(game):
in_battle_transition = False
# !!! CHATGPT !!!
def update(game, dt):
global btrans_active, btrans_timer
if btrans_active:
btrans_timer += dt
btrans_timer += dt
if btrans_timer >= BTRANS_DURATION:
game.mos_enabled = False
btrans_active = False
btrans_sound.stop()
gamestate.switch_gamestate(game,"battle")
gamestate.switch_gamestate(game, "battle")
game.mos_enabled = True
cycle_progress = (btrans_timer % BTRANS_PULSE_DUR) / BTRANS_PULSE_DUR
game.mosaic = max(1, math.floor(cycle_progress * 16))
cycle_progress = (btrans_timer % BTRANS_PULSE_DUR) / BTRANS_PULSE_DUR
game.mosaic = max(1, math.floor(cycle_progress * 16))
return
balthasar.update()
if controls.is_control_pressed(4): # DEBUG: battle
if controls.is_control_pressed(4): # DEBUG: battle
start_battle(0)
if controls.is_control_pressed(0): # Fel
@@ -57,24 +58,51 @@ def update(game, dt):
elif controls.is_control_pressed(3): # Jobb
balthasar.set_direction(DIR_RIGHT)
walking = False
# Calculate movement delta based on input
dx = 0
dy = 0
walking = False
if controls.is_control_held(0): # Fel
overworld.scroll_y -= WALK_SPEED * dt
if controls.is_control_held(0): # Fel (Up)
dy += WALK_SPEED * dt
walking = True
elif controls.is_control_held(1): # Le
overworld.scroll_y += WALK_SPEED * dt
elif controls.is_control_held(1): # Le (Down)
dy -= WALK_SPEED * dt
walking = True
if controls.is_control_held(2): # Bal
overworld.scroll_x += WALK_SPEED * dt
if controls.is_control_held(2): # Bal (Left)
dx -= WALK_SPEED * dt
walking = True
elif controls.is_control_held(3): # Jobb
overworld.scroll_x -= WALK_SPEED * dt
elif controls.is_control_held(3): # Jobb (Right)
dx += WALK_SPEED * dt
walking = True
balthasar.set_walking(walking)
if walking:
# Get current world position
cur_x, cur_y = overworld.get_player_world_pos(game)
# Define collision box dimensions for Balthasar (e.g., 12 width, 10 height at feet)
box_w = 12
box_h = 10
# Test and apply X movement independently (Slide on walls)
if dx != 0:
next_x = cur_x + dx
if overworld.is_box_walkable(next_x, cur_y, box_w, box_h):
overworld.scroll_x -= dx # Note: scroll moves inverse to world pos change
# Re-fetch current world pos after potential X movement update
cur_x, cur_y = overworld.get_player_world_pos(game)
# Test and apply Y movement independently
if dy != 0:
next_y = cur_y + dy
if overworld.is_box_walkable(cur_x, next_y, box_w, box_h):
overworld.scroll_y -= dy # Note: scroll moves inverse to world pos change
# !!! CHATGPT VÉGE !!!
def draw(game):
overworld.render(game)
balthasar.render(game)