Coder Social home page Coder Social logo

runty8's Introduction

Runty8 Logo

Runty8

A Pico8 clone in Rust.

Making your own games

Head over to our template for an example to get started!

Crates

  • runty8: Main entry point for games created with Runty8. Most Runty8 users should probably only depend on this crate.
  • runty8-core: Core types needed by every Runty8 related crate
  • runty8-runtime: Run standalone Runty8 games in native or wasm targets
  • runty8-editor: Run game inside editor
  • runty8-winit: Integration layer for winit
  • runty8-event-loop: Thin layer over winit/glow/glutin to have a cross-platform OpenGL/WebGL-powered event loop

Contributing

See the contributing guide for instructions on how to get started.

Examples

Celeste playthrough

Running

Run examples (celeste, moving_box, confetti) with:

cargo run --bin celeste -- --game
cargo run --bin confetti -- --game
cargo run --bin moving-box -- --game

Or run cargo run --bin to get a list of the available examples.

Press the Escape key to switch between the game and the editor.

runty8's People

Contributors

arturamiryan avatar erlend-sh avatar jjant avatar lesleyrs 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  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  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

runty8's Issues

Investigate rendering alternatives

Description

Rendering is currently implemented using Glium. I picked this library initially because it was the only one I was familiar with.

My main concerns with it are that it looks like WASM is not supported (which we do want), and that compile times may be excessively long for what we need (we only need a handful of OpenGL functions).

Possible alternatives

Fix editor using the game's sprite sheet for its own assets

Description

Currently, if you run any game: cargo run --bin celeste, the editor will look wrong:

image

This is because we're using the same pico8.spr(...) functions for rendering editor sprites, but these use the current game's sprite sheet.

To fix this we want to load the editor sprite sheet separately and use Pico8::spr_from instead: pico8.spr_from(editor_sprite_sheet, ...).

We probably only want to tackle this after #16 is done, as the current setup allows editing editor sprites directly from the editor (by running cargo run) which is useful.

Boot animation

Description

Pico8 has a pretty cool boot animation:

Pico8_BootAnimation.mov

It'd be nice to have our own, it doesn't have to match Pico8's exactly.

Given that we don't currently have a command line, the boot sequence should land you in the editor.

Replaced files not being noticed by Cargo

I noticed with replacing the asset txt files you don't need to use cargo clean if you just save it after replace. Then I noticed that if you save the replacing file after using git checkout . to reset local changes, cargo run will actually pick it up. So I believe this isn't related to include_dir but Cargo itself specific to Windows?

rust-lang/cargo#9598 (comment)

