feat: Implement core game systems including settings management, player input, and initial gameplay mechanics with associated UI.
This commit is contained in:
@@ -31,23 +31,33 @@ var settings = {
|
||||
},
|
||||
"controls": {
|
||||
"use_controller": false,
|
||||
# Movement (Keybinds are typically fixed to WASD/Arrows in Input Map, but we show them)
|
||||
# Movement
|
||||
"move_up": KEY_W,
|
||||
"move_up_alt": KEY_UP,
|
||||
"move_down": KEY_S,
|
||||
"move_down_alt": KEY_DOWN,
|
||||
"move_left": KEY_A,
|
||||
"move_left_alt": KEY_LEFT,
|
||||
"move_right": KEY_D,
|
||||
"move_right_alt": KEY_RIGHT,
|
||||
|
||||
# Actions
|
||||
"grab": KEY_SPACE,
|
||||
"grab_alt": KEY_J,
|
||||
"put": KEY_R,
|
||||
"put_alt": KEY_K,
|
||||
"tekton_grab": KEY_G,
|
||||
"tekton_grab_alt": KEY_L,
|
||||
|
||||
# Power-Up Controls
|
||||
"powerup_1": KEY_1,
|
||||
"powerup_2": KEY_2,
|
||||
"powerup_3": KEY_3,
|
||||
"powerup_4": KEY_4,
|
||||
"use_powerup": KEY_F,
|
||||
"use_powerup_alt": KEY_SHIFT,
|
||||
|
||||
# Power Bar Controls / Special
|
||||
"attack_mode": KEY_Q,
|
||||
"spawn_boost": KEY_E
|
||||
"attack_mode_alt": KEY_U,
|
||||
"spawn_boost": KEY_E,
|
||||
"spawn_boost_alt": KEY_I
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +90,7 @@ func save_settings():
|
||||
func apply_all_settings():
|
||||
apply_video_settings()
|
||||
apply_audio_settings()
|
||||
apply_control_settings()
|
||||
emit_signal("settings_applied")
|
||||
|
||||
func apply_video_settings():
|
||||
@@ -149,9 +160,62 @@ func set_bus_volume(bus_name: String, volume_linear: float):
|
||||
AudioServer.set_bus_volume_db(bus_idx, linear_to_db(volume_linear))
|
||||
AudioServer.set_bus_mute(bus_idx, volume_linear <= 0.001)
|
||||
|
||||
func apply_control_settings():
|
||||
# Sync custom settings with InputMap
|
||||
var mapping = {
|
||||
"move_up": "move_north",
|
||||
"move_down": "move_south",
|
||||
"move_left": "move_west",
|
||||
"move_right": "move_east",
|
||||
"grab": "action_grab",
|
||||
"put": "action_put",
|
||||
"use_powerup": "use_powerup",
|
||||
"tekton_grab": "action_grab_tekton",
|
||||
"attack_mode": "action_knock_tekton",
|
||||
"spawn_boost": "spawn_boost"
|
||||
}
|
||||
|
||||
for setting_key in mapping.keys():
|
||||
var action_name = mapping[setting_key]
|
||||
if not InputMap.has_action(action_name):
|
||||
InputMap.add_action(action_name)
|
||||
|
||||
InputMap.action_erase_events(action_name)
|
||||
|
||||
# Add Primary
|
||||
var primary_key = settings.controls.get(setting_key)
|
||||
if primary_key:
|
||||
var event = InputEventKey.new()
|
||||
event.keycode = primary_key
|
||||
InputMap.action_add_event(action_name, event)
|
||||
|
||||
# Add Secondary
|
||||
var secondary_key = settings.controls.get(setting_key + "_alt")
|
||||
if secondary_key:
|
||||
var event = InputEventKey.new()
|
||||
event.keycode = secondary_key
|
||||
InputMap.action_add_event(action_name, event)
|
||||
|
||||
# Add Joypad defaults for movement
|
||||
if action_name.begins_with("move_"):
|
||||
var joy_axis = -1
|
||||
var axis_val = 0.0
|
||||
match action_name:
|
||||
"move_north": joy_axis = JOY_AXIS_LEFT_Y; axis_val = -1.0
|
||||
"move_south": joy_axis = JOY_AXIS_LEFT_Y; axis_val = 1.0
|
||||
"move_west": joy_axis = JOY_AXIS_LEFT_X; axis_val = -1.0
|
||||
"move_east": joy_axis = JOY_AXIS_LEFT_X; axis_val = 1.0
|
||||
|
||||
if joy_axis != -1:
|
||||
var joy_event = InputEventJoypadMotion.new()
|
||||
joy_event.axis = joy_axis
|
||||
joy_event.axis_value = axis_val
|
||||
InputMap.action_add_event(action_name, joy_event)
|
||||
|
||||
func set_control(action_name: String, keycode: int):
|
||||
if settings.controls.has(action_name):
|
||||
settings.controls[action_name] = keycode
|
||||
apply_control_settings() # Apply immediately
|
||||
emit_signal("control_remapped", action_name, keycode)
|
||||
save_settings()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user