R0J0hound's Recent Forum Activity

  • Would it work to use the action in your first post under a every tick event, only change 30 to 30*dt?

  • One way could be to do this. Each is a seperate event.

    Global number numPicked=0

    Every tick -> set numPicked to 0

    Family: is dead -> add family.pickedcount to numPicked

    Family: is running -> add family.pickedcount to numPicked

    NumPicked=family.count -> trigger action

    Or you may be able to do this with two conditions in one event.

    System: pick family by comparison family.dead+family.running>0

    System: compare family.count=family.pickedcount

    ->trigger action

  • It's basically a flood fill. For the wires start at the power source and then power all the connected wires, then loop over those wires and power what is connected to them and repeat. To address wires being cut you can set everything to be not powered before spreading the power from the source.

    The hull breach can be done similarly, only the fill starts from outside the ship.

  • The function is cr.angleTo(x1, y1, x2, y2) and it's in common_prelude.js. It's a helper function that is used throughout the runtime, so the likelihood of it breaking later on is near zero. There are also a lot of other functions in that file that can by useful.

  • It's a difference between webgl and html canvas rendering. Webgl only draws the pixels inside a polygon whereas html canvas draws along the edge as well. For a solution you can use a sprite for the line and paste it to paster.

    Here's a way to position a line:

    https://www.scirra.com/forum/viewtopic.php?f=147&t=76296&p=631921&hilit=line#p631921

  • Just to add that the "pick by uid" condition is the exception to the rule about picking since r127.

    https://www.scirra.com/construct2/releases/r127

  • You don't always need an expert to answer every question. If the question isn't directly tied with c2 the internet is a vast resource that can provide solutions or tips on how things are done. Even if it isn't then you can expiriment with the lab which is c2. My computer is filled with examples I've done to figure out how things work.

    I'm not saying you shouldn't ask questions, rather there are ways to figure it out on your own.

    Also keep in mind that most experts don't just know an answer, but if it sparks their interest and they have the time they sometimes can find a solution. The key word being "time". And all users, including you and even the brand new users can be one of the "contributing experts" if you take the time to find an answer to a question.

  • QuaziGNRLnose

    Ok, I found where the webgl texture handle is in the __webglTexture attribute of WebGLRenderTarget.

    var rendertexture = new THREE.WebGLRenderTarget(100,100 );
    //texture to use with setTexture()
    rendertexture.__webglTexture[/code:2w4vnv08]
    
    The problem that I've found after that is the texture still won't work since by default textures aren't shared between different contexts.  But there is a way to share it:
    [url]http://www.khronos.org/webgl/wiki/SharedResouces[/url]
    
    From that page I found this tidbit of code that shows what needs to be done to share textures:
    [code:2w4vnv08]var gl1 = someCanvas.getContext('webgl');
    var sg1 = someCanvas.getExtension("WEBGL_shared_resources");
    var gl2 = someOtherCanvas.getContext('webgl', {
        shareGroup: gl1.shareGroup
    });
    var sg2 = someOtherCanvas.getExtension("WEBGL_shared_resources");
    var tex = gl1.createTexture();
    sg1.releaseSharedResource(tex);
    sg2.acquireSharedResource(tex, gl.READ_ONLY, function() {
       gl2.bindTexture(gl.TEXTURE_2D, tex);
    });[/code:2w4vnv08]
    
    I'm still working out the details for getting it working but a few points I have so far.
    1. The first context doesn't need to be created, we can get it from this.runtime.gl.
    2. For the second context it seems we have to create the canvas and context for WebGLRenderer first and then pass them as parameters like this: [code:2w4vnv08]var renderer = new WebGLRenderer({"canvas":mycanvas, "context":mycontext});[/code:2w4vnv08] The context creation can likely be copied basically from what threejs already does plus the shareGroup stuff.
    3. The bindtexture() function should be replaceable by the set Texture() function.
    
    I hope to have it more ironed out later.
    
    Edit:
    Well it seems that resource sharing isn't implemented as of yet...
    
    Edit2:
    After further testing the idea won't work.  I also tried making threejs use the same canvas and context as c2 but it's giving errors, probably due to conflicts in gl states from the two.  So Ashley's solution is probably the best you can get at the moment.
  • I did about the same thing in my canvas plugin to get a webgl texture and had the same effect of being slow.

    If you look in the text object it uses a function from Glwrap that just copies the pixels from a canvas to a webgl texture instead of loading a new texture each time. I haven't used it yet but it should be a bit faster especially since it should give less for the gc to collect.

    That sounds interesting that three.js can render directly to a texture. As far as I'm aware c2 uses just a standard webgl texture handle. I'll try to investigate furthur when I get to my PC.

  • Try Construct 3

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

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

    Feel free, I don't have any restrictions on the use of my plugins.

  • The closest you can do is perhaps use the canvas plugin (third party). With it you can get individual pixels from just the object's image. Besides that there isn't a way currently to get the color under the mouse for the whole game area.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 157 followers

Connect with R0J0hound