R0J0hound's Forum Posts

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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;

    ...

    }

    }

  • 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.

  • Can't look at the capx because it uses plugins I don't have installed. You can look in preview.js for the exact implementation but if you had to do dt and time with the event sheet this is what it would look like:

    global number time=0

    global number previoustime=0

    global number dt=0

    every tick

    --- set dt to min(0.1, wallclocktime-previoustime)

    --- set previoustime to wallclocktime

    --- add dt to time

  • Looks like the closest you can get to the runtime snapshot is to use pretick.

    Basically run this when the plugin is created:

    this.runtime.pretickMe(this);

    Then when you run the action to capture the pixel, you set a boolean in your plugin and tell the runtime to redraw.

    this.runtime.redraw=true;

    Then in pretick you'd grab it.

    I wouldn't call drawgl directly. I mean you could but it would be very slow. Getting pixels from the canvas is slow anyway. What we're doing is grabbing the entire canvas and loading it into an image, which can take several frames. If you called drawgl directly you'd just be making the runtime draw something it would draw anyway.

  • CreativeMind

    None to my knowledge, but I only use HTML export. However there shouldn't be since it's just math an JavaScript and JavaScript should ru the same everywhere.