I think Windows copy preserves the timestamp (whereas unix doesn't do that by default), so if you copy a file in with an older timestamp, it won't rebuild.

It mentions this issue tracking it rust-lang/cargo#6529

I'm a little confused how include_dir works though, it has a metadata feature that doesn't seem to be used? So is it only used for embedding files now?

Implement Zoom tool in Sprite Editor

Description

Pico8 features this zoom tool: image which lets you edit a bigger portion of the sprite sheet at once.

It allows selecting between 4 zoom levels:

  • 1X (1x1 sprites)
  • 2X (2x2 sprites)
  • 4X (4x4 sprites)
  • 8X (8x8 sprites)

Setting flags while selecting many sprites (with the >1X zoom levels) sets the flag for all sprites in the selection (general care is needed around flags in these cases).

Examples not running on Windows 11

After cloning the repository I am getting an error when I try to run any of the examples.:

cargo run --bin moving-box -- --game
...
Loading assets from: C:\Users\Charlie\code\r8\runty8\examples/moving-box
Couldn't find file for asset: map, creating a blank one.
Couldn't find file for asset: sprite flags, creating a blank one.
Couldn't find file for asset: sprite_sheet, creating a blank one.
Running editor...
thread 'main' panicked at 'called Result::unwrap() on an Err value: NoAvailablePixelFormat', src\runty8-event-loop\src\lib.rs:127:18
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
error: process didn't exit successfully: target\debug\moving-box.exe --game (exit code: 101)

`btn()` and `btnp()` not working consistently

I don't think this is a big deal but there's a problem with both btn functions.

Btn works fine if you hold it down, but if you press repeatedly it will often ignore presses.

Btnp is mostly broken, ignores many key presses.

In both cases when I check by printing if they're held down it does register correctly. Even if pressing Btnp very slowly and the game knows it's not held down it will mostly not react to it. Can be reproduced in the game template by just changing a key to btnp. So is this an upstream problem?

This does not affect me because the Btn problem only matters if you have a game where you need very rapid key presses. Btnp is very clearly broken though.

Fix Editor not correctly picking up its assets

Currently the editor picks up the game's assets (sprite sheet, etc) to displays its own icons, which leads to problems like this:

image


A solution would probably be to include_str! the sprite sheet, put it in a once_cell::Lazy and add a Pico8::editor_spr method through an extension trait that the editor calls.

Pico-8 variable arguments in functions

For stuff like print() in Pico-8 you can leave out x, y and it will just add 6? to y in the local scope. Is this even possible to do in Rust? Just wondering.

Support gif recording

Pico8 supports recording gifs of your game (pressing F8 to start, and F9 to stop), and it saves the file to your desktop.

`take_new_title` and `debug_run` question

What is the take_new_title function supposed to be used for? It returns the title name but I'm unsure how or why to use it.

Besides that I saw that debug_run/run_editor is running at higher fps than run, that could lead to some problems with timings not being the expected speed when later changing the setting since you can't immediately tell what fps your game is running at. I noticed this when playing a frames based animation but I couldn't really tell when running the example games for some reason? Although I appreciate having this setting available. ๐Ÿ‘

Port Editor sprites

Description

We're missing a bunch of sprites used in the editor (Pico8 screenshot for reference), including:

  • Code editor button (may not be used)
  • Sound editor button
  • Music editor button
  • Tools icons:
    • Stamp
    • Selection
    • Pan
    • Fill
    • Shapes:
      • Square
      • Filled Square
      • Circle
      • Filled Circle
      • Line
  • Zoom (square crosshair in slider)

In Runty8 these sprites are currently implemented as a regular sprite sheet, which you can edit by running cargo run, and save to disk with Ctrl + S.

Build Error

I ran cargo run
but it exit unsuccessfully

Compiling servo-fontconfig-sys v5.1.0 Compiling freetype-rs v0.26.0 Compiling wayland-client v0.29.4 Compiling calloop v0.10.1 error: failed to run custom build command forservo-fontconfig-sys v5.1.0`

Caused by:
process didn't exit successfully: /home/asterisks/projects/learn/Rust/github_project/runty8/target/debug/build/servo-fontconfig-sys-2c68ca559824e33f/build-script-build (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=FONTCONFIG_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=FONTCONFIG_STATIC
cargo:rerun-if-env-changed=FONTCONFIG_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at '"pkg-config" "--libs" "--cflags" "fontconfig" "fontconfig >= 2.11.1" did not exit successfully: exit status: 1
error: could not find system library 'fontconfig' required by the 'servo-fontconfig-sys' crate

--- stderr
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing fontconfig.pc' to the PKG_CONFIG_PATH environment variable No package 'fontconfig' found Package fontconfig was not found in the pkg-config search path. Perhaps you should add the directory containing fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
', /home/asterisks/.cargo/registry/src/github.com-1ecc6299db9ec823/servo-fontconfig-sys-5.1.0/build.rs:34:17
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

`

Force aspect ratio on screen resize

Description

Currently you can resize the window and "break" the 1:1 aspect ratio, this distorts the pixels.
I think we want to allow resizing the screen arbitrarily but fit to the smallest dimension: in a 600px x 800px window, we'd show a (vertically) centered 600px x 600px image.

Come up with a better name

I don't love the name runty8.
Some easy alternatives are:

  • pico8-rs
  • pico-rs

Suggestions are welcome (and encouraged!).

Port more Pico8 games

Description

Pico8 games serve as a benchmark to see that we're doing things correctly, we currently only have Celeste and it'd be useful to have more.
Find Pico8 games and their source code here, please only port those with a CC license.

What still needs to happen for clipboard to be supported?

I can see it correctly saves each pixel in sprite_sheet.txt and shows the copied/pasted message yet it does not work, so if you slap [gfx][/gfx] on a string with the data from current selected sprite we can copy and read it back minus [gfx][/gfx] for paste?

Then we need to be able to access to stat(4)/clipboard to read it in a game/tool.

Is that it?

Also I know Pico-8 has intentional limitations about reading/writing clipboard which is quite annoying for my usecase here: https://github.com/lesleyrs/pico-paint

This is to prevent a cartridge from accessing potentially-sensitive data on the host system's clipboard without the user's permission. - from https://pico-8.fandom.com/wiki/Clipboard

I couldn't find an answer why this would be bad on pico-8 as it doesn't have any built-in network capabilities so the worst that could happen is a game displaying your clipboard on screen, which could be annoying if somebody was livestreaming it and happens to copy his passwords. And even then they wouldn't know their username?

IMO that's not worth being a big inconvenience though, I would much rather have a notification on launch that shows if the application could try to access clipboard. Just like the devkit mode notification in pico-8 informing people.

Thx for coming to my TED talk.

Parallelise CI steps

We're currently running these steps sequentially:

  • cargo build
  • cargo test
  • cargo fmt
  • cargo clippy

These could be easily parallelised to speed up CI.
Feel free to use this example as a reference.

Naming convention for Pico8's overloaded functions

Description

Pico8 uses Lua as its scripting language, which allows overloading functions on the number of arguments it takes.
For example, Pico8's spr function can be called in the following ways:

1. spr(n, x, y)
2. spr(n, x, y, w)
3. spr(n, x, y, w, h)
4. spr(n, x, y, w, h, flip_x)
5. spr(n, x, y, w, h, flip_x, flip_y)

We need to decide various things:

  • Do we expose all 5 versions? We could, for example, only expose the most general one (5) and have the user write their shorthands.
  • If we do expose all 5, how do we name them?
  • We could also just have a general version with Option<T> arguments and expose that instead:
fn spr(n: i32, x: i32, y: i32, w: Option<f32>, h: Option<f32>, flip_x: Option<bool>, flip_y: Option<bool>)

IMO that's pretty ugly, and not much more convenient than having non-optional arguments (and have the user pass in the defaults).

We need to make sure that whatever approach we choose works for all of the Pico8 API functions.

Sprite related improvements

  • always hide cursor since the sprite cursor is enabled, #50
  • Add cutting (Ctrl-x) to sprite editor #50
  • Clean up sprite sheet #53
  • Ctrl-s moves down the currently selected sprite by 1 row: #55
  • what happened to .ppm files being generated on save? - Intentional 3e84646
  • palette swap tool sprites instead of 2 versions #68
  • is cargo clean just required for it to pick up replaced sprite_sheet.txt files? #57
  • save/read to and from clipboard when using ctrl-x/c/v #48 and ingame access

The following are not that important to do right away and don't apply to me that much. Maybe it's better to just put them in comments so we can finish this issue sometime? I think some of these are already commented as well. Or track these in a separate issue with other sprite editor features.

- [ ] change cursor sprite based on what is being hovered
- [ ] undo/redo does not work for pasting sprites, only for the sprite editor itself.
- [ ] right click to grab palette
- [ ] Ability to move the selected sprite using keys: `q` `w` OR `a` `z` with or without `shift`
- [ ] Ability to change the selected palette using keys: `1` and `2` Also fun idea with this: allow shift modifier to move 2 palettes at a time and it has more features than the original pico8

I didn't expect to be thinking about this many things when just drawing a few sprites but there you go. I don't want to track the actual sprite editor features here as it's already excessive.

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.