/** * @param x1 #start * @param y1 #start * @param x2 #end * @param y2 #end * @param numParticles #density */ public void MakeFrontFire(int x1, int y1, int x2, int y2, int numParticles) { final Timeline fronttimeline = new Timeline(); y2 = (int) (y2 - ((y2 - y1) * .8)); for (int i = 0; i < numParticles; i++) { int size = CoreMath.rand(15, 20); int duration = (100 - size) * 10; int moveDistance = CoreMath.rand(1, 4 * size); double moveDirection = 180; // CoreMath.rand(0,5); int startX = x1 + i * (x2 - x1) / numParticles; int startY = y1 + i * (y2 - y1) / numParticles; int goalX = startX + (int) (moveDistance * Math.cos(moveDirection)); int goalY = startY + (int) (moveDistance * Math.sin(moveDirection)); CoreImage image = flame[CoreMath.rand(flame.length - 1)]; Sprite sprite = new ImageSprite(image, startX, startY); sprite.setAnchor(.5, .5); sprite.setSize(size * 6, size * 2); sprite.alpha.set(50); scene.add(sprite); fronttimeline.animate( sprite.height, sprite.height.get(), sprite.width.get(), duration, Easing.REGULAR_OUT); fronttimeline.animateTo(sprite.x, goalX, duration, Easing.REGULAR_OUT); fronttimeline.animateTo(sprite.y, goalY, duration, Easing.REGULAR_OUT); fronttimeline.at(100).animateTo(sprite.alpha, 0, duration - 100, Easing.REGULAR_OUT); fronttimeline.add(new RemoveSpriteEvent(scene.getMainLayer(), sprite, duration)); } scene.addTimeline(fronttimeline); }
public Centipede(Player p, Level l, int x, int y) { super(p, l, "enemy_centipede.png", x, y); speed = CoreMath.rand(0.8, 1.4) + (p.getLevelNumber() / 7); health = p.getLevelNumber() + CoreMath.rand(2.0, 5.0); points = (int) health; int size = CoreMath.rand(20, 30); setSize(size, size); }
public void load() { setCursor(Input.CURSOR_OFF); cursor = new ImageSprite("glow.png", 0, 0); cursor.setAnchor(0.5, 0.5); cursor.visible.set(false); // Create the mask maskLayer = new Group(); maskLayer.add(new FilledSprite(gray(18))); maskLayer.add(cursor); maskLayer.setBlendMode(BlendMode.Multiply()); maskLayer.createBackBuffer(); // Create the background image Timeline t = new Timeline(); Group imageLayer = new Group(); imageLayer.add(new FilledSprite(rgb(0xba9b65))); int size = 80; int spacing = 16; for (int i = -spacing / 2; i < Stage.getWidth(); i += spacing + size) { for (int j = -spacing / 2; j < Stage.getHeight(); j += spacing + size) { int color1 = colors[CoreMath.rand(colors.length - 1)]; int color2 = colors[CoreMath.rand(colors.length - 1)]; FilledSprite sprite = new FilledSprite(i, j, size, size, color1); imageLayer.add(sprite); int delay1 = CoreMath.rand(20000); int delay2 = delay1 + CoreMath.rand(20000); t.set(sprite.fillColor, color2, delay1); t.set(sprite.fillColor, color1, delay2); } } t.loopForever(); addTimeline(t); // Add the layers to the scene addLayer(imageLayer); addLayer(maskLayer); }
/** * @param x1 #start * @param y1 #start * @param x2 #end * @param y2 #end */ public void MakeFire(int x1, int y1, int x2, int y2) { final Timeline backtimeline = new Timeline(); for (int i = 0; i < 1; i++) { int size = CoreMath.rand(25, 50); int duration = (100 - size) * 10; if (duration < 0) { duration = 10; } int moveDistance = CoreMath.rand(70, 150 - size); double moveDirection = 180; // CoreMath.rand(0); int startX = x1 + i * (x2 - x1); int startY = y1 + i * (y2 - y1); int goalX = startX + (int) (moveDistance * Math.cos(moveDirection)); int goalY = startY + (int) (moveDistance * Math.sin(moveDirection)); CoreImage image = flame[CoreMath.rand(flame.length - 1)]; Sprite sprite = new ImageSprite(image, startX, startY); sprite.setAnchor(.5, .5); sprite.setSize(size, size); scene.add(sprite); scene.getMainLayer().moveToBottom(sprite); scene.getMainLayer().moveUp(sprite); backtimeline.animateTo(sprite.x, goalX, duration, Easing.REGULAR_OUT); backtimeline.animateTo(sprite.y, goalY, duration, Easing.REGULAR_OUT); backtimeline.at(100).animateTo(sprite.alpha, 0, duration - 100, Easing.REGULAR_OUT); backtimeline.add(new RemoveSpriteEvent(scene.getMainLayer(), sprite, duration)); } scene.addTimeline(backtimeline); MakeFrontFire(x1, y1, x2, y2, 1); }