Code Monkey home page Code Monkey logo

pf_sandbox's Introduction

PF Sandbox Build Status

A platform fighter featuring a character editor tightly integrated with gameplay.

Quick links

OS/Controller requirements

  • Windows 10: Xbox controllers + native GC adapter
  • Other Windows: Unsupported
  • Linux: All controllers + native GC adapter
  • Mac OS: Unsupported

You cannot use a keyboard to play, you must use a controller.

Goals/Features

  • Package system used to distribute complete games that run on PF Sandbox
    • A package includes:
      • Fighters
      • Stages
      • Rules - Set game mode and mechanics e.g. game length, stock count, l-canceling, ledge-hog mechanic
      • A url specifying where to download updates
    • Package data is serialized into multiple files stored in a folder, allowing individual characters/stages to be easily copied between packages
  • Powerful Fighter/Stage editor
    • Make edits in the middle of a match
    • Use the mouse to select elements for editing.
    • Command line used for viewing/setting selected elements
    • Keyboard shortcuts and click and drag where applicable
  • Replays that do not desync on character/mechanics/physics changes
  • Controller support including Native Wii U -> GC adapter Support
  • TAS Tools
  • Netplay
  • Minimalist but visually appealing graphics

Restrictions/Non-Goals

  • Advanced features need not be beginner Friendly (e.g. editor/frame advance/replays/TAS)
  • Ability to recreate other platform fighters does not overrule other advantages (e.g. 2D hitboxes instead of 3D hitboxes)
  • Restricting character graphics to only hitboxes reduces scope for development of the project and development of packages

CI Infrastructure

We build and test on:

  • Rust stable/nightly - Linux 64 bit (Travis)
  • Rust stable/nightly GNU - Windows 64 bit (Appveyor)

We build and test when:

  • All incoming pull requests are built and tested.
  • Every commit merged to master is built, tested and then an incrementing tag/release is created for it.

pf_sandbox's People

Contributors

rukai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pf_sandbox's Issues

Small handy editor additions

Add arithmetic functions to numeric types in treeflection e.g. package.fighters[?].actions[?].frames[*].colboxes[*].point.0:add 10 (useful for shifting all hitboxes in a single action)

Replay Save/Reload

Need to be able to save and reload replays.
Press w to save replay.
Load replays screen lists replays recorded in the current package titled by its timestamp: selecting one will load up a game with that replay.
Store them in ~/local/share/pf_engine/replays. Subfolders for each package, containing the replay files.

ECB editor

Allow the ecb for each frame to be edited with some sort of drag and drop interface.

Improve package save/reload UI

Save

Its easy to accidentally try to save (e key) without pausing first, so we should:

  • Package save should give some visual comfirmation on complete.
  • Maybe change package save to work while playing

Reload

Its easy to bump reload (r key) (especially while trying to save), make the button harder to press or add some sort of confirmation. Maybe hit r three times.

Hitbox arrows and angle setter

1

Player debug toggle that displays an arrow for each hitbox.
The direction of the arrow shows the angle of the hitbox.
The length of arrow is kbg * damage + bkb
kbg * damage half of the arrow should be colored blue

2

Pressing Q should set the angle of selected hitboxes to point to the mouse location.

Bad performance on windows

On windows sometimes the game runs choppy.
CPU usage doesnt look maxxed.
Not sure whats going on, I assume we (or vulkano) are doing something wrong with vulkan.
Waiting for Vulkano to stop triggering validation layer errors in the examples before I look further into it.

Improve surface edge mouse click box

Currently the collision detection for clicking on a surface edge uses a circle at the edge.
This should be replaced with a rectangle that extends the width of the surface but not the length.
This will make clicking feel easy, allow clicking on the whole area of the surface edge and also stop clicking both connected edges.
A simple AABB is not sufficient because surfaces can be at any angle.

Color should be determined by team not port

  1. Add team field to player
  2. Determine color based on team instead of port
  3. Added players will take the next available unused team in CSS.
  4. Add team select option for player in CSS menu.

Save replays from Results screen

Need to be able to save a replay from the Results screen.
Will require a bit of refactoring as currently game data is deleted before the results screen.

Snap surface move to angle.

Ctrl + Shift + Alt are already taken as surface type modifiers, ideally we would use them here but maybe we will need something else.
Hold Shift to snap the currently moving surface to 0, 22.5, 45, 67.5, 90 ... degrees

