R0J0hound's Forum Posts

  • Here's a math idea that simplifies it a bit.

    Basically it's a torque calulation using a cross product.

    https://dl.dropboxusercontent.com/u/542 ... _knob.capx

  • You can do it like this if array1 is size 5x5x2 and array2 is size 25x2x1, but I don't follow how it helps your op.

    array1: for each xyz

    --- array2: set value at (array1.curx+array1.cury*5, array1.curz) to array1.curValue

  • jobel

    To use tab I usually copy paste it over from notepad. I guess you could also javascript with the browser object too.

    The event 8 condition would be changed to:

    left(curline, 1) = tab

    And the 3's in it's actions would become 1's.

  • Here's an example of doing parsing of a custom format:

    https://dl.dropboxusercontent.com/u/542 ... ormat.capx

    The advantage is you can customize it any way you'd like to make creating the data file easier. For example this one does without the xml tags or the need for all the comments and symbols of json. Also you can omit unused parameters.

    weapon
       id 0
       name sting
       perk glows when orcs are near
       damage 100
    weapon
       id 2
       name rusty sword
       damage 10[/code:1z5snhwy]
    
    To each his own though.  Personally I love creating something like this and dislike using xml or json unless I have to.  Another option could be to make your own editor to set the array data.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To me simpler would be one file to load a text from ajax. The file wouldn't be json or xml or anything complicated like that. You can come up with your own file format that you can parse pretty easy with tokencount() and tokenat() with a few events. Maybe 20 or so? The idea is to make editing the data file easier since xml and json are tedious.

    Give me a more complete idea of the data in your files and I can give a more refined answer.

  • Profile it with wallclocktime. Basically you can do this to measure how long some events take. Then you can try both ways and compare it.

    global number starttime=0

    every tick

    --- set starttime to wallclocktime

    // events to profile

    --- set text to wallclocktime-starttime

  • Wrong section.

    However C2's sprite is drawn in the same way as pixi.js. It uses webgl or canvas2d on older systems.

  • How are the players moved? Using other behaviors besides physics to move them may be the problem. Basically the physics behavior can't account for the motion of the other behaviors. For best stability the physics should be doing all the movement.

    Setting the position with events or other behaviors is the most unstable especially when joints are involved. Setting the velocity with events is better but still can be unstable with joints. Best is to use forces and impulses to move the objects.

  • Borgi

    Best I can tell the force pulls the joint out of place. Maybe try a torque instead?

    Either would be fine to use.

  • The bug is with the & operator when it converts a number to text. It's the rounding feature that was added to make decimal numbers print nicer that is causing the issue. It's not unique to array values, something like a variable can be used to cause it too.

  • There probably is. This is a pretty old topic so I'm not familiar with what I did. Also I don't have the patience to load that link to see what it does.

  • Try setting "set angle" to no and making an event:

    Sprite: 8direction: is moving

    --- sprite: set angle to sprite.8direction.angleOfMotion

  • It should. You'd put the timing only in functions that either C2 calls:

    or any ACE functions. Helper functions only used by those other functions wouldn't need it. Also it wouldn't work if an action called another action inside the function.

    It sounds like it would be what your after since you want to know the total time used by a plugin. It is a bit tedious to do though.

  • A brute force way would be to just have a variable for the total time in the plugin space. aka here:

    /////////////////////////////////////
    	// Behavior type class
    	behaviorProto.Type = function(behavior, objtype)
    	{
    		this.behavior = behavior;
    		this.objtype = objtype;
    		this.runtime = behavior.runtime;
    		if (typeof this.behavior.totalTimeUsed == "undefined")
    			this.behavior.totalTimeUsed = 0;
    	};[/code:23ivohi0]
    
    Then you could just get the current time at the start of a function and right before it returns get the time again and add the difference to the total time.  You get the current high res time with performance.now().  The kahanTime gives you C2's "time" expression and is dt adjusted so it's not what you want.
    
    [url=https://developer.mozilla.org/en-US/docs/Web/API/Performance/now]https://developer.mozilla.org/en-US/doc ... rmance/now[/url]
    
    Here's a possible implementation:
    [code:23ivohi0]behinstProto.profileBegin = function ()
    {
    	this.ProfileStartTime = performance.now();
    };
    
    behinstProto.profileEnd = function ()
    {
    	this.behavior.totalTimeUsed += this.ProfileStartTime - performance.now();
    };
    
    behinstProto.tick = function ()
    {
    	this.profileBegin();
    	
    	if (!this.enabled)
    	{
    		this.profileEnd();
    		return;
    	}
    	// do stuff
    	this.profileEnd();
    };[/code:23ivohi0]
     
    Now adding lots of floating point numbers together will give rounding errors over time.  You can do this instead of a simple add to circumvent that if desired:
    [url=https://en.wikipedia.org/wiki/Kahan_summation_algorithm]https://en.wikipedia.org/wiki/Kahan_summation_algorithm[/url]
  • The core part is being able to slice a polygon by a line into two polygons. This can be done by calculating the intersection between the line and the edges, as well as finding which side of the line a point is.

    Here's one possible psuedcode of the algorithm to do it:

    for each edge clockwise
       if edge.point0 is on left side of line
          add point to poly1
       else
          add point to poly2
       if edge intersects line
          add intersection to poly1
          add intersection to poly2[/code:3d7po4e6]
    
    Next we have the issue of drawing an arbitrary polygon and changing the collision polygon.  Vanilla C2 plugins won't help here.  I don't use it but the third party polygon plugin by yann probably could work since it both lets you draw arbitrary polygons at runtime and it makes it's collision polygon match.
    
    The rough psuedocode for that could be:
    [code:3d7po4e6]get the list of edges of a polygon
    try to slice the polygon in two with a line
    destroy the old polygon and create two new polygons from the sliced polygons[/code:3d7po4e6]
    
    Also on a side note you'll want to set the new polygons' velocities the same as the old polygon otherwise the pieces will go at a complete stop after slicing.
    
    At least that's a general idea how to do it.  There might be some issues that need to be ironed out, such as I don't know how well the polygon plugin works with the physics behavior.