R0J0hound's Recent Forum Activity

  • Set the Sprite size to 1x1 and the position to 0,0

  • You do not have permission to view this post

  • If you want to try an ai coder then go for it. I wouldn't be interested in trying since it would create more work for me to verify made working changes and if it broke it I'm not interested in debugging it.

    I'm happy you've found enjoyment in using this plugin, but at this point I'm not likely to revisit it at all. I'm more likely to make a stand alone tool independent of Construct since most of what I want to do in Construct requires workarounds and once I made such a tool I'd probably disappear from here rather quickly.

  • The colors that construct support are just one single number. That js library appears to return an objects so I guess you'd get the color with rgbEx255(gotColour.r,gotColour.g,gotColour.b) but I'm almost certain that rgb function is accessed differently in js than in events.

    If you want a event based solution there's this:

    construct.net/en/forum/construct-3/how-do-i-8/hex-colour-values-code-179603

  • Here's an event based way

    https://www.dropbox.com/scl/fi/0zafmr4lyclg3mmcodkea/hex2color.c3p?rlkey=6ird9o8ud8opsp2k3v7chtb3x&dl=1
  • Here's an example. Uses helper functions with uids to access 1d arrays. local arrays are created as temporary and are automatically cleaned up each tick. Shows examples of global, local, static and instance variables.

    https://www.dropbox.com/scl/fi/92uyaria57umj85d6vsps/arrayVariables.c3p?rlkey=kcnxwxheph0g7poe3lo7h7qc1&dl=1

    Could be modified for 2d arrays.

  • Using some kind of id to reference each array and having helper functions to access or manipulate them is probably the easiest way to go. Uid is good as an id since you can access newly created instances immediately. Iid is an alternate idea where you can access data without a helper function. For ex: array(a).at(5). But for iid you’d not want to be creating instances on the fly, instead you’d want an object pool that you’d allocate from.

    Global, static or instance variables would require you to create arrays. And for instance variables you’d need to manually destroy them.

    For local variables you could either manually destroy them when done with them (tedious to keep track of) or just mark them as temporary and then clean up all the temporary instances at the end of the tick. Still it will be on you to make sure you don’t store temporary arrays in non local places.

    Another strategy for locals is to just have a small amount that you juggle the use of. Typically you don’t need too many.

    You mentioned json. You could use a single json object to store all the arrays instead instances of the array object. I say a single instance because that could be simpler to work with than dealing with picking.

    If you use helper functions to access stuff you can implement things anyway you like under the hood. Here’s a possible design of the helper function.

     new(tempBool) -> id
    delete(id)
    isTemp(id) -> true/false
    clone(id) -> newId
    copy(id, other)
    equals(id1, id2) -> true/false
    clearToValue(id, value)
    mergeX(id, otherId)
    mergeY(id, otherId)
    getwidth(id) -> width
    getheight(id) -> height
    setSize(id, width, height)
    get(id, x, y) -> value
    set(id, x, y, value)

    Anyways. Just some ideas. I’ll have a look at an implementation later. There are usually simplifications that can be done.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Probably something like this or so.

    https://www.dropbox.com/scl/fi/tp34591xsnw69ga17m58r/fish_maybe.c3p?rlkey=wquwjk7sfp51hgj56v31y70mw&dl=1
  • I'm not familiar with that game and I'm too lazy to google it. But anyways...

    Look at the mesh distort feature. You can animate the mesh points by moving them with events. The exact way you'd move the meshpoints is up to you and some artistic fiddling I suppose. Maybe you could use sin() or something to get a wavy motion.

  • After more tests I'm finding that stoppingDist=velocity*velocity/2/acceleration formula not well suited to stop on a fixed spot. You can compare it with the current distance to know when to start slowing down, but it will always be a bit late so it will overshoot the target position as you've seen. I also find it a bit annoying to have to handle the case where the velocity is away from the target.

    Anyways, here is one partial solution. For simplicity I'm just covering the case where the target is to the right of the position. I use a variable to store the state since we have to clamp the position and speed when moving. The result would be stopping at the target and discarding any remaining velocity.

    if state=normal
    -- //accelerate toward target
    -- velocity+=acceleration*dt
    -- position+=velocity*dt
    -- distance2target = distance(position, target)
    -- if distance2target < velocity*velocity/2/acceleration
    -- -- state=slowing
    if state=slowing
    -- velocity= max(0, velocity-acceleration*dt) 
    -- distance2target -= velocity*dt
    -- position -= velocity*dt
    -- if distance2target<0
    -- -- position-=distance2target
    -- -- velocity=0
    -- -- state=arrived

    In a similar fashion it could be modified so when the state is changed to slowing we readjust the position/velocity as if it started slowing at the precise time between frames. That would make it so there was less to no velocity leftover when it arrives. However care must be taken to handle stopping short, so we'd probably need to check the case where the relative velocity becomes negative.

    Ideally all that fully implemented could be reduced to something simpler. In the end it would just be a linear motion so maybe just switching to an ease might be more user friendly.

    As an alternate idea you could try the Arrival Steering Behavior. That would be nicer in the 2d case as it would gradually turn before smoothly slowing down to the target. I had one issue with that though, the original paper basically relies on a fixed timestep, so when I added dt it made things overshoot more. As a fix I added a tuning factor to reduce overshoot.

    https://www.dropbox.com/scl/fi/qoowuphapihsbvl0vg7lm/arrivalSteeringBehavior.capx?rlkey=quochzw7cd7fgp51elzqb2xx7&dl=1

    Another idea is to use a damped spring to do the motion. Pick a spring stiffness and then a damping so it's critically damped (aka no overshoot) and you're good.

    https://www.dropbox.com/scl/fi/mjw9c25v91mezo18n7foj/dampedspringArrive.capx?rlkey=9rjkwlv09i5qc8uu17k89ucip&dl=1
  • A few thoughts:

    You want the object to start slowing down when it’s a certain distance away. That distance is probably hit between the last frame and the current one. You could solve for that distance and between the frames and start applying the acceleration then. You could do something similar when the target is reached.

    Another idea could be to adjust the acceleration to compensate since it will always start slowing down a bit late.

    Simplest would be to clamp the position to stop at the target so it doesn’t overshoot.

  • Simplest would be to just make an animation to do that. More complex would be to utilize distort meshes to make a piece of the object. You’d have to duplicate the sprite for each piece. Then set the mesh point xy to the edge of the shape used of the piece and the uv so that the image isn’t distorted. Doing that in a dynamic way is probably too complex so you could use a 3d modeler to chop up a quad into fragment polygons. They should be convex but you can have concave polygons in some cases. I think I’m only scratching the surface on how that could be done. There’s a lot of busywork and smaller puzzles to solve. So again it’s probably easier to do an animation or just draw the smaller prices. Or you could draw the object to a canvas and use a blend mode to mask out the part you want.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound