R0J0hound's Forum Posts

  • You can set the velocity toward the position of the other object.

    So once you get the angle toward a position you can do:

    Vx=speed*cos(angle)

    Vy=speed*sin(angle)

    But there are other ways.

  • You can access individual letters with the mid() expression. The tokenat() expression can be useful to grab individual words if there are spaces in between. To filter around punctuation you can remove them first with replace() or maybe regexreplace to remove all punctuation in one shot, but that can be tedious to do.

  • The non-behavior way is to compare the distance between each pair of objects and push them apart and update their velocities if they are too close. That doesn't scale well with such a large amount of objects, so we need to do some kind of spatial hash so we only need to check objects that are nearby. Unfortunately when doing it with events it's hard to get that much of an improvement so JavaScript is better.

    Here's one possible test of that. It handles one object type and treats them all as the same size. Disable the group to compare performance with the physics behavior.

    dropbox.com/scl/fi/ja4hfo7dv9sqq7phs1q25/spatialGridJS.c3p

    With 1400 objects:

    Custom push out: 60fps

    Physics: 10fps

    The example also does it's own physics, but you can just use the spatialGrid() function if you just want push out.

  • Maybe a nw.js issue then? If you can reproduce it reliably then filing a bug with scirra is your best bet. As an alternate to nwjs they have that webview2 export which seems to have less issues. Maybe that's a solution.

  • Like it was pointed out a number can’t be three values at once.

    What you’re trying to do is more complex. Three objects, each with their own value. Maybe something like this?

    Var count=0

    Every tick

    — set count to 0

    Sprite: var=1

    — add 1 to count

    Sprite: var=3

    — add 1 to count

    Sprite: var=7

    — add 1 to count

    Count=3

    — set text to “match”

  • All bets are off if they just find where you encrypt it in your code, and either understand it or just copy it. But I guess you could make it harder to find even the code.

    At a deeper level you could generate the encryption code on the fly too, encrypt that and append that to the save.

    You could make the key random and store parts of it in the encrypted result.

    You could come up with some other esoteric scheme to do the encryption.

    The more effort you take to do things to obscure it the longer it would take someone to figure it out.

  • You could add parenthesis. (Sprite.var=2)&(sprite.var=3)

    I think at least. It’s an order of operations thing or something. But for and I’d just add multiple instance compare conditions. That acts as an and

  • When using “compare instance variable” you can only compare it against one value. Basically whatever the expression you write evaluates to will be the value you’re comparing the variable against.

    Now, if you want to do a general picking condition look at system->pick by evaluate. With that you can do do what you’re after.

    System->pick by evaluate

    Object: sprite

    Expression: sprite.var=1 | sprite.var=2

    Hopefully that will give you the general idea. I can’t do screenshots atm.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If the sprite is rotated then the formulas look a bit more involved. It unrotates the position, before scaling.

    Meshx = ((x-sprite.x)*cos(-sprite.angle)-(y-sprite.y)*sin(-sprite.angle))/sprite.width

    Meshy = ((x-sprite.x)*sin(-sprite.angle)+(y-sprite.y)*cos(-sprite.angle))/sprite.height

  • Mesh points are relative to the position, angle and size of the object. That can be useful or inconvenient depending on what you want to do.

    If the sprite isn’t rotated then this should work to get an x,y position on the layout converted to a mesh point location.

    MeshX = (x-sprite.x)/sprite.width

    MeshY = (y-sprite.y)/sprite.height

  • Your code seems to be ok up till the phase where you do the attacks. But I can't place what's amiss at that point. As you stated you have a lot of variables for the state, and it's tricky to debug where the logic error is.

    A slightly different way to go about it could be to have a single state variable to organize the different steps. I guess this is called a state machine.

    Anyways here's an example made from the free version. Although that probably made the events a bit odd looking in spots to get it to fit.

    dropbox.com/scl/fi/ugfnxtiht6kijgrqtqyq3/rpgBattle.c3p

    Could be useful for ideas possibly.

  • I don’t think you can? At least not with Ajax.

    A quick google search yielded this. Apparently it’s possible to do from the server side but not from JavaScript on the client side.

    stackoverflow.com/questions/30622369/easiest-way-to-get-list-of-files-in-the-server-directory

    A creative solution could be to periodically open your c3p with a zip program and copy the .c3proj file. At one point in the file it lists all the files in the files folder. You could utilize that to find the folder a particular file is in.

  • No, and I don’t think most would be happy if such a thing was easily possible. Sure it would useful in cases where the author of the game lost the source, but in practice it would mostly be others using it to rip other games.

  • Oh. Sorry, I didn’t read it well the first time. It wouldn’t be a bug and yes the way you did it does fix the frame rate dependence.

    With maxspeed=maxspeed+1 in 1 second at 60fps the maxspeed would increase by 60. At 120fps it would increase by 120 in one second.

    By changing it to maxspeed=maxspeed+60*dt it would increase by 60 in one second no matter the frame rate.

    If the behavior had a rate of change for the max speed it could handle it for you, but it’s a bit unrealistic to handle all cases, so doing what you’re doing is fine.

  • Nothing looks amiss. You use the mouse movement to change the angles. You clamp the up and down angle a bit, it then gets a direction vector from the two angles and uses that for a look at.

    The video doesn’t show much. Do you get the runaway too or just some users?

    If it only happens on some machines then it’s an issue with the mouse movement values perhaps? Hard to debug if you don’t get the issue too.

    I guess you could make a test to log or graph the movement values along with the time. Then maybe nail down down what movements cause the runaway, and record that on both machines and see if there’s anything drastically different between the two.

    Overall if it’s a browser bug with the mouse movement callback then I’m not sure how to correct it. Maybe there’s some creative way to deal with it.

    Nothing else looks amiss otherwise.