tonarino / bomberman-of-the-hill

13 stars 5 forks source link

Gather/make basic spritework #4

Closed PabloMansanet closed 3 years ago

PabloMansanet commented 3 years ago

I'm assuming 2D rendering, so we'll need some sprites :). I don't know exactly how this will be rendered in the November meetup so I'll leave it to you to define the requirements.

bschwind commented 3 years ago

I don't know how technically difficult this would be, but it would be really cool if the trait players implemented involved a method to draw themselves. They'd be given some sort of Painter object which lets them issue draw commands for basic shapes like lines, circles, rectangles, etc.

We could take those draw commands, limit them to some maximum number, and draw them into a clipped rectangle (so they don't draw themselves on the entire screen, for example)

This could save time on artwork and also let players more easily distinguish themselves.

PabloMansanet commented 3 years ago

@bschwind That's a fun idea, but I wonder if funneling something complex like that through the limited .wasm api is the right call. How about just letting players upload a .png file (or sprite sheet if they want to be fancy) when they upload the wasm?

Alternatively, we could draw the standard model and let them define a Color method that returns their palette, so they can choose their color or even change it on the fly (if the method is called every tick)

bschwind commented 3 years ago

Right, I'm not sure how complicated it would to do something like that. bincode or some other serialization strategy would have to be used, right? Here's my current thought in code, as a rough idea

struct Color { ... }

enum Primitive {
    Line(Point, Point, Color),
    Circle(Point, Radius, Color),
    Rectangle(Point, Point, Color),
    PngImage(Point, &[u8])
}

struct Painter {
    primitives: Vec<Primitive>,
}

impl Painter {
    // Functions which maybe limit the amount of primitives or size
    // of images that can be added.
    fn draw_circle(&mut self, ...);
    fn draw_line(&mut self, ...);
    fn draw_image(&mut self, ...);
}

trait Player {
    fn draw_self(&self, painter: &mut Painter);
}

// Serialize the painter and send over to the WASM module
// WASM module deserializes the painter and calls `draw_self()`
// The painter then goes back through the serialize/deserialize pipeline
// and gets used to generate actual game assets/materials
PabloMansanet commented 3 years ago

That may be possible yeah! I'll explore the limitations of we can do across .wasm and depending on how far we get there we can probably make a better decision :)

skywhale commented 3 years ago
  • Is copyright a problem? I imagine it's not an issue for a fun meetup project, but I'm not a lawyer so asking just in case.

It'll probably fall under a fair use of the copyrighted assets, but let me quickly double check with our layer where a line would be. While the event is mostly a privately held one, I imagine we'll want to photoshoot the event and be able to use them on our public blog.

the doctrine of fair use allows for a court defense for the public performance of a work if you can show the court that the nature and intention of your use was non-infringing, you only used a small amount of the copyrighted work, the nature of the work does not lend itself to a finding of infringement and your use of the work did not affect the intended market for the work.

PabloMansanet commented 3 years ago

Closing this for now as it's provisionally implemented by #17 , though I'm aware there's still an open question on @bschwind idea for custom rendering. I think we can look into it as a stretch goal after MVP :)