Skip to content

Rework player movement and simplify the code #233

@NathanLovato

Description

@NathanLovato

The current player control has the cursor and player controller as separate components that communicate through global events. This separation isn't needed for player-specific controls and makes tuning the movement harder than it needs to be. Everything related to controlling the player character should be contained in one place instead: querying the game board, handling input, and visual feedback.

Code simplification

Right now the cursor emits global events that the player controller listens to. In this task I want to:

  • Remove the global event signals between cursor and player
  • Move all player-related input handling, gameboard queries, and visual feedback (like moving or drawing the cursor) in the player controller script

The player controller generally can be self-contained as it exists only for player control (it's not a shared or reusable thing), so it doesn't need to be built from separate components.

Movement control improvements

Currently there's this lag where you click once to set a target and the character moves there, and you can change the target but clicking while the camera is moving with the character makes it hard to select the right cell.

The usability of both mouse and keyboard movement needs improvement. Here's what would make controls more responsive and intuitive:

Mouse controls:

  • Click and drag to move: Instead of click once to move, the player should be able to click and drag to continuously update where the character is moving to. The target cell should update immediately as you drag the mouse around.
  • Easy stop: Players need an intuitive way to stop movement. This could be based on the proximity of the mouse to the character, checking movement direction, or something else. But it needs hands-on testing to get it right.

I would drop thinking about touch controls for now and just focus on mouse and keyboard and building the game for desktop as it's for educational purposes. If we layered mobile support on top of it it'd gonna make the codebase overall harder than it needs to be to understand. It's already a project that's going to remain complicated for learners.

Keyboard:

  • Input buffering: Add some input buffering when moving with arrow keys so movement feels more responsive. We should try to detect the intention of the player and not have this slightly choppy motion. At the moment it's functional but keyboard controls are not very fluid.

This whole task needs hands-on experimentation to figure out what feels good. I'm just putting it up there for future reference. It's not something I'll have time to look into or work on soon myself.

We have a first version of the game demo that packs a lot of code and it's been made by @food-please with a lot of effort and a best attempt to structure the code and figure out how to approach this complicated beast (thanks again for all your help and efforts!). There's compartmentalization and components that make a lot of sense across the code base. From here on, the focus should just be simplifying what can be simplified and improving and tightening game feel along the way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions