R0J0hound's Forum Posts

  • If you move the island over the path so they are lined up and save the x,y position of the island to some vars: startx, starty then you can have some sprite dummySprite that you move along the path as normal, only you'd make that invisible. Then you can move the island anywhere and set the position of another sprite to

    x = island.x+dummySprite.x-startx

    y = island.y+dummySprite.y-starty

    and the path will move with the island.

  • Just use it instead of the first code. I kind of paraphrased the expressions but it should be useable. At the end of it the highest value will be

    Array.at(index1)

    And the second will be

    Array.at(index2)

    You’ll want to reset both vars to 0 before running that event.

    If there is a tie then then it will still work. Barring any flaw to the idea.

    edit:

    Actually that won't work right for finding the second highest value in some cases. Do this instead: loop over the array twice. Again you'll want to reset the variables to 0 before running the two loops again.

    global number index1=0

    global number index2=0

    array: for each x

    compare: array.curvalue >= array.at(index1)

    --- set index1 to array.curX

    array: for each x

    compare: array.curx != index1

    compare: array.curvalue >= array.at(index2)

    --- set index2 to array.curX

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I suppose. I’ll try to give a possible example.

    But it’s probably simpler to sort the array. If you want to remember the original indexes, you can add another column and set the values there to the indexes before sorting. If you want to leave the original array alone, you can copy it to another first with the asjson expression.

    var index1=0

    var index2=0

    Array: For each x

    Current value <= array.at(index1)

    —- set index2 to index1

    —- set index1 to curx

  • You probably can use a dictionary. It’s just something you’d have to try. You can loop over the values much like the array to find the highest value.

    Instead of that expression with max you could do

    var highest=0

    var index=0

    Array: for each x

    Compare: array.curvalue>highest

    —- set highest to array.curvalue

    —- set index to array.curx

  • I got bored of finding a simple solution. You could just use one sprite with on animation with all the frames. The second object would just be a separate instance. The animations are just lists of frames, and categories are just lists of animations. The frame value, if different per animation could be included in the animation list.

    The lists could be done with arrays, text variables or whatever. Getting the data into the arrays isn't too bad. Dop listed a few solutions but there are more.

    The algorithm itself is straightforward imo. Just implement it as you say.

  • I notice that you have identically named pictures for separate animations, are they meant to be identical pictures?

  • Couldn't you make it in Construct, and save a series of png files and use something else to convert them to a gif?

    Making the gif directly could be possible from javascript but there is nothing setup for that currently.

  • A few ways come to mind:

    One is to use the audio plugin's level monitoring effect, or whatever it's called. There is an example capx that comes with C2 that shows how to use it. It's good for visualizing the music, but may not be suitable to read the beat like you want.

    A second way is to manually list all the times of a beat in the song, or something like that. You may be able to use some audio software to help with that or maybe you could make a tool in C2 to assist and make things easier. I'd imagine this is mostly what things like ddr does.

    You could also use a music format like midi that has the sheet music of the song that you could pull the timings from. There may be some audio processing magic that could assist with things but that's not quite simple.

    You may get some other ideas/solutions by searching the forum for previous discussions about this kind of thing. I know it's been discussed a few times before.

  • If you have each card as a separate instance, you could do this

    For each sprite ordered by random(1) ascending

    —- sprite: set animation frame to loopindex

    If you want to just get a number one at a time you can either make an array with all the numbers and randomly taking one out. Blackhornet also made a nice plugin to do that.

  • Positioning with events can be as easy as setting an object position to another objects position or one of it's imagepoints.

    You can also save the offset and just set the position from that. Like this more or less. There are more deluxe ideas too.

    Start of layout

    --- set dx to child.x-parent.x

    --- set dy to child.y-parent.y

    every tick

    --- child: set x to parent.x+dx

    --- child: set y to parent.y+dy

  • A second delay is a bug in your event code. The pin behavior runs once per frame and typically there is no lag at all. A one frame lag can be possible when using multiple behaviors are used. It’s basically due to the order of behaviors being run. A multiframe lag can be possible in cases of pinning to objects pinned already.

    Anyways you can always just position objects with events. With that you can control when you do it, or even do it multiple times in events if you move object around a lot.

  • Not really. Debug is always going to be slower.

  • If you move the html elements with css instead of the set position actions things won't resize. It does draw outside the canvas area, but you can use the "clip" css property to address that.

    Anyways here's an example. It basically get's the position and size of everything in windows coordinates and does the above.

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

    The example was for c2, but the only change for c3 is probably replacing c2canvas with c3canvas.

    The size of the button is smaller than it actually should be. A fix for that is giving each button an id and using javascript to get the size. I thought it wasn't needed though.

  • If you think of the layer property as binary you have 8 separate layers. The objects can be in all the layers or even a few of them. For example “11111111” would be all the layers, “00000001” would only be the first one, and “01010101” would be every other layer. Anyways any two objects will collide only if they share a layer. For example an object in layers “00001111” will collide with an object in layers “00000001” because they are both in the first layer. Whereas an object in layers “11110000” won’t collide with an object in layers “00001111” because they have no layers in common.

    You can also look at the chipmunk documentation linked in the first page for another explanation. You actually have 32 layers if you treat layers as hexadecimal.

    “Bit wise and” is a way to check if two numbers have bits in common.

  • Here’s the math to rotate around an imagePoint. It can be any x,y point really. Here I’m only rotating by 5 degrees, you can change 5 to anything.

    Global number cx=0

    Global number cy=0

    Every tick

    —- set cx to sprite.imagePointX(1)

    —- set cy to sprite.imagePointY(1)

    —- sprite: rotate 5 degrees clockwise

    —- sprite: set position to ( (self.x-cx)*cos(5)-(self.y-cy)*sin(5)+cx, (self.x-cx)*sin(5)+(self.y-cy)*cos(5)+cy )

    Another way could be this:

    Global number d=0

    Global number a=0

    Every tick

    —- set d to distance(sprite.x,sprite.y, sprite.imagepointX(1), sprite.imagepointY(1))

    —- set a to angle(sprite.x,sprite.y, sprite.imagepointX(1), sprite.imagepointY(1))

    —- sprite: move -d pixels at a degrees

    —- sprite: rotate 5 degrees clockwise

    —- sprite: move d pixels at a+5 degrees