R0J0hound's Forum Posts

  • alextro

    The dijkstra algorithm is what your capx is doing and is the algorithm used it the article you referenced.

  • newt

    I'd imagine that'd be doable with an overhaul of expressions. My hypothetical would have it in mind. It's often hard to change an existing system to allow it, but a redesign can allow it. The freedom of my design is I'm ignoring all issues of backward compatibility, which Scirra has to deal with carefully.

    Animmaniac

    For that I was kind of imagining kind of a hierarchy of types or something. Limiting to common features is another thought, but I understand Ashley's point stated elsewhere where expressions can mean entirely different things for different objects, so it'd not work.

    object: uid
    |
    |--visual: x,y,width,height,angle
       |
       |--sprite: anim, frame
       |
       |--tiledbg: offset[/code:3p95f9kh]
    
    Another sloppy idea would be to either do nothing or cause an error if an expression was used that the object doesn't have.
    But basically my design is glossing over the problem by assuming pretty much only one kind of object.
    
    @rexrainbow
    The idea is similar, but I'd also like to explore the idea of not using UID's like we do now since they're a lot like pointers in c.  Using an array or dictionary is more in line with normal coding.  I like the picking system C2 provides and would like to design it so it acts pretty much the same.
    
    @99Instances2Go
    Those would likely be mitigated by being able to see what's picked in the debugger and being able to step through it a condition and action at a time instead of only a event at a time.  Advanced users do this manually either on paper or change opacity or something to visualize it when running the game.
    
    @newt
    Having "and" and "or" in the same event makes sense for simple stuff, but in other ways it doesn't seem intuitive to me.  C2's "or" event is already kind of like that to me.  I'm never sure of it's behavior when  two conditions of different objects are used, instead I have to verify what it does in events.
    In my design i'm probably side stepping the issue by making the expression based solution, often used in C2, easier.  Here are some possible solutions, but it probably needs more exploring because it should work with triggers and loops to...
    
    sprite: x<0
    or
    sprite2: x<640
    sprite2: x>320
    
    sprite: sprite.x<0
    or
    sprite2: sprite.x<640 and sprite2.x>320
    
    sprite, sprite2: sprite.x<0 or sprite2.x<640 and sprite2.x>320
  • When you say with itself it's confusing to me. The overlapping point just finds objects overlapping a point that's not associated with anything. You could save the uid of the object you got the point from and then after the operlap condition do a system compare to make sure the picked uid isn't the same as the saved one.

  • 0plus1

    There are probably other ways to do it. One would be to use raycasting by calculating the intersection of two lines. The example here just does it by steps. The 16 is the distance the laser moves per step. It works only with horizontal or vertical walls though.

    The problem is basically:

    Thinking of the end of a laser as a moving object,

    move it till it hits a wall,

    using the angle of the wall calculate the new angle of the object and repeat.

    If you use raycasting math it can be 100% precise. I did the math for it a while ago and made a quick example here:

    https://www.dropbox.com/s/1tzd6emtsbdpx ... .capx?dl=1

    /examples32/raycast_math.capx

  • alextro

    That's probably not every possibility. Here's three different ways:

    This uses normal pick logics:

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

    This does it all in an array:

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

    This does the same as above but in js. There is some overhead of copying the map to and from js, and likely something more efficient could be done on the js side.

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

  • Animmaniac

    I haven't given a whole lot of thought how the event wizard would work with the design. Right now the design is like typed code to show what you can do. Things to help you do it would come later. Ideally though if you had an action like:

    Sprite.setPositionTo(sprite2)

    You could click on sprite2 and it would give a list of objects.

    In fact actions and conditions could be added in the same way as you can now in c2. Expressions are the main thing that is being revamped.

    In that function "a" is replaced with whatever object type you call the function with. So if you called it like this:

    Call indist (sprite, 100,100,50)

    "a" would be Sprite. It's basically another way to make things more generic.

  • Here's a new capx, but I guess it's not really simple.

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

    It takes a file and loads it into a text variable with ajax.

    The format of the file is just comma seperated:

    note,duration, note,duration....

    Notes are defined by the note and octave: ex: a4, a4#, etc...

    Rests are defined by "r"

    The meat of it is it uses a number i to define where we at.

    It get's the note from the music with tokenat(music, i, ",")

    It takes that and converts it to a frequency. Here I used an equation and a lookup, but it can all just be a lookup.

    Next it get's the duration with tokenat(music, i+1, ",") and sets a timer and adds 2 to i.

    When the timer finishes it goes again.

    I added little stuff here and there like fading the volume, and stopping if something invalid is in the file.

  • It's tricky to improve performance with events. In my experience simpler is better and when doing something more complex to improve performance you also get more event and picking overhead which reduces overall improvement.

    That said you'll probably want to measure it with wallclocktime to get a good idea if you're getting any improvements. "best first" might be a better choice than bi-directional or even going full A* might reduce the amount of cells to search through.

    There are other things you can do too. One I tried is to not use the overlapping condition. Instead i populated an array with uid's so I could pick the neighbors directly so it wouldn't have to check all the instances if they're overlapping. That roughly made it twice as fast. I say roughly because it would take anywhere from 0.01 to 0.05, whereas before it was 0.03 to 0.08 seconds with my test. I can provide that capx if you'd like.

    A next iteration could be to do all of it in an array and do no picking. That would give further improvements but would be harder to read. I'd imagine you may be able to half the time again, but that's just a guess. The only problem is it's less visual and more abstract at that point and if you change the tiles around you'd need to update the arrays accordingly.

    The ultimate for speed would be to use js for most of it. Basically send the array or tile positions to some js code, then tell it a start and end tile. This is by far the most awkward and least flexible, but the performance improvement of calculating the path itself will be around 10x faster, or more with more tuning on the js side. This can be done with the browser object, since making a plugin would require a good design idea and take longer.

    Another thing i've done elsewhere is to not do it in just one frame, but instead do it over multiple frames so it doesn't affect the framerate.

  • kaiko

    You could perhaps use canvas or paster, they both have a unique image per instance. There may be other plugins that do it, but I don't use many.

  • Pretick is the very next spot we can run code after the game draws, and since C2's snapshot runs right after a draw, this will get you pretty close.

    Best I can tell telling the runtime to redraw before using imageUrl is needed. The snapshot function does this and I recall it not working if we don't.

    By boolean I mean something you'd add to your code. Something like this:

    action()

    {

    this.grabcanvas = True;

    }

    pretick()

    {

    if (this.grabcanvas)

    {

    this.grabcanvas=false;

    ...

    }

    }

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use y=sqrt(r^2-(X-a)^2)+b where a,b is the center and r is the radius. That would give the equation for the top half of the circle. Make the sqrt negative to get the bottom half. There's an example of this in some terrain destruction using tilemaps elsewhere on the forum.

    Or you could just loop over all the pixels and draw the pixel if this is true:

    R^2>=x^2+y^2

    Replace X with (X-a) and y with (y-b) if you want to center the circle at a,b instead of 0,0.

  • Still it isn't an issue if your game doesn't lag. If it's really bothering you, file a bug report. I'm sure Ashley can give you a much better explanation than me.

    time is just the game clock, it's advanced by dt. Dt is affected by the time between frames and timescale. Now when the time between frames gets too big c2 will limit it, which is what you have a problem with. This was done on purpose to slow down instead of letting objects move too far per frame and miss collisions.

    Consider an object with a speed of 600.

    At 60fps it will move 10 pixels per frame.

    At 10fps it would move at 60 pixels per frame.

    So if walls were only 32 pixels wide, the object could move right past it.

    Limiting dt helps with this.

  • I don't see any reason for it. If dt wasn't limited objects would teleport quite far if you hit a loop like that.

  • 99Instances2Go

    I think normal picking works well for that sort of thing already.

    I do think it could be handy to be able to save a copy of the list of picked objects to a variable, but there are issues when objects can be destroyed.

  • corpvs2

    Top view can be done by setting the gravity to 0.

    To break up physics objects it's either a matter of using an animation or creating the fragment objects over the object, then destroying the original object.