R0J0hound's Forum Posts

  • Pretick is the very next spot we can run code after the game draws, and since C2's snapshot runs right after a draw, this will get you pretty close.

    Best I can tell telling the runtime to redraw before using imageUrl is needed. The snapshot function does this and I recall it not working if we don't.

    By boolean I mean something you'd add to your code. Something like this:

    action()

    {

    this.grabcanvas = True;

    }

    pretick()

    {

    if (this.grabcanvas)

    {

    this.grabcanvas=false;

    ...

    }

    }

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use y=sqrt(r^2-(X-a)^2)+b where a,b is the center and r is the radius. That would give the equation for the top half of the circle. Make the sqrt negative to get the bottom half. There's an example of this in some terrain destruction using tilemaps elsewhere on the forum.

    Or you could just loop over all the pixels and draw the pixel if this is true:

    R^2>=x^2+y^2

    Replace X with (X-a) and y with (y-b) if you want to center the circle at a,b instead of 0,0.

  • Still it isn't an issue if your game doesn't lag. If it's really bothering you, file a bug report. I'm sure Ashley can give you a much better explanation than me.

    time is just the game clock, it's advanced by dt. Dt is affected by the time between frames and timescale. Now when the time between frames gets too big c2 will limit it, which is what you have a problem with. This was done on purpose to slow down instead of letting objects move too far per frame and miss collisions.

    Consider an object with a speed of 600.

    At 60fps it will move 10 pixels per frame.

    At 10fps it would move at 60 pixels per frame.

    So if walls were only 32 pixels wide, the object could move right past it.

    Limiting dt helps with this.

  • I don't see any reason for it. If dt wasn't limited objects would teleport quite far if you hit a loop like that.

  • 99Instances2Go

    I think normal picking works well for that sort of thing already.

    I do think it could be handy to be able to save a copy of the list of picked objects to a variable, but there are issues when objects can be destroyed.

  • corpvs2

    Top view can be done by setting the gravity to 0.

    To break up physics objects it's either a matter of using an animation or creating the fragment objects over the object, then destroying the original object.

  • Can't look at the capx because it uses plugins I don't have installed. You can look in preview.js for the exact implementation but if you had to do dt and time with the event sheet this is what it would look like:

    global number time=0

    global number previoustime=0

    global number dt=0

    every tick

    --- set dt to min(0.1, wallclocktime-previoustime)

    --- set previoustime to wallclocktime

    --- add dt to time

  • Looks like the closest you can get to the runtime snapshot is to use pretick.

    Basically run this when the plugin is created:

    this.runtime.pretickMe(this);

    Then when you run the action to capture the pixel, you set a boolean in your plugin and tell the runtime to redraw.

    this.runtime.redraw=true;

    Then in pretick you'd grab it.

    I wouldn't call drawgl directly. I mean you could but it would be very slow. Getting pixels from the canvas is slow anyway. What we're doing is grabbing the entire canvas and loading it into an image, which can take several frames. If you called drawgl directly you'd just be making the runtime draw something it would draw anyway.

  • CreativeMind

    None to my knowledge, but I only use HTML export. However there shouldn't be since it's just math an JavaScript and JavaScript should ru the same everywhere.

  • How far have you got it? The cvs is just a file. You can use the AJAX object to get it into a text variable. You can then use the tokenat expression it get indavidual values from it.

  • Are you saying it is, or are you asking how?

  • I think the answer is in c2's runtime with it's capture action. It doesn't grab the canvas right there, instead it grabs it later (I think it's right after the next redraw).

    I was fiddling with that with the paster plugin before and you have some places in the plugin that's run at different times.

    Two that come to mind are the tick() and tick2() functions. I forget if there are others. One is run before the event sheet and one is done after. You do have to tell the runtime to call those functions with I think a tickme() call? Searching for tick2 probably would give a post with more info as I recall, as well as any I'm fogetting here. Anyways my guess is in those places might be better times to grab the canvas, but it's kind of test and see.

    Basically the process would be to set a Boolean with your action and in the tick function it would check if the Boolean is set and then do what your action does currently.

    The idea can probably be more definite, you just need to break down what the runtime is doing. Off hand I think it looks something like this? I'd have to verify where the capture is done.

    Tick()

    Events

    Tick2()

    Capture canvas

    Draw

    Repeat

  • One thing I didn't cover was in the action right before the callback you see the line:

    var self=this;

    Then inside the callback self is used instead of this. The reason for that is "this" is the object instance inside the action, but when the onload function is called "this" is instead the global variable space because the function is called without a object. You can find more information by googling "JavaScript this".

    Anyways that just means to just use self instead of this everywhere inside the onload function. If you used "this" instead it would explain why the instance variables aren't being changed.

  • ye7yakh

    Is the canvas size the same as the image size? If they're not that could explain the slightly off white next to the black from resizing I suppose.

  • In js as soon as you give a URL to img.src the image will be loaded asycronously and when it finishes it calls the function at img.onload. It's an html thing.

    Yeah you'd probably want to want to wait till the image load trigger to draw it to the canvas.

    It should work fine getting a 2d context because it's using the new canvas created right above it.

    The preserveDrawingBuffer setting is slower when it's on which is why it typically is off. The fact readpixels worked once with that flag off probably has to do with undefined behavior since it's not supposed to work when the flag is false. As far as I can tell, you can only set that flag when first getting the context, aka when the runtime creates it. But ya it's not really acceptable for a user to have to make that change when using such a plugin. :p

    If the image URL idea isn't working paste the code for that function and the trigger it calls. The events should look like this:

    On click

    --- get pixel at X,y

    On pixel got

    --- set redvar to pixel.red