Java 类org.newdawn.slick.geom.Line 实例源码

项目:trashjam2017    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:Progetto-C    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:BaseClient    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:Saboteur    文件:SaboteurGame.java   
/**
 * Casts 3 rays from the player to the given point and returns the 3 points
 * where the ray collides with an object or null
 * 
 * @param g
 *            the Graphics context
 * @param vPoint
 * @return [0] is the ray in the center, [1] is the left ray and [2] is the
 *         right ray
 */
public Vector2f[] getCollisionPoints(Graphics g, Vector2f vPoint) {

    Vector2f[] theCollisionPoints = new Vector2f[3];
    Vector2f playerCenter = thePlayer.getCenter();

    Vector2f destPoint1 = vPoint.copy().add(vPoint.copy().sub(playerCenter));
    Vector2f destPoint2 =
            playerCenter.copy().add(destPoint1.copy().sub(playerCenter).normalise().scale(1700f).add(0.2));
    Vector2f destPoint3 =
            playerCenter.copy().add(destPoint1.copy().sub(playerCenter).normalise().scale(1700f).add(-0.2));

    Line ray1 = new Line(playerCenter, destPoint1);
    Line ray2 = new Line(playerCenter, destPoint2);
    Line ray3 = new Line(playerCenter, destPoint3);

    theCollisionPoints[0] = getCollisionPoint(ray1);
    theCollisionPoints[1] = getCollisionPoint(ray2);
    theCollisionPoints[2] = getCollisionPoint(ray3);

    return theCollisionPoints;

}
项目:Saboteur    文件:SaboteurGame.java   
private Vector2f getCollisionPoint(Line ray) {
    ArrayList<Vector2f> collisionPoints = new ArrayList<>();

    for (Line l : map.getCollisionLines()) {
        Vector2f collisionPoint = l.intersect(ray, true);

        if (collisionPoint != null) {
            collisionPoints.add(collisionPoint);
        }
    }

    Vector2f point = ray.getEnd();
    for (Vector2f pointOfCollision : collisionPoints) {

        if (point == null || thePlayer.getPos().distance(point) > thePlayer.getPos().distance(pointOfCollision))
            point = pointOfCollision;

    }

    return point;
}
项目:LightningBolt    文件:LightningBolt.java   
public void render() {
    float alpha = (float) currentTime / (float) totalTime;

    /***** Begin OpenGl *****/
    glPushMatrix();
    // Notice that the internal update will make these values all
    // simultaneously drop to 0, making it black, thus ending the
    // effect.
    glColor4f(alpha, alpha, alpha, alpha);
    glLineWidth(lineWidth);
    glBegin(GL_LINES); {
        for (Line segment: segments) {
            glVertex(segment.getStart());
            glVertex(segment.getEnd());
        }
    }
    glEnd();
    glPopMatrix();
    /***** End OpenGl *****/
}
项目:GPVM    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:GPVM    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:SpaceStationAlpha    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:cretion    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:slick2d-maven    文件:LinearGradientFill.java   
/**
 * Create a new fill for gradients
 * 
 * @param shape The shape being filled
 * @param trans The transform given for the shape
 * @param gradient The gradient to apply
 */
