Giter VIP home page Giter VIP logo

input-sequencer's Introduction

Input Sequence Proof of Concept

NOTE: This is a work in progress.

Get Started

This proof of concept is built with Phaser 3 and requires Node.js

npm install
npm run dev

Overview

This is a proof of concept for an input buffer system seen in games with input sequencing, primarily fighting games.

The simplest example is throwing a fireball in Street Fighter. To activate a fireball move, this requires a specific sequence of inputs to be entered in order to trigger the move within a certain number of frames. Not only this, but the state of the player has to allow the move to trigger.

Visual Flow Chart

Breakdown

1. Player Input Controller

src/controllers/player-input-controller.js

A simple brute force way of handling inputs. It checks if the input sent by the user is a valid input for the game every frame. If there is a valid input, it will pass it to the Sequence Buffer Controller.

Inputs allowed

  • W = up
  • A = left
  • S = down
  • D = right
  • P = punch
  • K = kick

2. Sequence Buffer Controller

src/controllers/sequence-buffer-controller.js

This controller accepts the valid user input every frame. It builds a buffer "stack", which is a list of user inputs over the last X frames. The larger the stack window, the longer the user has to input a sequence command. Once the stack is filled up, the inputs will be removed first in - last out (the oldest input will be removed from the end of the buffer stack).

Note: If the player send no inputs, the buffer stack will still record that no input was received, and will fill that frame with an empty input.

After the buffer stack is updated, it will check for a sequence match from the player's character move list (src/data/test-player.js). It loops through every move's sequence and checks the stack for a complete pattern match. If there is a match to any sequence, it will emit an event on the player, which will be caught by the Actions Controller.

Example: to throw a fireball like Ryu, you have to input QCF+P - or simply - Down, Down-Forward, Forward, Punch

Also note that the player move list is prioritized. This way, more complicated moves or moves that overlap, will take priority over simpler moves.

Example: A fireball requires the same input as a Punch. The only difference is you have to do Down, Down-Forward, Forward before pressing Punch. With prioritization, if you input a fireball, you will get a fireball instead of a standard punch.

3. Action Controller

src/controllers/sequence-buffer-controller.js

This controller listens for move events. Once it receives one, it will simply check the player's current state, and verify whether the player is able to execute the move that was emitted, and fire it.

There has to be a check against the state of the player, otherwise you would be able to cancel any move into any other move. This is just a simple version, but it can get more complex once you start to add cancelable moves, airborne moves, etc.

Attributions

This proof of concept uses an altered version of John Cheeseman's phaser3-webpack.

input-sequencer's People

Contributors

developwisely avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.