Skip to content

Conversation

@dhiegosilva
Copy link

Summary

This PR adds comprehensive Player 2 controls for multiplayer mode with single-step input handling to prevent action repetition when keys are held, matching Player 1's behavior.

Features Added

Player 2 Controls

  • Attack Button: Player 2 can now draw sword when sheathed by pressing the attack button (X key by default)
  • Block/Parry: Player 2 can parry/block attacks using the up key (W by default)
  • Sheath Sword: Player 2 can sheath sword using the down key (S by default)
  • Movement: Forward/backward movement with single-step mode (A/D keys by default)

Single-Step Input Mode

All Player 2 controls now use single-step mode, preventing continuous actions when keys are held:

  • Attack: Triggers once per press, no continuous swinging
  • Block/Parry: Triggers once per press, no continuous blocking
  • Down/Sheath: Triggers once per press, no continuous sheathing
  • Movement: Already implemented, now consistent across all controls

Technical Changes

Modified Files

  • src/seg005.c:

    • Added Player 2 attack button support in control_standing() and control_guard_inactive()
    • Enhanced parry() to allow Player 2 parry regardless of opponent distance/frame
    • Added IGNORE state synchronization for control_shift2_p2, control_up_p2, and control_down_p2 in sword_strike(), draw_sword(), parry(), and sword sheathing logic
  • src/seg006.c:

    • Implemented single-step logic for all Player 2 controls in read_user_control_p2()
    • Added IGNORE state preservation in user_control_p2() to prevent input repeat
    • Enhanced control state management to maintain IGNORE state across frames

New Files

  • src/build_and_run.ps1: Fast incremental build script for development (only compiles changed files)

How It Works

  1. Input Processing: read_user_control_p2() processes Player 2 input with single-step logic
  2. State Management: IGNORE state is preserved across frames to prevent repeat actions
  3. Control Mapping: user_control_p2() maps Player 2 controls to the game's control system
  4. Action Execution: Game functions (sword_strike(), parry(), etc.) set IGNORE state to prevent repeat

Testing

  • ✅ Player 2 can draw sword with attack button when sheathed
  • ✅ Player 2 can parry/block with up key
  • ✅ Player 2 can sheath sword with down key
  • ✅ All controls trigger once per press, no repeat when held
  • ✅ Works consistently with Player 1 controls

Compatibility

  • Fully backward compatible
  • Only activates when is_multiplayer_mode is enabled
  • No changes to existing single-player gameplay

… and joystick support. Update CMake configuration for optimization and SDL2 path adjustments. Enhance .gitignore for build artifacts and temporary files.
…ready present, reposition them correctly, and manage sword states for both characters. Implement auto-turning for Guards based on distance to opponents.
…le-step movement logic to prevent continuous movement on key holds, and ensure proper state management for forward and backward controls.
… to X, improve sword drawing mechanics when sheathed, and refine control state management for smoother gameplay.
…nt for Player 2 to prevent repeat actions when drawing the sword and during parries. Refine handling of attack button when sword is sheathed to ensure smoother gameplay.
…trol_shift2 to preserve IGNORE state during attack animations and prevent repeat actions. Update logic for transitioning between control states to improve gameplay responsiveness.
…ing of control states for parries and sheathing actions to preserve IGNORE state, preventing repeat actions during animations. Improve logic for transitioning between control states to enhance gameplay responsiveness.
Fix release workflow: only trigger on published releases and fix file…
Fix Windows build: use MSYS2 shell for DLL paths
Add verification steps and fix binary path: prevent build failures wi…
Fix AppImage rename and Windows zip nesting issues
Fix Windows build: install zip package in MSYS2
…uild jobs, update artifact handling, and improve naming conventions for clarity.
Enhance GitHub Actions workflow: Add 32-bit Windows and ARM64 Linux b…
…ement SDL2_image package checks, and improve linking logic for static and dynamic libraries.
Enhance GitHub Actions workflow: Add ARM32 and ARM64 build jobs, impl…
Fix Windows 32-bit build: Remove non-existent SDL2_image package, bui…
Fix ARM64 and Windows 32-bit builds: Unset PKG_CONFIG to prevent pack…
…r Linux 32-bit, fix tar symlink issue for Windows
Fix Linux 32-bit and Windows 32-bit builds: Build SDL2 from source fo…
Remove Windows x86 (32-bit) and Linux AppImage 32-bit build jobs
…age package installation and improve build process.
Fix Windows 32-bit build: Update workflow to correctly handle SDL2_im…
…g and improve SDL2 plugin detection logic. Remove obsolete build scripts for PowerShell and batch processing.
Enhance release workflow: Add curl for better plugin download handlin…
@salvadorc17
Copy link

Hey can you try something similar to my project
https://github.com/salvadorc17/Prince-Monogame

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants