Giter VIP home page Giter VIP logo

Comments (7)

Rodeoclash avatar Rodeoclash commented on May 2, 2024 1

That's great feedback. All the feedback has been that it's too difficult. I've tweaked it a bit and removed the rotation (like you comment) and it plays a lot easier. Try refreshing that heroku site to see what I mean.

Shame though. The original control scheme was similar to "Gravity Power" on the Amiga. I'd like to build some kind of dog fighting or racing game using that control schema still - but for previous version, well I don't think I'd ever get another job due to the difficulty of it, haha.

from matter-js.

liabru avatar liabru commented on May 2, 2024

Is using resurrect-js a requirement for serialisation? I didn't have any problems not using it but might be setting myself up for trouble later.

Nope, it's just the first library I found to work best at handling serialization in general. Any lib that can handle complete serialization of JS objects should work. But it seems many simply don't handle all the edge cases properly such as preserving dates, floating point values, null, true, false, Infinity etc which can cause issues.

How do I take a serialised object / world and restore it? Just feed it into the create function?

When you deserialise the object should perform (ideally) identical to the one you serialised. So if you serialise a body instance, you should be able to just unserialise it and use World.add(body) just as if it had come out of Body.create.

Also I wouldn't advise passing them through constructors again, as they don't guarantee to be 100% perfect at recreating the original object so this will be unreliable.

Is their a way of "updating" a created object or is just overwriting the properties sufficient?

It depends on the property, in some cases you can. But there are some cases where updating one property requires a number of other property updates.

In the latest master version there are some new setters for some of the more complex operations (see here). So look for a setter first!

What I suggest is that you have two modes of sync:

  • a full sync where you send a fully serialised world / body
  • an update sync where you manually update important properties (positions, angles etc)

A function that automatically updates any property dynamically would be cool (something like Body.set(property, value) and Body.set(map), this is something that I've considered myself (as I've experimented with multiplayer games in Matter too). I might try something like it when I get time.

For now if you just need a quick approach that works for a game then maybe do something like the above?

I haven't given any serious thought to debugging the issue were the objects don't interact with each other but does anything spring into mind about where I might start?

Not sure what you mean here, can you send me some code? (feel free to email if its private).

from matter-js.

Rodeoclash avatar Rodeoclash commented on May 2, 2024

Excellent, I'll post a few more comments on how I'm handling some things once I get them going (e.g. using JSON patch to only send changes).

Thanks!

from matter-js.

liabru avatar liabru commented on May 2, 2024

@Rodeoclash

How are you getting on with this?

I've added a new function which you may find useful.

It's Body.set(body, properties) where properties is an object of body properties and values to set. The idea is that it will automatically delegate to the correct setter function if there is one.

I think you'll be able to use it to help automatically apply your object updates?

Try it in the latest master build:
https://github.com/liabru/matter-js/blob/master/build/matter.min.js

from matter-js.

Rodeoclash avatar Rodeoclash commented on May 2, 2024

That's awesome. To be honest, I've been a bit distracted with Clojure/ClojureScript recently so haven't looked at my game since I left it. When I get back onto it though I'll look at using the body set function though, it looks perfect.

I wound up using a different JSON serialiser in the end, I didn't have a good result with resurrect-js. Besides that, it didn't have any AMD / CommonJS integration making it a pain to use with WebPack. I've gotten as far as serialiser the objects and sending them over the wire, I still had a few bits to debug with the interactions with the created objects.

I should finish up my Clojure stuff soon so I'll be back on the game :)

from matter-js.

Rodeoclash avatar Rodeoclash commented on May 2, 2024

For what it's worth - here's the start of the game. I've built a scaled down, single player, version for my CV but ideally would like to adapt into a multiplayer game at some stage.

http://richardson-homepage.s3-website-ap-southeast-2.amazonaws.com/

from matter-js.

liabru avatar liabru commented on May 2, 2024

Nice! Interesting concept for story telling. The ship seems a little hard to control though, I'd probably prevent it from rotating and just have upwards motion against gravity, maybe allow a little side to side motion at a slower rate when pressing the left and right keys.

from matter-js.

Related Issues (20)

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.