R0J0hound's Forum Posts

  • I realize you just want a complete template to use, but I’m sure you could use any number or features to make parts of that game.

    Tilemaps let you place tiles that both serve as collisions and as a visual, so I can see that useful to try to use to do the play area. You can loop over the tiles too. So that’s a plus. Performance would need to be seen though. The rest I’m too lazy to think about atm.

  • So I opened that capx and the only thing I tried to solve in it was a way to slice away chunks of the play area. It was a bit of presumptuous to call it a qix like. I do recall an older capx I made but the forum and a search of my dropbox yielded no results.

    The original qix probably did everything pixel based. Things moved a pixel at a time. It knew if the player was on the edge or inside the play area based on the color of the pixel it was on. The filling of areas was done with a pixel flood fill. And finally the filled percentage was done by counting pixels with a certain value.

    C3 has the canvas plugin that can be used to set and read pixels so that could be leveraged to do that stuff. The problem is with modern resolutions you deal with more pixels so it may not be as performant.

    All my previous attempts tried to do the game in a more modern way such as keeping track of the polygon around the unfilled areas and measuring the distance the player was from the closest edge to those polygons. All which are all slightly involved projects on their own. To top it off some creativity is necessary to utilize constructs available features to achieve that. I typically run out of steam after finding a way to erase chunks of the play area, so most of this is completely unsolved for me.

    To make good clone I think the best starting point would be to make a complete list of all the game rules. Like what is happening, what can you do as a player and what happens. Even something complex should be able to be broken down into simpler parts.

  • It’s simpler to look at with 1D arrays.

    So these two

    A =[ “a”, “b”, “c”]

    B =[“a”, “c”, “d”]

    Would give:

    C=[1,2,3]

    A:for each x
    — compare: A.at(A.curX)=B.at(A.curX)
    — — c: set at (a.curX) to 1
    — else
    — A: contains value B.at(A.curX)
    — — c: set at (a.curX) to 2
    — else
    — — c: set at (a.curX) to 3

    Doing it with 2D or 3D arrays may be similar, but I’m not up to working it out.

  • Here’s the file from that topic:

    dropbox.com/s/lmd0vwck1dy9agq/qix_like.capx

    I haven’t looked at it in a while.

  • That particular event looks at all the outgoing roads except for the one the car came on and just picks a random one.

    To only turn right I guess you could pick roads whose angle is car.angle+90 or something.

    It’s honestly been long enough that I don’t like the events I wrote and would rather just redesign the whole thing and maybe reusing some of the concepts used here. I’ll probably have a go at that the next few days with better intersection logic. Maybe the cars could have preferences where they’d like to go for like pathfinding and such.

    In my experience when I make something and then change what I want it to do it’s not often a simple tweak. Besides rewriting it often yields a better design anyways.

  • This was built around casting rays against arbitrary triangles, and trying to fit it within 25 events. It may be possible to simply since 3D objects are limited, or there may be other approaches.

    Anyways I have no alternatives currently.

  • When I posted that example I didn’t have a good idea how to fix that issue and decided it still was good enough to post as it mostly worked.

    To fix I’d say the whole thing would need to be redesigned with more logic at intersections.

    As is it just moves along the roads, turns randomly at intersections, and stops if a car is ahead.

    Probably would need the cars to not enter the intersection unless it’s path doesn’t cross another one already in it. Not just look right in front of itself. Probably would do well with some kind of signal logic to keep things fair for cars who can’t enter.

  • No problem. Glad it worked.

    newt

    You can already do that with functions somewhat.

    What I’d like to see is being able to have simple structures as values in addition to numbers, text and bools. Would make some events way more readable I think.

  • So this is what the math would look like.

    X,y is the position on the curve.

    If we advance t by a small amount and get that xy then subtract the position from that we get a direction vector.

    We can then normalize it to make it have a length of 1.

    So then if we swap xy and make one negative it’s the same as rotating 90 degrees.

    So we end up with a point 50 pixels to the left and right of a point on the curve.

    x = cubic(x0,x1,x2,x3,t)
    y = cubic(y0,y1,y2,y3,t)
    dx = cubic(x0,x1,x2,x3,t+0.001)-x
    dy = cubic(y0,y1,y2,y3,t+0.001)-y
    mag = distance(0,0,dx,dy)
    dx = dx/mag
    dy = dy/mag
    
    points:
    x+dy*50, y-dx*50
    x-dy*50, x+dy*50
  • One way is to just make a curve for one edge. Cubic or qarp for example. Or even using the arc of a circle for minimal distortion. Then you can get points from one edge.

    You can get the other curved edge by moving the points out perpendicular from the curves angle.

    I’m probably not doing the idea justice without an example. I’ll try to make one tomorrow.

    This page has ideas how to bend roads which is very similar to what you’re trying to do.

    redblobgames.com/articles/curved-paths

    That guy’s whole site is full of a wealth of information.

  • You can use a dictionary for that. So basically use tokenat to get each number from the string and add a key to a dictionary. Duplicates will be the same key.

    Then you can loop over the keys and add it to a string and there will be no duplicates.

  • That was just what that algorithm did, which I honestly don’t fully understand. What I do know is it should be one of the faster algorithms for that problem, according to Wikipedia.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The algorithm came out cleaner in events than I expected.

    dropbox.com/s/t4hci8revuyaz1q/smallest_enclosing_circle.capx

  • It should be possible to implement the welzl algorithm to do it. We just need to use some cleverness to return multiple values and be able to pass arrays to the function.

    The meatiest part of the algorithm is probably the math to give the smallest circle around three points.

  • Instead of the average you could find the median and use that for the center.

    X = (xmax+xmin)/2

    Y = (ymax+ymin)/2

    Then just use the furthest point. Might give a tighter circle.