Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About phaelax

  • Rank
  1. phaelax

    Finding Coordinates in a JFrame

    This might help you: public void mouseClicked(MouseEvent e) { PointerInfo a = MouseInfo.getPointerInfo(); Point point = new Point(a.getLocation()); SwingUtilities.convertPointFromScreen(point, e.getComponent()); x=(int) point.getX(); y=(int) point.getY();}
  2. Not tested, but I think this'll work. It does assume that only 1 sphere(P) is moving and the rest are stationary. P - origin of stationary sphere A - origin of moving sphere 'S' from start B - ending point of sphere 'S' n = (P.x-A.x) * (B.x-A.x) + (P.y-A.y) * (B.y-A.y) x = B.x - A.x y = B.y - A.y d = x*x + y*y u = n / d if u >= 0 && u <= 1 Vector2D I I.x = A.x + u*(B.x-A.x) I.y = A.y + u*(B.y-A.y) distance = sqrt((I.x - P.x)^2 + (I.y - P.y)^2) if distance <= (P.radius + S.radius) then return true endif
  3. Set up port-forwarding on your router. Anything incoming to your IP over the specified port will be forwarded to the computer you choose. It might also be called a "Virtual Server" on your router settings. Mine's listed under NAT.
  4. Not sure if this will work in your situation, but its what I use to get the height of my terrain. In my terrain object, all the X and Z vertices are evenly spaced and only the Y is adjusted. If that's not the case for you, then this wouldn't work. Verts are assumed to be clockwise in this function. function getHeight(float x, float z) { float y = 0.0 // xsegs,zsegs - number of segments terrain is broken into // width - width of terrain float tileSizeX = width / xsegs float tileSizeZ = depth / zsegs row = z / tileSizeZ column = x / tileSizeX //make sure point is within the terrain boundaries if row < 0 || row >= xsegs || column < 0 or column >= zsegs return 0 zNorm = z - row*tileSizeZ xNorm = x - column*tileSizeX //find which right-triangle of the segment to use if tileSizeZ*xNorm >= tileSizeX*zNorm { //first triangle float y1 = height of vert 1 float y2 = height of vert 2 float y3 = height of vert 3 y = y1 + (zNorm/tileSizeZ)*(y2-y3)+(xNorm/tileSizeX)*(y3-y1) } else { //other triangle float y1 = height of vert 1 float y2 = height of vert 2 float y3 = height of vert 3 y = y1 + (zNorm/tileSizeZ)*(y2-y1)+(xNorm/tileSizeX)*(y3-y2) } return y; }
  5. All I'm doing is drawing some boxes onto a Canvas that can be dragged with the mouse. Since it flickers when i move them I wanted to use double buffering. Here's part of the class. public class DisplayCanvas extends Canvas implements MouseInputListener { private BufferStrategy buffer; private ArrayList objects = new ArrayList(); private DisplayObject selectedObject = null; public DisplayCanvas() { this.createBufferStrategy(1); buffer = this.getBufferStrategy(); this.addMouseListener(this); this.addMouseMotionListener(this); } When I try to set the number of buffers to anything higher than 1, I get this error when trying to run the program: java.lang.IllegalStateException: Component must have a valid peer Not entirely sure what it means and I couldn't really find anything about it other than the docs said its thrown if the canvas isn't displayable.
  6. What specifically isn't working and what are you trying to do with the mouse listener?
  7. Must be a localized problem specifically with your machine. I ran your code with 20 also and connected all 20 times, same as Giuoco. I'm running Win2k with java 1.4
  8. Quote:the pile will expand of clickCount == 2 and will fail to de-expand after another double-click-- the clickCount is actually at 4. Or you could just tell the user to not have such a happy trigger-finger and wait that extra 1/10 of a second for the click counter to reset back to 0. I understand what you're trying to do, but why bother? If the user collapses a stack after he just expanded it, then he'll learn to click only twice instead of 4 times.
  9. phaelax

    pixel count of a circle

    Bit of an odd question, but is there a way to estimate the number of pixels that'll be needed to draw an outline of a circle with a given radius? for a = 1 to 360 step ? x = sin(a)*radius y = cos(a)*radius dot x,y next a 'Cause no sense in looping 360 times for a circle with a radius of 2, hardly anything is drawn. It's not really a speed concern I have, but larger circles may take more than 360 pixels to draw it completely without spacing between each dot. So what would be the smaller amount to increment by to complete the circle cleanly? (hope this makes sense)
  10. phaelax

    Verlet integration spring system question

    Quote:1. is there a standard way to connect a cloth like mass spring system? I can't remember off the top of my head, but the book "Physics for Game Developers" had a chapter on springs. In it, was a cloth example using springs. I'm not at home to check my book, so I'm not entirely sure if it used verlet or runge-kutta. If you could get a hold of a copy of that book it may help. The more I think about it, the example probably used runge-kutta. Sorry I couldn't offer more help.
  11. phaelax

    line of sight

    Thanks for the insight. I think I may end up going with the 3 rays idea, as well as taking the distance into consideration. If any of you have played Thief, thats basically the kind of system I'm after. So I don't need an exact percentage or perfect accuracy.
  12. I'm having some trouble figuring this one out. I'll try to describe the scenerio first. Imagine two laser canons. Canon_A fires a laser in direction 'D' with a velocity of 'v' units per 1 second. After 'x' amount of seconds, Canon_B detects the shot from Canon_A and fires its own laser to intercept using a different velocity. How can I find the direction vector that Canon_B needs to use in order for its laser to intercept Canon_A's laser? Since I don't know the time of intersection, I'm not sure how to put the two equations together. position of Canon_A's laser = A + Dvt position of Canon_B's laser = B + Dvt A,B = position of where canon was fired D = direction vector, normalized v = velocity in units per 1 second t = time in seconds Just for simplicity sake, we can assume both fire at the same time.
  13. phaelax

    line of sight

    Hopefully, this will explain better. Here, 50% of the player is visible to the bot. All I know to do really is just cast a line between the two objects and get a simple yes or no on an objects visibility to another. The idea is so that a bot won't see a player who has a toe sticking out from around a corner 1000 yards away. 10% -> bot thinks it sees something, takes caution 20% -> bot spots an object and goes to investigate 50% -> bot runs to attack I hope this gives you a better idea what I'm trying to do.
  14. phaelax

    line of sight

    I have a line of sight between two ellipsoids, thats not my problem. I want find out how much (what percent) of the ellipsoid is visible to the other. I'm not really sure where to start with such a thing.
  15. phaelax

    interpolation of 3 points

    I understand linear interpolation between 2 points, but how would go about interpolating between 3 points? Such as the points of a triangle? value = a + i(b-a)
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!