R0J0hound's Forum Posts

  • It very well may not work since I haven’t tested it.

  • Pretty mesmerizing. Would make a great screensaver.

  • Look at the second answer here:

    stackoverflow.com/questions/14521108/dynamically-load-js-inside-js

    It shows a way to load a script without jquery. Basically create a script element, set the source url, set the onload function, and finally append the element to your html document somewhere.

    That’s probably only the first half of making it work in c3. The c2_callFunction calls need to be changed to c3_callFunction. Also I’d imagine the way to access the objects texture is completely different with the new runtime. That’s just off the top of my head, I haven’t really used c3.

    As I recall the gist of that example is it just renders the 3D with some other library, and then it copies the texture over to an object’s texture in construct.

  • It looks like the four sprites are moving in a diamond shape.

    Add an instance variable to the sprite and call it “t”. Set each of the four instances to 0,1,2 and 3.

    Then create another sprite called “node” and place four instances in a diamond shape.

    Then in events you can do this:

    Every tick:

    — sprite: add dt to t

    — sprite: set x to lerp(node(int(self.t)).x, node(int(self.t)+1).x, self.t-int(self.t))

    — sprite: set y to lerp(node(int(self.t)).y, node(int(self.t)+1).y, self.t-int(self.t))

  • Do you literally want a n-dimensional array, or do you want an array that contains values or other arrays?

    For an actual n-dimensional array you could use a 1d array to do it. The size would be width*height*depth*... and accessing would be:

    For 2d

    Y*width+x

    3D:

    (Z*height+y)*width+x

    4d:

    ((W*depth+z)*height+y)*width+x

    And so on

    You’d probably wrap that in a function and you could make it resizeable with a bunch of inserts/deletes to move stuff around.

    For a 4d array you could also just use multiple instances of a 3D array and access it with array(x).at(y,z,w)

    You’ll have to deal with new instance picking if you end up creating more instances, not to mention you’d be limited to adding to the end of one dimension.

    The idea may be extendable for more dimensions. I like the uid idea too, but you’ll have to be more deliberate about setting it up.

    Now the issue with n-dimetional arrays is the amount of memory really blows up the more dimensions you add. Which is why I asked if what you want is arrays that contain values or other arrays, each with their own size. Kind of like a file tree.

    Anyways I’d imagine json might work for that. I don’t know if you can use it as a dynamic data structure or just to access the data since I haven’t used it.

    You could also use a normal array to do the dynamic tree structure. Basically you’d store values in pairs: a type and a value. The type would be either be “value” or “array”, and the value would be anything or the uid of another array. You’d then just use a function to do the reading, writing and any sort of extending/resizing. I guess the main aggravation here are errors. Your lookup should be simple as function.call(“at”, arrayid, x, y, z, w) which would access access each parameter as an array index. The trouble is if it tries to access a value as an array. There you could put put an error, which may be hard to hunt down in events, or just output 0 like normal events do out of range.

    If you ended up making a plugin you can detect where in the event sheet the calls are done, so that may help. There may. E a way to do it with the browser execjs action as well.

    Anyways a few other ideas for you. Personally I’d go the event based route. It’s easier to maintain and update.

  • I see what you mean but I’ve stopped working on plugins.

    You should be able to just use paster to do it. Use the draw texture with uv action and just set the uv’s to be the subimage.

    For example:

    U = xpixel / imagewidth

    It may fail if construct packs that image in the same texture as other frames on export.

  • If it’s consistently wider, maybe just using a smaller width would work when not in preview. I’ve pretty much abandoned this effect so I don’t know what’s amiss.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could reverse it by scaling by 1/scale instead of scale. Or you could store the original position and sizes to instance variables.

  • On your own site? I’d say anything is game.

  • If you want to do that in the editor you can select the objects, right click on that, and select wrap selection (shortcut key is return I think).

    If you want to do it when running the game you can do this:

    Global number scale=0.5

    Global number centerx=320

    Global number centery=240

    Start of layout

    — sprite: set x to (self.x-centerx)*scale +centerx

    — sprite: set y to (self.y-centery)*scale +centery

    — sprite: set width to self.width*scale

    — sprite: set height to self.height*scale

    That will scale around any center instead of just the object centers.

    To have actual resize handles at runtime is a bit more involved. There is a resize handle example you should be able to find with the search I think.

  • A couple ideas come to mind. One is to dynamically create some extra walls to help to box fall into the hole. Another is to check if there’s a hole below a box and have it shift a bit to align with it to drop in.

    The second idea seems a bit simpler to do. If everything is aligned on a grid then it’s a bit easier. So say the blocks are 32x32 and the ground is a grid of those boxes. I’m also assuming the boxes have their origin centered. You can calculate the closest grid position the box is on with:

    gridx=int((box.X-16)/32) *32+16

    gridy=int((box.y-16)/32) *32+16

    Then to see if there’s a hole below it check the point (gridx, gridy+32) to see if it’s overlapping anything.

    If it’s not you can then check if the x difference is close enough to make it shift into the hole. Here it would move into place if it was within 4 pixels.

    Compare Gridx > box.x

    Compare gridx-box.x <4

    — set x to min(box.x+1, gridx)

    Compare gridx<box.x

    Compare box.x-gridx <4

    — set x to max(box.x-1, gridx)

  • Ah ok. Seems like image tracing is what you want to do. Carry on.

    beguinner

    It's black because reading pixels with the canvas plugin takes so long. Give it a little bit.

    dop2000

    I made this a while back, It's much faster at reading the pixels, and avoids using the canvas plugin. It can't get the image from a sprite though.

    dropbox.com/s/soijvpnt8vjkcka/read_alpha_js.capx

    Even faster would be to save the tilemap to a file and load that later. At least as far as loading times go.

  • Well, cosp() is just a sine wave under the hood which is hard to adjust like that. It's probably too much math than what it's worth to find the polynomial that fits that curve, and while utilizing multiple bezier curves could work too it would still require some math solving.

    You could do a more visual method. I loaded your graph image as a sprite, and put the origin to the top left axis. Then turning on a 16x16 grid in the editor i added a 16x16 square sprite with the origin at the bottom left. I then placed copies one by one left to right over your graph image. The final step was to turn off the grid and resize the squares so the bottom left is on the curve on the image. Actually it worked out great since you seemed to use a 16x16 grid. An viola, we have manually defined the curve.

    dropbox.com/s/28qjc71ywa1g00p/custom_curve.capx

    There are probably simplifications of this.

  • I guess I’m having trouble following what is being asked.

    The op asks how to cover one object with another and the latest solution looks to be tracing the image of the red object to create a tilemap for collisions.

    Visually all that would change by covering one object by the other would be color. I’d think a different colored animation frame, or a color effect, or even a blend mode would work fine.

    If you do actually want that area replicated with blue rectangles, and that area is already made up of rectangles. Then you could also create a blue sprite for each red one and set the size and position to be the same.

    Any of those would be cheap instead of looping over the pixels to create a tilemap.

    In short I guess I’d want more details of what you want to do. You have a simple example, how about a deluxe one too. It would prolly better show what you want.

  • The simplest would be a condition to see if the variable is less than 5.

    Global number var=0

    On click

    Var < 5

    — add 1 to var

    If you want something more deluxe like being able to increase the var by other means then you’ll have to use another var as well.

    Global number var=0

    Global number clickcount=0

    Global number keypresscount=0

    On click

    Clickcount < 5

    — add 1 to var

    — add 1 to clickcount

    On key press

    Keypresscount < 5

    — add 1 to var

    — add 1 to keypresscount