protected void generateEffect(Vector2 loc, Texture2D tex) { Random r = new Random(); int numOfP = r.Next(160) + 40; for (int j = 0; j < numOfP; j++) { ParticleObject particle; particle = new ParticleObject(tex); particle.setLocation(new Vector2(loc.X, loc.Y)); int x = r.Next(78); double realX = (float)((x * .12)); int y = r.Next(78); double realY = (float)((y * .12)); double maxDist = 90;// (.01 * r.Next(400)) + 40; Boolean create = false; if (realX * realX + realY * realY < maxDist) { create = true; } int isNeg = r.Next(2); if (isNeg == 0) { realX *= -1; } int isNeg2 = r.Next(2); if (isNeg2 == 0) { realY *= -1; } particle.direction = (new Vector2((float)realX, (float)realY)); particle.rotation = (float)Math.Atan2(realY, realX) - (float)(Math.PI / 2); if (create) { particleList.Add(particle); } } }
protected void updateParticles() { for (int i = 0; i < particleList.Count; i++) { ParticleObject p = (ParticleObject)particleList[i]; float x = p.getLocation().X + p.direction.X - shipSpeed.X / 2; float y = p.getLocation().Y + p.direction.Y - shipSpeed.Y / 2; /*if (x < leftSideLoc.X) * { * p.setDirection(new Vector2(p.getDirection().X * -1, p.getDirection().Y)); * x = leftSideLoc.X + 3; * } * if (x > rightSideLoc.X) * { * p.setDirection(new Vector2(p.getDirection().X * -1, p.getDirection().Y)); * x = rightSideLoc.X - 1; * } * if (y < topSideLoc.Y) * { * p.setDirection(new Vector2(p.getDirection().X, p.getDirection().Y * -1)); * y = topSideLoc.Y + 3; * } * if (y > bottomSideLoc.Y) * { * p.setDirection(new Vector2(p.getDirection().X, p.getDirection().Y * -1)); * y = bottomSideLoc.Y - 1; * }*/ p.updateSpeed(); p.setLocation(new Vector2(x, y)); int life = p.getLifeSpan(); if (p.getLifeSpan() < 0) { particleList.RemoveAt(i); } } }
protected void generateEffect(Vector2 loc, Texture2D tex) { Random r = new Random(); int numOfP = r.Next(120) + 40; int rColor = 0; int gColor = 0; int bColor = 0; if (particleColor == 1) //Green { rColor = (byte)57; gColor = (byte)255; bColor = (byte)20; } if (particleColor == 2) //lightBlue { rColor = (byte)0; gColor = (byte)191; bColor = (byte)255; } if (particleColor == 3) //blue { rColor = (byte)103; gColor = (byte)200; bColor = (byte)255; } if (particleColor == 4) //purple { rColor = (byte)153; gColor = (byte)60; bColor = (byte)243; } if (particleColor == 5) //pink { rColor = (byte)255; gColor = (byte)0; bColor = (byte)255; } if (particleColor == 6) //red { rColor = (byte)254; gColor = (byte)0; bColor = (byte)1; } if (particleColor == 7) //orange { rColor = (byte)255; gColor = (byte)65; bColor = (byte)5; } if (particleColor == 8) //yellow { rColor = (byte)255; gColor = (byte)255; bColor = (byte)0; } for (int j = 0; j < numOfP; j++) { ParticleObject particle; particle = new ParticleObject(tex); particle.setLocation(new Vector2(loc.X, loc.Y)); particle.rColor = (byte)rColor; particle.gColor = (byte)gColor; particle.bColor = (byte)bColor; int x = r.Next(78); double realX = (float)((x * .12)); int y = r.Next(78); double realY = (float)((y * .12)); double maxDist = 90;// (.01 * r.Next(400)) + 40; Boolean create = false; if (realX * realX + realY * realY < maxDist) { create = true; } int isNeg = r.Next(2); if (isNeg == 0) { realX *= -1; } int isNeg2 = r.Next(2); if (isNeg2 == 0) { realY *= -1; } particle.direction = (new Vector2((float)realX * 2, (float)realY * 2)); particle.rotation = (float)Math.Atan2(realY, realX) - (float)(Math.PI / 2); if (create) { particleList.Add(particle); } } }