R0J0hound's Forum Posts

  • Probably you’d just need to make a feature request to do that if the export doesn’t have an option to remove the title bar.

    Webview2 doesn’t come with much of a js api like nw.js did. It also has no command line switches. One rabbit hole you could explore are “wrapper extensions” as mentioned in the sdk manual. That would let you make a plugin in c++ land which has far less limits on what is possible. Presumably you could make a plugin that uses the winapi to get the current process, then the window, and from that change a flag to hide the title bar. Could be a pretty big time sink to figure out and do though. I won’t venture it since I just use the free version and never use exports.

    Making an official feature request is probably the easiest approach.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you have a project you’re trying to open that relies on those versions?

    Even though the GitHub doesn’t have the updated 0.24 files it does have the change log from 0.23: two expressions and a fix. You could update it to a 0.24 release yourself.

    It’s simple enough to change the version to 0.24 and add the two expressions to the plugin. I’d imagine they have two number parameters for x and y. You’ll have to guess the ids of the expressions unless you have a project that uses them, in which case you can find the ids in the event sheet xml file. But if you had to guess I’d imagine they were 0 and 1 based on how the actions are numbered. That would at least let you open your project and be compatible with the real 0.24 release.

    Implementing the js side of the expressions should be simple enough.

    The fix for “block using object” would be the most involved, but not too bad. At a glance the plugin uses a 2d array to store the cost of cells and if they are blocked. When it uses an object to block it loops over all the cells that overlap the objects bounding box and sets them. So I’d assume there was a simple typo or oversight in 0.23 that needed correcting.

  • I don’t have an example. The way to load a data url is simple. For example use the “load frame from url” action of the sprite object.

    Start of layout

    — Sprite: load frame from url "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAwFBMVEUcdLVRaKWfbHD5VlL9WFX/W1H1T2igEeOwUn2naGL8VFL/WlXbUU9mO0ZrQT+lPmjlp6r0cnP/VU/uT0tFPkoWNkcSLT8eMz3rdne0rLjJnqaTWF8vSVlGUV8gLTwgLz37UEv9XVnFkpqPpLNzgY83RlYlM0JHX3XDTlDqUk/2UExZVmN1hpeTpat2fpR0GOe4Sk3pVVLqVlMoLDsZLjo9RmSPPPaFAP/TUFD7WFP0VlNEOEYSMDtQLlCLAOd6AP8xRjMWAAAAH0lEQVQIW2NkYIQCDhhDAMaQgDEUYAwNGMMAxrCA0gAgEAEhAJ4eUwAAAABJRU5ErkJggg=="

    That replaces the current frame with an 8x8 version of your avatar.

    You can convert an image into a dataurl with tools online, or in construct with the drawing canvas, or with JavaScript I suppose.

  • You could load an image from a dataurl to get an image without a file. You just have to do that in events. A data url has the file encoded as a base64 text string. The main drawback is base64 is 33% larger than a normal file. It could similarly be done with audio files.

    In a more complex fashion you could load a file you previously encrypted with some js or into the binary object. Then you’d decrypt it and convert it into a dataurl to then load into the sprite or audio plugin. That would avoid the size increase but you’d add to the loading time to do the decryption and conversion.

    Probably you’d only do that for a few spoiler images. It would be laborious for doing that with a full sprite animation. Not to mention you’d lose the optimization of images being sprite sheeted together.

    Bear in mind you can’t load images into all the plugins at runtime. For example spritefont and tilemap don’t have that capability. Also loading images into tiled backgrounds load it per instance so that would be inefficient.

    Probably look at the cryptography object.

  • So, the Separating Axis Theorem (SAT) is probably the easiest algorithm to use to implement collision detection and response between rotated rectangles. Here's one possible implementation in events:

    dropbox.com/scl/fi/buz1axwu4pv9p16m2qos9/sat_test2.capx

    I don't have a js version of that.

  • That bit of code just resolves overlaps between a bunch of circles that are the same size. Then to make it faster all the circles are first added to a grid spatial hash.

    So roughly it creates the grid spacial hash, adds the circles to all the grids their bounding box overlaps, then loops over the circles and uses the spacial hash to get other nearby circles, and finally it detects collision and pushes them apart.

    I don’t understand the question to have a rectangle instead of a square. You can make the grid of any size but it just needs to be the same size or smaller than the circle size.

    The layout size is used to have something to divide into grids. It could be made to reuse the same grids when objects are outside the layout. Probably by using x%layoutWidth or something.

    The angle is used for the push out logic for circles. Circles are the simplest to do that for. Using object bounding boxes instead are a bit more complex. Beyond that the push out logic would require some fancier algorithm such as SAT,GJK/EPA, MPR, SDFs,…etc to do the collision detection and resolving.

    If all you want to do is detect if two objects overlap it’s easiest to just use construct's js api overlapping function.

    That example was just tailored to a specific thing. It’s not really general purpose without a fair amount of modification.

  • To predict a path basically involves repeatedly simulating frames to get the path. I think previous topics tried to simulate that, but I actually haven't tried your approach of using an impulse to simulate a frame.

    Here's the idea refined, and it seems to work great.

    The setup is to set the physics stepping mode to fixed. With that the time step is always 1/60. Then to simulate the path you'd copy an objects position and velocity and then with a loop use timestep*force for the impulse, and then manually advance the position with the velocity.

    dropbox.com/scl/fi/7o7pjwaffwty9n3u8dke0/perdict_physics_path.c3p

    You can use a larger time step but since gravity forces vary by position the resulting path will be approximate and diverge pretty quick. In the same way using framerate independent stepping mode the predicted path will vary a lot.

  • You’re welcome. I was thinking a bit more and since you can get the accuracy of some gps coordinates you can probably utilize that.

    Here’s some rough pseudocode of how the logic might look. The gps vars keep track of lat,lon,alt, and accuracy.

    Start
    — prevGps=getGps()
    — TotalDist=0
    
    Update
    — curGps =getGps()
    — Dist= calcDist(prevGps, curgps)
    — If dist>(prevGps.acuracy+curgps.accuracy)
    — — totaldist = totaldist+dist
    — — prevgps = curgps

    You could probably get away with just using the current gps accuracy. But regardless be careful to use the same distance units for everything or be sure to convert them to be the same.

  • Lat longs give a point on a the earth which is approximated by a sphere. You can use spherical coordinates to convert the gps to xyz vectors from the center of the earth.

    X=radius*cos(lat)*cos(lon)

    Y=radius*cos(lat)*sin(lon)

    Z=-radius*sin(lat)

    If you then do a dot product between the two vectors you can find the angle between them. A dot B = len(A)*len(B)*cos(ang)

    And finally you can use the formula for arcLength = radius*angle to get a distance.

    That should come out to the following with two lat,Lon’s.

    dist = acos(cos(lat1)*cos(lon1)*cos(lat2)*cos(lon2) + cos(lat1)*sin(lon1)*cos(lat2)*sin(lon2) + sin(lat1)*sin(lat2))*180/pi*radius

    Where the radius of the earth is 6371 km.

    You’d probably want to add the average of the altitudes of the two points too. 6371+(alt1+alt2)/2. But I’m unsure how much that would change things.

    You probably could just measure the straight distance between two points instead. That would remove the dot product and arc length step.

    Dist = radius*sqrt((cos(lat1)*cos(lon1)-cos(lat2)*cos(lon2))^2+(cos(lat1)*sin(lon1)-cos(lat2)*sin(lon2))^2+(sin(lat1)-sin(lat2))^2)

    I factored out the radius but you could be more accurate using the altitude per point if you wanted.

    You could try to find a js library to do the calculation too. No idea if they’d be doing anything beyond what’s being done here.

    And just thinking aloud, but the gps coordinates have a varying accuracy so you might need to filter or smooth things out. For example if you’re standing still the gps coordinates may drift around by the accuracy amount so you’d get distance when you didn’t actually move. To filter you could only add distances longer than say a few feet. Or to smooth you could collect multiple lat Lon’s and average them before using it.

  • It still is jerky huh?

    To be completely smooth we’d want every frame to have the exact same frame time and no frames skipped. We have some control over that with how much logic and rendering we do per frame, but it can still vary per browser or machine. Btw I wasn’t really noticing much jerky motion with your game.

    It’s probably easier to notice the frame variance when moving things in straight lines with constant speeds.

    Anyways, only other suggestion besides using lerp like that to do an ease out, is you can give the camera velocity and do some math to do a damped spring to move the camera. Tune the two values from 0 to 1.

    Var vx=0

    Compare: dt > 0

    -- add -0.005*(scrollx-player.x)/dt-0.1*vx to vx

    -- set scrollx to scrollx+vx*dt

  • To make the ball motion smooth, just use the bullet behavior or "set x to self.x+1200*dt" instead of the tween every 0.5 seconds.

    Another thing to try is use lerp in a frame independent way.

    set scrollx to lerp(scrollx, ball.x, exp(-200*dt))

    or

    set scrollx to lerp(scrollx, ball.x, 1-0.001^dt)

  • You could replace the drag drop behavior with the car behavior and just disable it on all the instances but the head. Or just set the head instance (sprite.i=0) position to the car.

    Also currently it just pulls objects together if they are farther than 32 pixels apart. You can also make it push the objects apart if you remove the max from the move at an angle equation. I think that’s what you meant by squish together when braking.

  • Here's a behaviorless way to do it.

    First chain tries to replicate the stretch from pinning to pinned objects.

    The rest order from head to tail with an adjustable stretch stiffness.

    dropbox.com/scl/fi/yzrr05uk5ch8fex2hrqrv/chain_stiffness.c3p

    Might be useful or give some ideas.

  • Lionz’ suggestion is by far the easiest. Just put invisible sprites on the edges of the platforms, and have the enemy change direction when colliding with them.

    If it’s too laborious to place the sprites then there is likely a way to automate placing them, but it depends how you make your platforms.

    Another way could be to detect the edges of the platform with a small detector sprite. Say the enemy is moving right. Move the detector sprite to the bottom right corner of the enemy. If the detector isn’t overlapping a platform the change the enemy direction to left. You’d do similar logic for moving left. You could also use “pick overlapping point” instead of a small detector sprite.

    A third way could be just to pick the platform the enemy is on and change direction when getting close to the edge. Would work well if the platform is just one long object. Logic for the right edge would be the following. Left edge is similar.

    For each enemy

    Enemy overlaps platform at offset(0,1)

    Enemy: is moving right

    Compare: enemy.bboxright>platform.bboxright

    — enemy: set direction to left

    Fourth way would be to just use the sine behavior to move the enemy. Place the enemy at the center of the platform, set the magnitude to half the platform width, set motion to horizontal and wave to triangle. I’m unsure if position would drift over time though with different frame rates.

    There are probably many other possible solutions.

  • There is a system action: Set layout vanishing point