donderdag 7 april 2011

Circle inside Circle Collision Example

This example shows you how two circles can be found inside each other. I tried looking for an roundedrectangle2d intersect feature in java but it had none as far as I could see.

import java.awt.*;
import java.applet.*;

public class CircleCircleCollision extends Applet
        public void init()

        public void paint(Graphics g){
         int x1=150;
         int y1=150;
         int x2=120;
         int y2=160;
        int dist;
            Point p1=new Point(x1,y1);
            Point p2=new Point(x2,y2);
            g.drawString("Collision!", 10, 20);

I discovered on a game development site that Real Time Strategy Games use this kind of collision for the units.

Geen opmerkingen:

Een reactie posten