R0J0hound's Forum Posts

  • You can either use one sprite and make it's collision polygon detailed enough to match the shape... Or you could use a bunch of sprites positioned and rotated to cover the shape.

  • You do not have permission to view this post

  • "while" can be very useful to use. No reason to avoid it. You just need to make sure you're not causing an infinite loop by using it.

    The method I proposed was to choose a random number and if it's either of the last two values it tries again. The only drawback is it could have the chance of looping a lot if one of the last values gets picked over and over again, but that is a slim chance in this case.

    The method korbaach suggests is to have a list of all the numbers except the two last and choose one of them. Arrays could be used to do it or even text like the following.

    number cur=0

    number last1=0

    number last2=0

    text list=""

    on click

    --- set last2 to last1

    --- set last1 to cur

    --- set list to replace(replace("123456", str(last1), ""), str(last2), "")

    --- set cur to int(mid(list,int(random(len(list))),1))

  • It's in the manual under common conditions:

    https://www.scirra.com/manual/131/common-conditions

  • The "system compare" needs to be in the same block as the "while". It won't work if it's a sub event.

  • This could work also:

    var cur=0

    var last1=0

    var last2=0

    on click

    --- set last2 to last1

    --- set last1 to cur

    ------while

    ------ system compare: (cur=last1)|(cur=last2) = 1

    --------- set cur to choose(1,2,3,4,5,6)

  • This could be a way to do it:

    Just replace centerx/centery with the imagepoint x/y.

  • PixelMonkey

    For accessing the tilemap's collision polygons I found looking at the physics behavior useful.

    Here is the basics of getting them:

    //This is how you know an instance is a tilemap
    inst.tilemap_exists
    
    //This is how you get a list of the tilemap's collision polygons.
    var collrects = [];
    inst.getAllCollisionRects(collrects);
    
    // for example grabbing the first poly like so:
    var c = collrects[0];
    c.rc //this is the bounding box
    c.poly  //this is the tile's collision poly if it has one.
    [/code:3k5mqmbl]
    "poly" is defined in common_prelude.js as "cr.CollisionPoly".
  • Not currently. All layout/layer scaling is proportional. One workaround could be to draw to a paster object and stretch that.

  • lukezero

    It may perform better with webgl off. With webgl "on" a texture copy needs to be done every time the canvas is changed, which is slow.

  • Here's one way:

  • lukezero

    Flood filling is a slow operation, even on desktops, so that could explain why it's very slow on mobile. You could try making the canvas lower resolution with the "resize canvas" action to ease off some of the load, but if your game is running at 1 fps then that would probably not be good enough. You could also perhaps do the flood fill only every x seconds to space out the slowdowns.

  • Momio

    I'm not sure, you'd have to test previous versions to see when it stopped working.

  • Without imagepoints you'll need 3 variables. Two for the positional offset from the center of the parent object and one for the angle difference.

    For the positional offset you can either save it in rectangular (x,y) or polar(angle, distance) coordinates.

    For rectangular:

    every tick:

    --- set child position to parent

    --- child: move child.dx pixels at parent.angle degrees

    --- child: move child.dy pixels at parent.angle+90 degrees

    --- child: set angle to parent.angle+child.angdiff

    For polar:

    every tick:

    --- set child position to parent

    --- child: move child.dist pixels at parent.angle+child.ang degrees

    --- child: set angle to parent.angle+child.angdiff

    To calculate the offset it's probably easier to use polar.

    set child.ang to angle(parent.x,parent.y,child.x,child.y)-parent.angle

    set child.dist to distance(parent.x,parent.y,child.x,child.y)

    set child.angdiff to child.angle-parent.angle

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As it is C2's renderer doesn't let you pass anything but numbers to shaders.

    There are a lot of other values that you can pass to webgl in shaders, including lists of numbers, textures and even lists of textures.

    http://webglfundamentals.org/webgl/less ... -glsl.html

    [quote:24fpga9v]gl.uniform1f (floatUniformLoc, v); // for float

    gl.uniform1fv(floatUniformLoc, [v]); // for float or float array

    gl.uniform2f (vec2UniformLoc, v0, v1); // for vec2

    gl.uniform2fv(vec2UniformLoc, [v0, v1]); // for vec2 or vec2 array

    gl.uniform3f (vec3UniformLoc, v0, v1, v2); // for vec3

    gl.uniform3fv(vec3UniformLoc, [v0, v1, v2]); // for vec3 or vec3 array

    gl.uniform4f (vec4UniformLoc, v0, v1, v2, v4); // for vec4

    gl.uniform4fv(vec4UniformLoc, [v0, v1, v2, v4]); // for vec4 or vec4 array

    gl.uniformMatrix2fv(mat2UniformLoc, false, [ 4x element array ]) // for mat2 or mat2 array

    gl.uniformMatrix3fv(mat3UniformLoc, false, [ 9x element array ]) // for mat3 or mat3 array

    gl.uniformMatrix4fv(mat4UniformLoc, false, [ 17x element array ]) // for mat4 or mat4 array

    gl.uniform1i (intUniformLoc, v); // for int

    gl.uniform1iv(intUniformLoc, [v]); // for int or int array

    gl.uniform2i (ivec2UniformLoc, v0, v1); // for ivec2

    gl.uniform2iv(ivec2UniformLoc, [v0, v1]); // for ivec2 or ivec2 array

    gl.uniform3i (ivec3UniformLoc, v0, v1, v2); // for ivec3

    gl.uniform3iv(ivec3UniformLoc, [v0, v1, v2]); // for ivec3 or ivec3 array

    gl.uniform4i (ivec4UniformLoc, v0, v1, v2, v4); // for ivec4

    gl.uniform4iv(ivec4UniformLoc, [v0, v1, v2, v4]); // for ivec4 or ivec4 array

    gl.uniform1i (sampler2DUniformLoc, v); // for sampler2D (textures)

    gl.uniform1iv(sampler2DUniformLoc, [v]); // for sampler2D or sampler2D array

    gl.uniform1i (samplerCubeUniformLoc, v); // for samplerCube (textures)

    gl.uniform1iv(samplerCubeUniformLoc, [v]); // for samplerCube or samplerCube array

    Some of those could be useful additions to request.

    To do it without official support could be very tricky.

    In webgl/js if you compile a shader you first need to get the variable location in the shader with something like:

    var offsetLoc = gl.getUniformLocation(someProgram, "u_offset");

    Then you'd set the uniform before drawing using one of the functions listed above.

    So basically it's rather simple in just javascript, but you can't do that for C2 since you need it to work with the runtime's batch renderer to get the effect to be applied to anything else the runtime draws. Modifying the batch renderer isn't trivial and is best left to be done by Scirra since a lot of other things in the runtime and editor would need to be done to accommodate it.

    You could just do your own webgl renderer in a plugin to render to a texture that c2's renderer could then draw, but I haven't had much luck in the past grabbing what's already been rendered to modify.