R0J0hound's Forum Posts

  • I fiddled with this earlier. C2's runtime actually uses localStorage to store the saves. I had no luck figuring out how to access it from either JavaScript with execjs or with the local storage plugin itself. I may have missed something though.

  • It's not that it can't be changed. It can be changed to store speed and angle of motion instead of xvelocity and yvelocity. The only other tweak would be when gravity is applied it would have to switch to x and y velocity for the calculation since it changes both speed and angle of motion.

    The real issue is this is a breaking change, the affects the behavior's behavior and can change how existing projects work. Personally i'd like it changed but then again I don't have commercial projects relying on the previous behavior.

  • It was reported before a few times. The crux of the issue is speed is stored as X and y components, and the speed and angle of motion are calculated from that. So when the speed is zero both components are zero and the angle of motion is calculated as zero.

  • Try it and see.

  • I just tested it with "paste layer" and it indeed doesn't work. It works with pasting sprites though. The matrix transformation is probably wrong or something. For now I'm not going to fix it, but at least it's known now.

  • Replaying input would be hard to get exact. I mean you could save the time with the input used but as you said, a variable framerate would through it off.

    You could change your logic to run a fixed number of times per second so input would only be handled at those times. Then to keep things smooth you'd interpolate object positions between logic steps. The pro is replays will be practically exactly the same, but the con is a huge invasive rewrite of your game. Probably too tedious to do since you also wouldn't be able to use behaviors since we can't control when they update.

    The first idea you said won't work sounds better. It can be made to work with different types as well as with objects getting created and destroyed. The simplest way to save a frame would be to take an empty array and the for each of each object type, push it's name, its position and any other info. When that's do you can store it in another array by using array.asJson of the first array.

    Loading a frame is then just a matter of taking one of those json strings, loading it into an array and looping over it and creating objects based on the saved name. Basically just recreating everything every frame.

    To have it work with varying framerate or a different playback speed you'll need to save the time with the json of the frame, and then interpolate between the two closest frames.

    An example is needed here to fully illustrate it. There are probably a few nuances I'm not thinking of.

  • There probably is nothing i can do about that.

  • It's expected since when you destroy an object it's not removed till the next toplevel event.

    So right below event 25 in the first image, or right below event 23 in the second.

  • Here's the other slightly differecnt method:

    https://www.dropbox.com/s/df8jtstjva45m ... .capx?dl=1

    /examples34/road2.capx

    Cars track to the line defined by the road's position and angle. The result is some smoother turning.

    The intersections are done by picking a random outgoing road in roughly the direction the car is facing.

    The car car interactions is slightly different too. If there's another car ahead it stops, but if it's clear further ahead it keeps going. This works well for the most part but it fails pretty bad if cars cross paths in an intersection so they drive through each other.

  • Prominent

    It may be because C2 didn't redraw yet. So it doesn't matter what you draw to the object before grabbing the canvas, because c2 hasn't redrawn the canvas.

    Edit:

    Also I cannot reproduce the flicker issue. Can you show the event used?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Prominent

    A quick look shows it doesn't draw right with negative dimensions, but you can make it negative, paste then make it positive again:

    Every tick

    --- canvas: set width to -self.width

    --- canvas: paste layer 1

    --- canvas: set width to abs(self.width)

  • That "load texture from canvas" doesn't work reliably with webgl on since it relies on undefined behavior of the webgl spec. I never got around to removing it.

    That said, it makes sense to me that it would clear only if you clear last. If you cleared first, it would clear but then it would be filled with a copy of the canvas.

  • Hmm, interesting. I've never enountered that. Then again I haven't used webgl in a while either.

    I probably won't be able to look into it very soon.

    Webgl queues up draw calls until a "present" or "flush" call sends everything to the gpu to draw. If you're interested in tinkering with it you can try adding glwrap.flush() to the end of the paste function in the plugin's runtime.js. It may not be that exactly though. It might solve the out of order issue, but it will also make it slower.

  • Prominent

    The paste actions will draw objects as they appear. So to flip it you need to flip after pasting.

    Every tick

    --- canvas: paste layer 1

    --- canvas: set width to -self.width

    The last game I bought was probably coming up on four years ago. Typically it's 0 a month though.