List of usage examples for com.google.gwt.maeglin89273.game.mengine.physics Vector Vector
public Vector(double x, double y)
From source file:com.google.gwt.maeglin89273.shared.test.volcanogame.component.FireBall.java
public FireBall(Spacial space, Point p, int radius) { super(new Point(p.getX(), p.getY() - radius), radius * 2, radius * 2); this.radius = radius; double h = 5 + Random.nextInt(21); double s = 80 + Random.nextInt(21); double l = 35 + Random.nextInt(16); ballColor = CssColor.make("hsl(" + h + "," + s + "%," + l + "%)"); ballShadowColor = CssColor.make("hsl(" + h + "," + s + "%," + (l + 15) + "%)"); this.space = space; aabb = new PixelAABB(this.position, width, height); BodyDef bodyDef = new BodyDef(); CircleShape shape = new CircleShape(); FixtureDef fixtureDef = new FixtureDef(); Vec2 impulse = CoordinateConverter/*ww w .ja v a 2 s.co m*/ .vectorPixelsToWorld(new Vector(-30 + 60 * Random.nextDouble(), -(175 + 50 * Random.nextDouble()))); bodyDef.type = BodyType.DYNAMIC; bodyDef.position.set(CoordinateConverter.coordPixelsToWorld(position)); body = space.getWorld().createBody(bodyDef); body.setLinearVelocity(impulse); body.applyLinearImpulse(impulse, body.getPosition()); shape.m_radius = CoordinateConverter.scalerPixelsToWorld(radius); fixtureDef.shape = shape; fixtureDef.density = 4.3f; fixtureDef.restitution = 0.2f; fixtureDef.friction = 0.8f; body.createFixture(fixtureDef); }
From source file:com.google.gwt.maeglin89273.shared.test.volcanogame.component.Volcano.java
public Volcano(Spacial space, Point p) { super(p, 500, 150); this.space = space; this.image = MEngine.getAssetManager().getSpriteSheet("volcano.png"); BodyDef bodyDef = new BodyDef(); bodyDef.position.set(CoordinateConverter.coordPixelsToWorld(p)); PolygonShape shape = new PolygonShape(); Vec2[] vertices = { CoordinateConverter.vectorPixelsToWorld(new Vector(-250, 75)), CoordinateConverter.vectorPixelsToWorld(new Vector(250, 75)), CoordinateConverter.vectorPixelsToWorld(new Vector(CRATER_WIDTH / 2, -75)), CoordinateConverter.vectorPixelsToWorld(new Vector(-CRATER_WIDTH / 2, -75)), };/* w w w.j a v a 2s.c o m*/ body = space.getWorld().createBody(bodyDef); shape.set(vertices, vertices.length); aabb = CoordinateConverter.transformAABB(body.createFixture(shape, 0f).getAABB()); }