R0J0hound's Forum Posts

  • Cool, glad it was useful.

  • I had no idea what game tag you were referring to. Google linked to a game on the arcade. Looks like the camera centers between the players and zooms so all players are visible at once even when far apart.

    So here's how you'd do it for two sprites. 640,480 is the window size. Find the width and height of the bounding box that contains all the players. You can add to this so there is space around the players. Next you scale the layout. Here it's limited to 1 so it will only zoom out instead of zoom in too. Lastly scroll to the midpoint between the players. For that step you can just give the sprites the scrollto behavior instead.

    w= max(palyer1.x, player2.x)-min(palyer1.x, player2.x)
    h= max(palyer1.y, player2.y)-min(palyer1.y, player2.y)
    set layout scale to max(1, (w/h> 640/480)?640/w:480/h)
    scroll to ((player1.x+player2.x)/2, (player1.y+player2.y)/2)

    For three sprites you can change the calculation to:

    xmin = min(palyer1.x, player2.x, player3.x)
    xmax = max(palyer1.x, player2.x, player3.x)
    ymin = min(palyer1.y, player2.y, player3.y)
    ymax = max(palyer1.y, player2.y, player3.y)
    w= xmax-xmin
    h= ymax-ymin
    set layout scale to max(1, (w/h> 640/480)?640/w:480/h)
    scroll to ((xmin+xmax)/2, (ymin+ymax)/2)
  • Tested it myself with c2 and c3 and it's sorting correct with that data you're using.

    dropbox.com/s/dz762jh9t0myg9a/array_sort_test.capx

    You'll have to show your project or events.

  • Thanks. The mathiest part is the random orientation bit. And the random velocity.

  • An ugly verlet physics die.

    dropbox.com/s/zis7zp6rggxpdny/dice.c3p

  • Cleanest way I can come up with is to also add a Boolean variable to A and B, and do this:

    A: set paired to false
    B: set paired to false
    
    for each A
    B: matchID = A.matchID
    pick B instance 0
    -- A: set paired to true
    -- B: set paired to true
    
    A: [inverted] is paired
    -- A: destroy
    
    B: [inverted] is paired
    -- B: destroy
  • The pathfinder behavior works by dividing the level up into squares and uses the a star algorithm to find the closest path. You can implement a star with events to use a node mesh. This site is a great reference:

    redblobgames.com/pathfinding/a-star/introduction.html

    Looking through my files I found two examples of that. The first is newer, but I included the older one in case that gives ideas.

    dropbox.com/s/v4axhrz8stistdn/astar2_mesh.capx

    dropbox.com/s/p1w0y1qusjp38fu/astar_nodes.capx

    So basically if you used the first one, just place nodes and lines between them to make connections. Then calling the "astar" function with the uid of the start and end nodes will give you a comma separated list of the nodes that would make up the quickest path.

    The latter part of the example gives a possible way to move the object through that list of nodes. There are other ways.

  • Came out like I described, unless I made a typo.

    dropbox.com/s/t2olbf79b3han1q/Array_compare.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have no answer for that. You can add the request to the ideas platform and maybe they’ll eventually add it or say doing that with current features is good enough.

    There’s probably a balance between a minimal useful list of actions and a list of every useful function.

  • It was intentionally missing. Probably could be reworked without it.

    That’s fair. I can only approximate events with text, and I was only mentally working it out. I’ll see if I can make a capx of it eventually. Might have to defer to other people’s ideas in the meantime as I have no eta when I’ll lay aside time to make one.

  • Gdevelop expressions look overly verbose. Anyways, I’m not sure the question.

    The math of positioning an object with a distance and angle from another object is the same no matter the program.

    X = centerX + dist*cos(ang)

    Y = centerY + dist*sin(ang)

    Or since you know the object you want to move toward you can skip the trig altogether.

    mag = distance(centerX,centerY,mouse.X,mouse.Y)

    X = centerX + dist* (mouse.x-centerX)/mag

    Y = centerY + dist* (mouse.y-centerY)/mag

    Although you could use the move at angle or move forward actions to do that too in construct.

    Sprite: set position to (centerX,centerY)

    Sprite: set angle toward position (mouse.x,mouse.y)

    Sprite: move forward dist pixels.

    There are likely other ways too. My answers are construct centric.

  • Right. You have to loop over it in multiple passes. Once to find the 1s and another for the rest.

     var i
    var j
    repeat a.width times
    -- set i to loopindex
    -- compare: a.at(i) = b.at(i)
    -- -- a: set at i to "-"
    -- -- b: set at i to "-"
    -- -- c: set at i to 1
    
    repeat a.width times
    -- set i to loopindex
    -- compare: a.at(i) = "-"
    -- -- 
    -- else
    -- -- set f to b.indexOf(a.at(i))
    -- -- compare f = -1
    -- -- -- c: set at i to 3
    -- -- else
    -- -- -- a: set at i to "-"
    -- -- -- b: set at f to "-"
    -- -- -- c: set at i to 2
  • If you’re okay with the two arrays getting destroyed this should work on paper. You could always save the asjson of arrays A and B to save them. This assumes all the arrays have the same size.

     var i
    var f
    repeat a.width times
    -- set i to loopindex
    -- compare: a.at(i) = b.at(i)
    -- -- a: set at i to "-"
    -- -- b: set at i to "-"
    -- -- c: set at i to 1
    -- else
    -- -- set f to b.indexOf(a.at(i))
    -- -- compare f = -1
    -- -- -- c: set at i to 3
    -- -- else
    -- -- -- a: set at i to "-"
    -- -- -- b: set at f to "-"
    -- -- -- c: set at i to 2
  • Sure you could use imaginepoints too. There are probably other ways to get a point to rotate around