本文整理汇总了Java中org.newdawn.slick.geom.Line类的典型用法代码示例。如果您正苦于以下问题:Java Line类的具体用法?Java Line怎么用?Java Line使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Line类属于org.newdawn.slick.geom包,在下文中一共展示了Line类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LinearGradientFill
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
/**
* 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);
}
示例2: getCollisionPoints
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
/**
* 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;
}
示例3: getCollisionPoint
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
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;
}
示例4: render
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
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 *****/
}
示例5: checkCollision
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
@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;
}
示例6: LightingBoltEffect
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
public LightingBoltEffect(
int time,
Collection < Line > segments,
float lineWidth) {
this.totalTime = time;
this.segments = segments;
this.currentTime = time;
this.lineWidth = lineWidth;
}
示例7: FowToPolygonThread
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
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;
}
示例8: getCollisionLines
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
@Override
public ArrayList<Line> getCollisionLines() {
return collisionLines;
}
示例9: add
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
public synchronized void add(ArrayList<Line> al) {
for (int i = 0; i < al.size(); i++) {
ret.add(al.get(i));
}
}
示例10: getDetectionLine
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
public Line getDetectionLine() {
return detectionLine;
}
示例11: setDetectionLine
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
public void setDetectionLine(Line detectionLine) {
this.detectionLine = detectionLine;
}
示例12: getCollisionLines
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
/**
* @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;
}
示例13: generateLightingBolt
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
/**
* 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);
}
示例14: Cross
import org.newdawn.slick.geom.Line; //导入依赖的package包/类
/**
* 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);
}