Alternatively:
We could have a button angle-snap selected surface sides in line to its opposing side.
This means we dont need to free the shift key.
Would have some weird, potentially unintuitive/unhandleable, edgecases.

Implement deterministic random methods

We will need random functions available that are based off a seed which can is stored in replays/synced over netplay.

Immediate usecase is for the wobble effect during hitlag. But it will also be useful to use with custom stage/fighter scripts.

Replay desyncs

Frame rewind uses player history.
Frame replay uses input history.

By replaying and then doing a frame rewind we can sometimes notice a large desync between the current state (derived from input history) and the current player history.
No idea what is actually triggering the desync though, needs more investigation.

Document how to use GDB on windows with msys2

I tried pacman -Syu mingw-w64-x86_64-gdb
But when I run gdb, I get no output, gdb closes immediately returning some non zero exit value.
I assume I am doing this correctly so will follow up/report a bug/ask around later on.

Treeflection inflicted issues

There are a bunch of ways to either crash or put something into a broken state via treeflection commands.
Ideally these will all be fixed but for some of them there is substantial work involved and other trade offs that make fixing them unpleasant.

So for the mean time I will just keep track of them here:

  • package:default

More accurate camera controls

Clicking and dragging with middle click will pan the camera.
It pans a static amount which means:

  • when zoomed in it moves too quickly
  • when zoomed out it moves too slow.

Instead it should pan the appropriate mount for the current zoom so that the screen moves at the same rate the mouse moves across the screen. (Just like moving hitboxes with a)

Menu keyboard & mouse controls

Currently menu screens can only be controlled by a controller

  • If all controllers control the same cursor on a menu screen then it should also be navigable by keyboard.
  • All menu screens should also be clickable by mouse.

Generic controller support

Support controllers other then wiiU->GC adapter
This library looks good: https://gitlab.com/Arvamer/gilrs

Will need to handle mapping from generic controller to GC controller:

  • Load serialized mapping data from files in the directory PF_Sandbox/controller_maps/ (created if doesnt exist)
  • Use the naming scheme: $osname-$controllerID.json
  • If the required mapping file does not exist:
    • create it with a known correct mapping stored in the binary
    • otherwise use a generic mapping that will certainly be wrong but from here the user can modify it to be correct.
  • Maybe have a controller debug mode (cli flag to enter mode) that prints the controller buttons/axis ids to stdout. so the user can figure out what ids to use in the mapping file

Osu style package drag and drop

Osu allows easy importing of songs by drag and drop.
Similar functionality would make importing packages more intuitive.
Click and drag package zip/folder onto PF Sandbox window to unzip/copy it to PF_Sandbox/packages/

Wont implement for Linux as there doesnt seem to be support for it? And its fairly safe to assume that linux users are not afraid of the filesystem.

Windows API: https://msdn.microsoft.com/en-us/library/windows/desktop/ms678405(v=vs.85).aspx
Will need to add functionality to winit to handle this.

Display spinner when graphics thread does not receive display data on time

Loading packages takes a long time and there is no feedback to the user that pf sandbox has not crashed. (package load to graphics thread also occurs in game when manipulating package data)
It should be easy to make the graphics thread display a little spinning triangle or something if it doesnt receive a frame on time.
Loading times + user feedback should be improved in other ways, but this is a (simple) quick fix.

Crashes on Linux

Caused by the upgade to vulkano 6.0.0
Commenting out text rendering prevents the issue.
Will run for a few seconds before crashing with:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: AccessError(AlreadyInUse)', /checkout/src/libcore/result.rs:860:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:397
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:572
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:498
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:71
   9: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:41
  10: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:738
  11: pf_sandbox::vulkan::VulkanGraphics::render
             at vulkan/mod.rs:301
  12: pf_sandbox::vulkan::VulkanGraphics::run
             at vulkan/mod.rs:239
  13: pf_sandbox::vulkan::VulkanGraphics::init::{{closure}}
             at vulkan/mod.rs:83

Allow TAS tool to manipulate game flow state

TAS tool needs to be able to perform the following on the game state:

pub enum Flow {
    Stop,
    Play,
    Rewind,
    Replay,
    StepFrames   (u64),
    RewindFrames (u64),
    ReplayFrames (u64),
}

To do this we need to implement treeflection actions for each.
But we will need to refactor Game to hold Input and OsInput to achieve this.

