R0J0hound's Recent Forum Activity

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

  • Yeah it’s row,column instead of column,row

  • Yeah referencing the bounding box doesn’t really work for that. Mesh coords are relative to the oriented box of the sprite if it had no distort.

    Basically the unlerp would only work if the sprite wasn’t rotated and if the bounding box was the same as if there was no distort.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Realized you probably what the layout position from mesh point coordinates too. I made an old post about it but search isn’t cooperating.

    You’d start with the position from the json, then using the original sprite’s position and size you convert to a layout position. The third action is if the original sprite had any rotation.

    Sprite2: set position to JSON.Get("w.mesh.points.0.0.x"), JSON.Get("w.mesh.points.0.0.y")

    Sprite2: set position to (self.x-0.5)*sprite.width+sprite.x, (self.y-0.5)*sprite.height+sprite.y

    Sprite2: set position to (self.x-sprite.x)*cos(sprite.angle)-(self.y-sprite.y)*sin(sprite.angle)+sprite.x, (self.x-sprite.x)*sin(sprite.angle)+(self.y-sprite.y)*cos(sprite.angle)+sprite.y

    Anyways hope that helps.

    Edit:

    Forgot to talk about the 0.5 part in the formulas. That would be the origin position of the sprite. 0.5,0.5 for center, and 0,0 for top left.

    Edit2:

    For zelevation too it would be:

    Sprite2: set zelevation to JSON.Get("w.mesh.points.0.0.z")+sprite.zelevation

  • Add the json object to your project and in events json: parse sprite.asJSON.

    Then you can access mesh points with

    JSON.Get("w.mesh.points.0.0.x")

    The 0.0. part is the row then the column.

    Heres how I found that. I added a sprite and set the mesh size to 2,2 and then set point 0,0 to have an xy of 0.5, 0.5. Then looking at the mesh part of the sprite.json we have:

    "mesh":{"cols":2,"rows":2,"points":[[{"x":0.5,"y":0.5,"z":0,"u":0,"v":0},{"x":1,"y":0,"z":0,"u":1,"v":0}],[{"x":0,"y":1,"z":0,"u":0,"v":1},{"x":1,"y":1,"z":0,"u":1,"v":1}]]}

    So all the mesh data is fairly easily accessible.

  • This page has a lot of useful info on how that fake kind of 3d can be done. It’s not construct specific but you can possibly find some older posts on here that made some examples based on this. I know I did at least once.

    extentofthejam.com/pseudo

    That said it’s probably easier to just use real 3d similar to that example posted. Changing the graphics, camera angle and movement can probably get you pretty close.

  • I'm also getting mostly 0s, but occasionally I get values. When I get a value it's mainly when barely hitting like a glancing hit.

    Why? Who could say, but it seems like the contact points are available on the following frame (construct has too many things that are only calculated at the end of a frame).

    So, a user fix could be to do events like this:

    every tick:
    -- signal "nextFrame"
    
    Ball1: collides with Ball2
    -- wait on signal "nextFrame"
    -- ... get contact info

    I suppose you could still miss hits if physics detects a collision with the circle, but construct doesn't detect a collision with the polygon since they both have their own collision detection.

    Another idea could be an expression like:

    Ball1.Physics.ContactCount>0

    and you'd get contact points from ball1 hitting anything. You could find what was hit as a secondary collision check.

  • Logging stuff can be useful to debug things but I only use the browser console for JavaScript stuff. When just logging stuff with events I just append stuff to a textbox, and even then it’s only temporary.

    You’ll have to indicate the location when you log manually. Usually it’s not a big deal but there isn’t an automated way to get the location when you log with events or JavaScript.

    Now if you made an addon to do the logging it can know the location on the event sheet it was called from. It seemed possible in C2’s addon sdk but no one ever used it. You’d need to investigate c3’s addon sdk to still see if you can do that. But it’s easier and faster to just manually specify the location than to make a plug-in to help with that.

  • Here's a few ideas:

    If you want to compare the visual overlap area you can do that by looking at pixels with a drawingCanvas. Basically draw one sprite to the drawingCanvas, snapshot the canvas, and then loop over the pixels and count the number of then with an alpha>50. That will give the Initial area. If the sprite isn't changing sizes save that to a variable, so you don't have to recalculate it every time. Then you paste the second object to the canvas with the "destination out" blend. That will erase the overlapping part from from the first sprite. Then you'd snapshot the canvas, loop over the pixels and count the pixels with an alpha>50. That will give the number of pixels not overlapping. Finally, the calculation will be percentCovered = 1 - (pixels not overlapping)/(initial area).

    Overall, that will take a few frames to complete since it involves a few async operations. Looping over all the pixels can be a bit heavy, so you'd want the canvas to just be big enough to cover both objects, and/or you could just sample some of the pixels like igortyhon suggested.

    Another way is to check the percentage the collision shapes are overlapping. It can be done in one tick but you'd need to use "object overlaps point" to sample stuff. The con is it's only approximate based on how many points you sample.

    You can also access the polygon points and if both objects have convex collision polygons you can calculate the exact area covered by the polygon and use a line clipping algorithm to clip one polygon by the other to get the intersecting polygon. The main complexity here is to clip the polygons and calculate the areas. It's not hard but won't be a one liner.

    If the objects are both unrotated boxes or circles, then you can do something even simpler.

    For example, if both are unrotated boxes you'd calculate the coverage with:

    Sprite1: overlaps Sprite2

    --- percent = (min(sprite1.bboxBottom, sprite2.bboxBottom)-max(sprite1.bboxTop, sprite2.bboxTop))*(min(sprite1.bboxRight, sprite2.bboxRight)-max(sprite1.bboxLeft, sprite2.bboxLeft))/(Sprite1.width*sprite1.height)

    Circles could be a relatively simple option too. Basically come up with the math from the two radii and the distance between the centers.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound