R0J0hound's Forum Posts

  • There are a few tutorials will various ways and a lot of topics on the subject. Maybe one of them is exactly what you're looking for, or at least give you a start.

    https://www.scirra.com/tutorials/search?q=inventory

    search.php?keywords=inventory&terms=all&author=&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search

  • If the loop is big enough it will eat up time. The idea I posted is a possible way to tune the length of it. Changing the numbers could give better results. In the end it's just a random idea. I probably would never use it, instead i'd go for the every x seconds idea.

  • Another idea would be to enable/disable the solid behavior for the stairs, and fall thru the floors. After a bit of head banging it works:

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

    The player is counting as falling even with slower speeds, but maybe the slopes are too steep. A solution to that is to only change the animation if the player is falling for a few frames.

  • Sam Mortimer

    Here's info about it.

  • The impulse of a collision is basically the change of velocity from before and after a collision. Using that info you can calculate it. Then you can use lerp or something to map the impulse to a volume.

    Here's one possible conversion:

    lerp(-1000, 0, min(impulse/1000, 1))

    which means when the impulse is 0 the volume will be -1000 dB, and when the impulse is 1000 or higher the volume will be 0 dB. Impulses in between will be between the two volumes. Tweak the numbers for different results.

    global number prevVelocityX=0

    global number prevVelocityY=0

    global number impulse=0

    on sprite collides with wall

    --- set impulse to distance(0,0, sprite.physics.velocityX-prevVelocityX, sprite.physics.velocityY-prevVelocityY)

    --- play sound at volume lerp(-1000, 0, min(impulse/1000, 1))

    every tick

    --- set prevVelocityX to sprite.physics.velocityX

    --- set prevVelocityY to sprite.physics.velocityY

  • Using regex for that doesn't sound like the most straight forward to me.

    First, the flag need to be "ig" instead of just "i". The "g" tells it to not stop at the first one it finds.

    http://www.w3schools.com/js/js_regexp.asp

    So then your expression would be:

    RegexMatchAt(gameSaveInfo,"fishCollectedUID:(\d+)","ig",loopindex)

    But, that doesn't give you the uid number, it gives:

    "fishCollectedUID:33" or something.

    You still need to get the number out of it. I guess you could use another regex for that.

    So it would look like this:

    repeat RegexMatchCount(gameSaveInfo,"fishCollectedUID:(\d+)","ig") times

    pick fish by uid int(RegexMatchAt(RegexMatchAt(gameSaveInfo,"fishCollectedUID:(\d+)","ig",loopindex),"\d+","i,0))

    --- fish: set invisible

  • Try Construct 3

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

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