Write tests

Gameplay should not be tested. (at least at this point)

A simple functional test could be:

  1. the game can be booted headless cargo run --no-default-features -- -p2
  2. wait 10 seconds
  3. frame1 = pf current_frame:get
  4. wait 1 second
  5. frame2 pf current_frame:get
  6. assert frame2 > frame1

Also the infrastructure such as package downloading/saving/reloading would definitely benefit from some unittests.

Create stages/fighters in menu

Rather then creating a menu option for this, which will normally go unused and clutter up the screen.
It will be accessible via treeflection.
We just need to be able to run commands while in the Menu which will be run directly on the package.

speedup treeflection commands on package.

To achieve this: commands run on the package should be stored in package_updates instead of a clone of the package.

Or maybe I should scrap the current system of precompiled buffers and just generate the buffers each frame.
When I originallly did generate each frame, it was too slow, but I suspect that was only because I had no idea what I was doing. (Maybe I wasnt even doing cargo run --release)
In particular using sin/cos to generate circle vertices is much slower than it needs to be.

UI rendering

Improve UI rendering for both in-game HUD and the out of game menu.
Its currently very trashy and looks like it needs to be entirely reworked.
A layer of abstraction between UI rendering and vulkano could be nice as well.

Linux: Vulkan window resize brings OS to a halt

On linux resizing the window on the vulkan backend, makes the entire OS incredibly unresponsive. You will probably need to hard power off after this.
This is really bad!
It seems to be a problem with vulkano, it also looks like we are waiting for the next release?
Vulkano issue

computer players

To add computer-controlled players we need:

  • A way to setup computer-controlled players on the fighter select screen
    + Left/Right dpad to add/remove computer players
    + Directly after adding a computer player the controller who did so must choose the fighter the computer player will use and then choose the AI the computer player will use.
  • A few generic AI's to choose from
    + Do nothing
    + Just Walk
    + Just Jump
    + Basic fighting AI
    - This will always be terrible because it wont know how to correctly play the fighter)
    - We could read the hitlag and frame data of the moves to determine which moves are better in the current situation, but theres not much point because a custom AI will always be better.
  • Custom AI's implemented via scripting

There is an immediate need for an easy way to get a dummy fighter so we should first implement a minimal version.
It will only allow adding/removing computer players and would be equivalent to running pf_sandbox -- -p2 with one controller.

Add treeflection for PackageHolder

  • impl Node for PackageHolder
  • change treeflection commands run during menu to run on PackageHolder instead of Package.
  • Add a treeflection method to PackageHolder to allow creation of new packages. (dont allow loading of packages)

Fighter mechanics

Advanced custom fighter mechanics will be enabled by scripting when that is added. #10

However, coexisting with scripting, there will be a bunch of cookie cutter mechanics available.
Each fighter can toggle these on/off and there is some level of customization for them.

Player mechanics that are currently missing:

  • Power shield // Can still be enabled while regular shield is disabled
  • Shielding mechanics
    • Shield
    • Analog shields
    • Shield aiming
  • Knockdown
    • Knockdown state
    • Getup states
  • Tech
  • Spot-dodge
  • Roll
  • Grabs
    • Throws
    • Pummels
  • Wall jump
  • L-cancelling
  • Improve current mechanics (physics and state transitions)

pf_tas GUI

Scrap all existing graphics and redo with:

  • Render GC controller diagram displaying buttons as pressed/held/none and stick/trigger values
  • Display controller selector as 'tabs'
  • Named toggle buttons for the various settings mapped to QWER
  • Buttons for Game flow control mapped to Enter, Space, ZXCV