public LinearGradientFill(Shape shape, Transform trans, Gradient gradient) {
    this.gradient = gradient;

    float x = gradient.getX1();
    float y = gradient.getY1();
    float mx = gradient.getX2();
    float my = gradient.getY2();

    float h = my - y;
    float w = mx - x;

    float[] s = new float[] {x,y+(h/2)};
    gradient.getTransform().transform(s, 0, s, 0, 1);
    trans.transform(s, 0, s, 0, 1);
    float[] e = new float[] {x+w,y+(h/2)};
    gradient.getTransform().transform(e, 0, e, 0, 1);
    trans.transform(e, 0, e, 0, 1);

    start = new Vector2f(s[0],s[1]);
    end = new Vector2f(e[0],e[1]);

    line = new Line(start, end);
}
项目:Generic-Zombie-Shooter-Redux    文件:LaserNode.java   
@Override
public boolean checkCollision(Enemy enemy) {
    Line barrier = new Line(position.x, position.y,
                            other.getPosition().x, other.getPosition().y);
    boolean barrierCollision = barrier.intersects(enemy.getCollider());
    return super.checkCollision(enemy) || barrierCollision;
}
项目:LightningBolt    文件:LightningBolt.java   
public LightingBoltEffect(
    int time,
    Collection < Line > segments,
    float lineWidth) {
        this.totalTime = time;
        this.segments = segments;
        this.currentTime = time;
        this.lineWidth = lineWidth;
}
项目:Oberien    文件:FowToPolygonThread.java   
public FowToPolygonThread(FowToPolygonThread superThread, controller.State state, Coordinate c, ArrayList<Coordinate> sight) {
    this.superThread = superThread;
    this.state = state;
    this.sight = sight;
    this.c = c;

    ret = new ArrayList<Line>();
    thisThread = this;
    tileSize = Globals.TILE_SIZE;
}
项目:Saboteur    文件:MapServer.java   
@Override
public ArrayList<Line> getCollisionLines() {
    return collisionLines;
}
项目:Oberien    文件:FowToPolygonThread.java   
public synchronized void add(ArrayList<Line> al) {
    for (int i = 0; i < al.size(); i++) {
        ret.add(al.get(i));
    }
}
项目:reddit-game-jam-5    文件:Enemy.java   
public Line getDetectionLine() {
    return detectionLine;
}
项目:reddit-game-jam-5    文件:Enemy.java   
public void setDetectionLine(Line detectionLine) {
    this.detectionLine = detectionLine;
}
项目:Saboteur    文件:Map.java   
/**
 * @return a list of all lines of the collision-shapes of the map and the
 *         borders of the map
 */
public ArrayList<Line> getCollisionLines() {
    return collisionLines;
}
项目:LightningBolt    文件:LightningBolt.java   
/**
 * Generates a lightning bolt.
 * 
 * @param p0 - the starting vector.
 * @param p1 - the Ending Vector
 * @param duration - the duration of the effect
 */
protected void generateLightingBolt(Vector2f p0, Vector2f p1, int duration) {
    Collection < Line > segments = new ArrayList < Line > ();

    segments.add(new Line(p0, p1));

    float offset = 200f;

    double probability = 0.3; // probability to generate new partitions

    float height = 50.0f;

    Random random = new Random();

    int partitions = 4;

    for (int i = 0; i < partitions; i++) {

        Collection < Line > newSegments = new ArrayList < Line > ();

        for (Line segment: segments) {

            Vector2f midPoint = segment.getStart().copy()
                .add(segment.getEnd()).scale(0.5f);

            Vector2f perpendicular = midPoint.copy().add(90);

            perpendicular.normalise().scale(

            random.nextFloat() * offset - (offset / 2));

            midPoint.add(perpendicular);

            if (random.nextFloat() < probability) {

                // generate new branch
                Vector2f direction = midPoint.copy()
                    .sub(segment.getStart());

                direction.add(random.nextFloat() * height);

                newSegments.add(new Line(midPoint.copy(), midPoint.copy()
                    .add(direction)));
            }

            newSegments.add(new Line(segment.getStart().copy(), midPoint.copy()));

            newSegments.add(new Line(midPoint.copy(), segment.getEnd()
                .copy()));
        }

        segments = newSegments;

        offset /= 2;
    }

    lightingBoltEffect = new LightingBoltEffect(duration, segments, 2.0f);
}
项目:celestial-pole-motion    文件:Cross.java   
/**
    * Constructs a cross with the center at x,y and a deviation of size
    * @param x - The x of the center
    * @param y - The y of the center
    * @param size
    */
   public Cross(float x, float y, float size) {
l1 = new Line(x - size, y - size, x + size, y + size);
l2 = new Line(x - size, y + size, x + size, y - size);
   }