R0J0hound's Forum Posts

  • If instead of a random area outside the screen you just want a random spot on a rectangle bigger than the screen you can do this. The var k sets how much bigger the rectangle is beyond the edge of the screen and r does a calculation to make the random more uniform. If we just set r to choose(0,1) the short sides would get more points.

    var x=0
    var k=16 //0 would be edge of screen, 16 would be 16 pixels beyond the edge of the screen
    
    set r to random(1)<(OriginalWindowWidth+2*k)/(OriginalWindowWidth+OriginalWindowHeight+4*k)
    
    set x to (r?random(-k,OriginalWindowWidth+k):choose(-k,OriginalWindowWidth+k))+ViewportLeft(0)
    set y to (r?choose(-k,OriginalWindowHeight+k):random(-k,OriginalWindowHeight+k))+ViewportTop(0)

    Or if you wanted a point outside of the layout instead of the screen:

    var x=0
    var k=16 //0 would be edge of screen, 16 would be 16 pixels beyond the edge of the layout
    
    set r to random(1)<(LayoutWidth+2*k)/(LayoutWidth+LayoutHeight+4*k)
    
    set x to r?random(-k,LayoutWidth+k):choose(-k,LayoutWidth+k)
    set y to r?choose(-k,LayoutHeight+k):random(-k,LayoutHeight+k)
  • Yeah, that looks pretty good. I wish I could knock out good art that quick.

    Here's the idea I was working on. It needs to be reworked to handle multiple vines and the transfer of momentum when grabbing the vine needs tweaking.

    https://www.dropbox.com/scl/fi/selt7na61fdxs7xkw7zx2/rotate_vine.capx?rlkey=qcom7w4ienynvdjen2r68oyza&dl=1 
  • Here's one way.

    https://www.dropbox.com/scl/fi/tbsd0woz3v14csc10q8mz/array_combine.capx?rlkey=m5kqrkoo9m8g0thdttvnxg1ve&dl=1
  • Looks like he found a a nice solution. My guess it’s a nice animation and it moves along the vine segments. Not bad.

    twitter.com/PD_CGT_games/status/1708700907238539702

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think calculating the path in a more dynamic way could be possible too. A reason for that could be you want the spinning to start where you first grabbed the vine, or if the shape of the vine is dynamic.

    The first step would be to have a curve fit the shape of the vine, then find the point on the curve that was grabbed.

    After that it’s a matter of moving along the vine, and the spin is done by moving along an angle perpendicular to the vine with a distance of 32*sin() or something. You can use cos() for the zelevation or use it to change the zorder. Finally when the end is reached you’d enable the platform behavior and set the speed.

    The coiled path around the vine could be refined further by doing some relaxation filter or something. Maybe overkill but it seems to kink a bit otherwise.

    I’ll finish up an example tomorrow and see if I can simplify the solution further. At this point I only have twisting around an arbitrary path.

  • It just uses whatever blend mode the object is currently using. So you’d need to set the blend mode before pasting. (And probably set it back to normal after).

  • It would be nice to have access to collision cells from js, so it’s a valid request.

    Still I suspect making a spatial partition in js could be faster. I made a rudimentary grid hash and even outperformed the physics behavior which does its own spatial hash behind the scenes.

    If I attempt it again I’ll reference this. Seems fast enough. And it builds the spatial partition every frame.

    matthias-research.github.io/pages/tenMinutePhysics/11-hashing.html

    github.com/matthias-research/pages/blob/master/tenMinutePhysics/11-hashing.html

  • When picking becomes a problem I try to do things in a way that does less picking that looks cleaner if possible. One idea is to make getter/setter functions with uids. Another is to use one data structure object such as json to store all the data.

    JavaScript works too but it has its own set of annoyances so pick your poison I guess.

    I’m always trying to find ways to do stuff in simpler, cleaner ways, and some kind of system on top of events to abstract away complexities often come up.

  • Sounds like fun. But I like math and replicate behaviors with events anyways.

    There is value in working within constraints.

    Making an event based drag and drop is useful. I can think of two times at least where I had to do that since the behavior didn’t give sufficient control of when to drag and drop.

  • You can set the velocity toward the position of the other object.

    So once you get the angle toward a position you can do:

    Vx=speed*cos(angle)

    Vy=speed*sin(angle)

    But there are other ways.

  • You can access individual letters with the mid() expression. The tokenat() expression can be useful to grab individual words if there are spaces in between. To filter around punctuation you can remove them first with replace() or maybe regexreplace to remove all punctuation in one shot, but that can be tedious to do.

  • The non-behavior way is to compare the distance between each pair of objects and push them apart and update their velocities if they are too close. That doesn't scale well with such a large amount of objects, so we need to do some kind of spatial hash so we only need to check objects that are nearby. Unfortunately when doing it with events it's hard to get that much of an improvement so JavaScript is better.

    Here's one possible test of that. It handles one object type and treats them all as the same size. Disable the group to compare performance with the physics behavior.

    dropbox.com/scl/fi/ja4hfo7dv9sqq7phs1q25/spatialGridJS.c3p

    With 1400 objects:

    Custom push out: 60fps

    Physics: 10fps

    The example also does it's own physics, but you can just use the spatialGrid() function if you just want push out.

  • Maybe a nw.js issue then? If you can reproduce it reliably then filing a bug with scirra is your best bet. As an alternate to nwjs they have that webview2 export which seems to have less issues. Maybe that's a solution.

  • Like it was pointed out a number can’t be three values at once.

    What you’re trying to do is more complex. Three objects, each with their own value. Maybe something like this?

    Var count=0

    Every tick

    — set count to 0

    Sprite: var=1

    — add 1 to count

    Sprite: var=3

    — add 1 to count

    Sprite: var=7

    — add 1 to count

    Count=3

    — set text to “match”

  • All bets are off if they just find where you encrypt it in your code, and either understand it or just copy it. But I guess you could make it harder to find even the code.

    At a deeper level you could generate the encryption code on the fly too, encrypt that and append that to the save.

    You could make the key random and store parts of it in the encrypted result.

    You could come up with some other esoteric scheme to do the encryption.

    The more effort you take to do things to obscure it the longer it would take someone to figure it out.