Teams Logic

  • Take teams into account when deciding winners.
  • Implement team-funnel hitbox properties
  • Implement team hit Hitbox
  • Either use or get rid of rules.teams (I'm leaning towards get rid of, team hits should be decided at the hitbox level)

Overlapping fighter rendering

Currently when two fighters overlap, one of them is just drawn on top of the other.
Instead, we should blend the colors.

A mockup of what it should look like:
2017-10-16-overlap-design
It looks quite gross but players wont stay in this state for long as ECB collision will push them apart.

Rework stages/platforms

Stages/platforms are currently very simple.

More features are needed including:

  • wall and ceiling collisions on platforms
  • angled platforms
  • moving platforms

In order to achieve these they will likely need to be completely reworked.

Make editor keys remappable

Should be able to remap editor keys to an expression containing buttons from both keyboard and controller.
Configure through /home/rubic/.local/share/PF_Sandbox/config.json

Plug'n play GC adapter on windows

Note that this is super low priority, most users have this setup for dolphin anyway.

Currently we rely on the user manually setting up the winusb driver via zadig to allow PF Sandbox to talk to the GC adapter.
Internally Zadig is using: https://github.com/pbatard/libwdi
We can either:

  • Create a rust wrapper for libwdi
  • Rewrite libwdi in rust (Starting with just the subset of functionality that we need)

Windows update sometimes overwrites the winusb driver so we could either:

  • Always install on launch
  • Install on failure to connect to adapter
  • Have a menu option to install it.

Netplay

Wew.

Netcode

Try GGPO style first, if analog inputs cause too many issues then try dolphin style.
(Maybe theres some sort of middleground?)

UI

CLI

TODO: CLI switches for hosting and connecting

Menu

Need screens for:

  • Waiting for client
  • Failed to connect to host

Other

We also need to verify package hashes are equal.

Stage Editor

On match Edit::Stage there should be stage edit logic.

Stage scripting will move, delete and add platforms from the initial state.
The editor will edit the state of the platforms on the current frame.
Run the command :copy_stage_to_package to copy the state of platforms in the current frame to the packages initial stage state.
The package can then be saved with the regular package:save

Automate packaging process.

Problem

Currently PackageMeta.source is an option, this lets us tell if there is a remote location to check for updates at.
However there is currently no way to specify that:

  • we are locally editing a package that should receive updates when used by others but we are editing it so dont want that.
  • we are editing someone elses package for lulz and we dont to erase our changes when an update occurs. (this is easy to work around currently, just set PackageMeta.source to None)
  • a published package should not be modified, (As it will be erased on update it is unfriendly to the user to allow them to edit it)

Solution

Main

Add PackageMeta.locked: bool

Will not retrieve updates for an unlocked package.
Treeflection package:save will fail on a locked package. (Need to manually unlock via editing the package_meta.json)

Publish command

Add a treeflection command package:publish
At the path: ~/.local/share/PF_Sandbox/publish/ the current contents will be deleted and then it will create:

  • packageNNN.zip file containing the package
  • package_meta.json file required by the updater process

Both produced package_meta.json files will have PackageMeta.locked set to true.
The original package_meta.json will will be unmodified.
Increment PackageMeta.save_version on package:publish instead of save (and probably rename to PackageMeta.published_version)

Scripting

This is a big vague issue, I'm just collecting/publishing ideas here.

Needed for

  • give fighters unique special abilities.
  • unique game mechanics
  • Ledge getup actions will use it for the following:
    • what frame to stop hogging
    • what frame to actually land/give control back to player
    • position offset from the ledge for each frame

Language choice

There a lot of options. The main ones include:

Rlua

  • lua binding

Hlua

  • lua binding

Rhai

Dyon

  • Functional

Gluon

  • Functional

Roll our own

  • Would integrate better with treeflection
  • Tailor syntax to our needs
  • Would never be as nice as a proper language, dont have the resources to devote to such a task.

Scope

The scope for the scripting language is very important, some potential ideas:

  • Move all game logic into script callbacks, things like collisionbox/stage collision are kept in rust.
  • Each character gets their own script which is called during their step method.
  • A unique script is stored for each action or frame for each character

Example Lua API

For each fighter there is a fighter.lua file containing the following functions:

spawn(usize player);
action(usize player, usize action, usize frame);
hitbox_collide(usize player, usize action, usize frame, int collision_flags);
hurtbox_collide(usize player, usize action, usize frame, int collision_flags);

The functions are called by pf sandbox when each event occurs.
They have access to an api:

set_acc_player(usize player, float x, float y);
get_acc_player(usize player, float x, float y);
set_vel_player(usize player, float x, float y);
get_vel_player(usize player, float x, float y);
set_pos_player(usize player, float x, float y);
get_pos_player(usize player, float x, float y);
set_action(usize player, usize action);
generate_entity(String name, float x, float y);
random(int max); // seeded determined at start of game + frame_index
// high and low level input e.g. can_jump and press_x

Fullscreen toggle

Handle Fullscreen toggle (Alt+Enter) + save in config.json

Blocked by issue #3

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.