R0J0hound's Forum Posts

  • If you save to old position of the sprite in some variables, you could then use a loop and lerp to create particles in between the positions.

  • I don't really have one. It's just that the rotate behavior is a very light behavior, and since it's only used on one sprite it's hard to believe it's a contributor to bad performance.

    You can't really squeeze any more performance from something so simple.

    My thought is the lag you're encountering has nothing to do with your game.

    But perhaps someone else has tips. I've only ever used the html5 and nw.js exports.

  • Every 0.017 seconds and lower is the same as "every tick". So dt can make sense there.

    All every x seconds does is check the time since it last ran, then if it's >=x it runs.

    The rotate behavior and doing it with events should be identical for performance. Actually the behaviors often should perform better.

  • Well, all the rotate behavior does is the same as a event like this:

    Every tick: sprite: rotate clockwise speed*dt

    With just one object, there isn't much you can do to make it faster.

    How is the performance bad?

    If you're getting a low framerate then you might have a blacklisted graphics card. If you can update your driver it may help.

    If instead you're getting a rotation that's not buttery smooth, then it's a current browser issue. You can have lots of sprites/events/behaviors or very few and it doesn't affect that. Chrome supposedly has a fix coming in a newer version, but other than that other browsers have varying degrees of stutter. Once one solves it well I'm sure the others will follow suit.

  • Here are the specs:

    https://en.wikipedia.org/wiki/Double-pr ... int_format

    1 bit for sign, 11 bits for exponent, and 52 bits for the fraction.

    With that it's only 15-17 significant decimal digits, but since it also stores an exponent it can store a value up to:

    1.7976931348623157 × 10^308

    which is plenty for a clicker game.

  • Numbers in C2 are 64bit floating point values so it can handle values like that.

    The editor doesn't let you type numbers with scientific notation so maybe that's where the misunderstanding is.

  • It's the same if you created a sprite in a function. If you create another, it will exist till you destroy it. Also an object's uid should never change. I've resized many arrays and their uid remains the same.

  • Maybe this?

    (1-value/180)*100

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't quite understand the first bit. Do you want the direction the enemy is moving or the direction from the enemy to the player?

    if you're using a behavior they often have a angleofmotion expression or x and y velocity expressions from which you can calculate the angle of motion with angle(0,0,veloctyx,velocityY).

    As for calculating a value of 0 to 7 for animation.

    This converts a from the range (-180,180) to (0,360):

    (a+360)%360

    This rounds the angle to the nearest 45degree angle 0 to 7. The 22.5 is half of 45 and is needed to round correctly.

    Int((a+22.5)/45)

    Edit:

    If you are using the move at angle action to move the object then you should keep track of the direction you moved. Another way is to save the objects position to variables oldx and oldy before you move and calculate the angle of motion with angle(oldx,oldy,sprite.x,sprite.y) after you move.

  • What you're trying to do is what is called "pass by reference" in other programming languages, which just passes the variable to modify to the function. C2 functions can't do that, it only does "pass by value", so the function has no idea where the values came from.

    So like you said you can do a function for each or re-work your function.

    On function "weapon leveling"

    Pick ship by uid function.param(0)

    --- function param 1= "rate"

    ------ events to level up rate

    --- function param 1="speed"

    ------ events to level up speed

    ....

    Then call the function with

    Call function "weapon leveling" (ship.uid, "speed")

    You'll still be duplicating events but they'll all be in that function.

  • Search for "gesture recognition" for a few examples that may help.

    What is usually done is to compare the points of the line drawn instead of the resulting image.

    One way is to evenly divide the drawn stroke and compare that with a saved stroke. The simplest way is if both strokes have the same number of points, but you can do some interpolation if the number is different.

    The comparison can compare the direction or positions of the points. If by location you'll need to scale the strokes to be the same size.

    For each point you add up the differences. Then that sum will indicate how similar the two shapes are. 0 would be identical and anything higher would be less similar. Typically you pick a number that would be good enough to consider it that shape.

    For comparing against multiple shape you'd do the same for each and keep the one that was closest.

    For comparing if a triangle was drawn then you would have to have to do something a bit more clever. Since you could have started drawing the triangle from any point and went either direction.

    One idea would be to find the center of the stroke and find the distances around that to the point. Then you could compare the distances of both strokes at the same angles around the shape.

    Anyway, just some ideas. I've made an example that you can find by searching that does some of the above. There are also some examples made by others as well as a plugin that could be of use.

  • You can make the bullet behavior not affect the sprite's angle by setting it's "set angle" property to "no".

  • Yeah, the calculation was done manually based on imagewidth*imageheight*4 as I recall.

  • I don't have access to C2 at the moment, but...

    4. I thought there was. At least you can scale the tiles up for sure. I'd assume it can go the other way.

    5. I could be remembering wrong but I thought if you right clicked the animation name then preview was one of the options.

    6. If you closed the image editor and you didn't want that change, you can use undo to revert it.

  • Neither. When you call a function only numbers or text is passed. The function has no knowledge of what variables were used.

    Consider your function call:

    Call "weaponleveling" (ship.bulletexpspeed, ship.bulletlvlspeed)

    If those two variables were 100 and 15 respectfully then this call would be identical:

    Call "weaponleveling" (100,15)

    If you want to modify a variable of a certain instance with a function then you need to pass that instance's uid as one of the parameters and then pick by uid in the function to modify the variables.

    Also as blackhornet stated a function has only one return value. if you set the return variable multiple times then only the last value will be used.

    The main purpose of a return value is when you call a function from an expression. Like this:

    On function "add"

    --- set return value to function.param(0)+function.param(1)

    Global number sum=0

    Start of layout

    --- set sum to function.call(100,15)