R0J0hound's Forum Posts

  • 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

  • I don’t think you can change it even with js. The origin is tied in with the frame which is shared between instances.

    You can rotate around an arbitrary point cx,cy by and angle a with

    sprite: setpositiom to (cx+(self.x-cx)*cos(a)-(self.y-cy)*sin(a), cy+(self.x-cx)*sin(a)+(self.y-cy)*cos(a))

    sprite: rotate clockwise a degrees

    You could pin another sprite on the sprite to be the center to use for cx,cy

  • You could do this:

    random(1)<0.25?int(random(10,25)):int(random(25,50))

    The 0.25 means

    10-25 has a 25% chance

    And 25-50 has a 75% chance

  • So I can think of two ways to do it. Pixel/tile based or polygon based. Polygon based would scale up better with higher resolutions, and pixel/tile based is simpler but is slow. Especially with higher resolutions.

    Here's a test of the tile based method with construct's tilemap.

    dropbox.com/s/v81su1aeaddh35y/qix_test.capx

    My intention with this as with most capx files I post is just to give ideas.

  • I agree. That would be useful.

    To set the overall velocity you’d have to do something like:

    Set velocity to

    100*cos(angle(0,0,self.physics.velocityX, self.physics.velocityY)),

    100*sin(angle(0,0,self.physics.velocityX, self.physics.velocityY))

    Where 100 is the speed you want to use.

  • Sorry. No ideas yet. Haven’t been on the computer.

    Any idea is probably feasible. I’d need to dissect that capx to see what I did to comment on any ways to modify it.

    On face value all the cars need to do is move along the roads, queue up at intersections, and have some logic to let them go though intersections in an orderly fashion.

    I’d have to work it out on paper, then find a way to make it into events. Depending on how I decide to do it some quirks of the event system need to be taken into account.

    Sub-problems to solve include moving the cars smoothly, handling different speeds, testing for edge cases and such.

    I’ll post if I get anything working.

  • You can do a flood fill to do that.

    Basically mark all the tiles as not visited and then start with some tile and flood fill from that. Marking all the connected tiles. At the end any tiles not marked are isolated.

    I guess the issue would be choosing which tile to start from. Maybe an edge? Depends on what you want to do.