R0J0hound's Recent Forum Activity

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

  • Try Construct 3

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

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

  • You can do it with physics forces. Take the sprite you want, and create a family “other” from that so you can reference two instances at the same time. Then do something like this:

    For each sprite

    For each other

    Sprite.uid <> other.uid

    — sprite: apply force 1/distance(sprite.x,sprite.y,other.x,other.y)^2 toward (other.x, other.y)

    If it’s too subtle the increase the value of 1. Try 1000 or 10000

  • Choose() will use one of the values at random. You probably wanted chooseindex()

  • If you know the speed the disk is rotating then you can rotate the sprite by the disks center by that amount.

    Sprite: overlaps disk

    — sprite: set position to (self.x-disk.x)*cos(disk.rotateSpeed*dt)-(self.y-disk.y)*sin(disk.rotateSpeed*dt)+disk.x, (self.x-disk.x)*sin(disk.rotateSpeed*dt)+(self.y-disk.y)*cos(disk.rotateSpeed*dt)+disk.y

  • I guess having backups that aren’t on your computer is a common response to this. Like an external drive or cloud storage.

    However a bad or buggy driver shouldn’t delete your files. Since you were able to fix your computer that means the hard drive wasn’t fried.

    If something happens where you can’t boot into windows to access your files you can always boot from a flash drive instead to access what’s on your hard drive. Those are pretty common to find online. They often include tools to access files even if the file system is corrupted or the file was deleted. Even if you can boot into windows and delete a file by mistake there are tools to undelete it as long as it’s not overridden by something else. The other benefit of booting from a flash drive is it won’t be creating new files on your hard drive and possibly overwriting files you deleted.

    All deleting a file does is to remove the reference to the file on the hard disk. The contents of the file is still there. However the file system is no longer protecting that portion of the drive so it can get overwritten if a new file is created that happens to use the same area. So in short, if a file is deleted you can often undelete it soon after, but wait too long and it’s probably mostly gone.

    A common way people fix a corrupted windows install if to factory reset the drive to a working state which overwrites the whole drive to how it was when you got the computer. Unfortunately there isn’t a whole lot that could be undeleted after that.

    Anyways, my point is there are ways to get deleted files back or even access files on a computer that isn’t booting. At least short of the hardware being fried or destroyed. And even for that there are companies that will do data recovery from destroyed or fried hard drives if the data is important enough to you to pay for.

  • To be clear the issue is from multiplying a number by text.

    Usually construct lets you know that it can’t do that when you write

    25*”1.3”

    So since the value is in an array it doesn’t know if it’s a number or text till runtime. And construct doesn’t really ever give runtime errors. So it just silently doesn’t do anything when trying to multiply a number by text.