public CollisionInfo collidesWithPoints(List <Vector2> points) { foreach (Vector2 pos in points) { Vector2 gridPos = MapTools.mapToGridCoords(pos); if (Game1.world.get((int)gridPos.X, (int)gridPos.Y).Type.Collision) { return(new CollisionInfo(true, Vector2.Zero, true)); } else { foreach (CollisionBox box in collisionBoxes) { if (box.collidesWithMovingPoint(pos, Vector2.Zero)) { if (!(box is FreeGravityBox)) { return(new CollisionInfo(true, box.speed)); } return(new CollisionInfo(true, Vector2.Zero)); } } } } return(new CollisionInfo(false, Vector2.Zero)); }
public Rocket(ContentManager content, float x, float y, float width, float height, Vector2 movingDirection) : base(content, x, y, width, height) { textureTest = Game1.cManager.Load <Texture2D>("themes/" + Game1.world.currentTheme + "/items/rocket"); this.travelSpeed = 15f; angle = MapTools.VectorToAngle(movingDirection); particleEmitter = new RoundParticleEmitter(ParticleType.SPARK, new Vector2(0, 0)); particleEmitter.pLifeTime = 100; particleEmitter.pMinLifeTime = 70; particleEmitter.pLoop = false; particleEmitter.pPerUpdate = 100; particleEmitter.pSize = new Vector2(5, 5); particleEmitter.pVelocity = 10; particleEmitter.pMinVelocity = 5; particleEmitter.pIlluminationStrength = 1; particleEmitter.pBounceFactor = 0.5f; particleEmitter.pDampenFactor = 0.97f; particleEmitter.pGravityFactor = 0.3f; smokeEmitter = new ConeParticleEmitter(ParticleType.ENGINE, new Vector2(0, 0), 0, 10); smokeEmitter.pLifeTime = 40; smokeEmitter.pMinLifeTime = 30; smokeEmitter.pLoop = false; smokeEmitter.pPerUpdate = 1; smokeEmitter.pSize = new Vector2(15, 15); smokeEmitter.pVelocity = 7; smokeEmitter.pMinVelocity = 5; smokeEmitter.pIlluminationStrength = 0.0005f; smokeEmitter.pBounceFactor = 0.0f; smokeEmitter.pDampenFactor = 0.97f; smokeEmitter.pGravityFactor = -0.02f; smokeEmitter.start(); oldPos = pos; }
public override void update() { if (activated) { for (int i = 0; i < pPerUpdate; i++) { double coneRadians = (coneRadius * Math.PI) / 180.0; double angle = (random.NextDouble() * coneRadians * 2) + direction - coneRadians; float v = pVelocity; if (pMinVelocity != -1) { v = (float)random.NextDouble() * (pVelocity - pMinVelocity) + pMinVelocity; } int lifeTime = pLifeTime; if (pMinLifeTime != -1) { lifeTime = (int)(random.NextDouble() * (pLifeTime - pMinLifeTime) + pMinLifeTime); } Vector2 velocity = MapTools.AngleToVector((float)angle) * v; Particle particle = new Particle(particleType, pos, pSize, velocity, lifeTime, pLoop, pFrameskip); particle.illuminationStrength = pIlluminationStrength; particle.gravityFactor = pGravityFactor; particle.bounceFactor = pBounceFactor; particle.dampenFactor = pDampenFactor; Game1.world.particles.Add(particle); } } }
public override void Draw(SpriteBatch spriteBatch) { angle = MapTools.VectorToAngle(endPoint - startPoint); startPoint = spawnPos; LineRenderer.DrawLine(spriteBatch, startPoint, endPoint, Color.Black, 3); #pragma warning disable CS0618 // Typ oder Element ist veraltet spriteBatch.Draw( textureTest, //position: spawnPos, destinationRectangle: new Rectangle((int)spawnPos.X, (int)spawnPos.Y, (int)size.X, (int)size.Y + 1 + (int)((pos - spawnPos).Length())), sourceRectangle: new Rectangle(0, 0, (int)(textureTest.Width * 0.51f), textureTest.Height + 1 + (int)((pos - spawnPos).Length() * ((float)textureTest.Height / size.Y))), color: new Color(255, 255, 255, alpha), rotation: angle - (float)(Math.PI * 0.5f), origin: new Vector2(textureTest.Width * 0.25f, 0), scale: new Vector2(2f * (size.X / (float)textureTest.Width), 1f * ((size.Y) / (float)textureTest.Height)), effects: SpriteEffects.FlipVertically, layerDepth: 1f); #pragma warning restore CS0618 // Typ oder Element ist veraltet spriteBatch.Draw( textureTest, position: pos, sourceRectangle: new Rectangle((int)(textureTest.Width * 0.51f), 0, (int)(textureTest.Width * 0.51f), textureTest.Height), color: new Color(255, 255, 255, alpha), rotation: angle - (float)(Math.PI * 0.5f), origin: new Vector2(textureTest.Width * 0.25f, -textureTest.Height * 1f), scale: new Vector2(2f * (size.X / (float)textureTest.Width), 1 * (size.Y / (float)textureTest.Height)), effects: SpriteEffects.None, layerDepth: 1f); }
public void drawIllumination(SpriteBatch spriteBatch) { Vector2 startVec = MapTools.mapToGridCoords(Game1.getCam().Pos); for (int x = (int)startVec.X - 100; x < (int)startVec.X + 100; x++) { for (int y = (int)startVec.Y - 64; y < (int)startVec.Y + 64; y++) { if (x > 0 && y > 0 && x < width && y < height && blocks[x, y] != airDefault) { blocks[x, y].drawIllumination(spriteBatch, x, y); } } } foreach (Item item in items) { item.drawIllumination(spriteBatch); } foreach (Particle particle in particles) { particle.drawIllumination(spriteBatch); } }
public override void Draw(SpriteBatch spriteBatch) { if (sourceRect.Width == 0) { sourceRect = new Rectangle(0, 0, textureTest.Width, textureTest.Height); } angle = MapTools.VectorToAngle(WorldInfo.gravity) - (float)Math.PI * 0.5f; if (Game1.running && collidesWithPoint(Game1.getPlayer().getCenter())) { //Console.WriteLine("hit"); Game1.getPlayer().die(); } spriteBatch.Draw( textureTest, position: pos, sourceRectangle: sourceRect, color: new Color(r, g, b, alpha), rotation: angle, origin: new Vector2(sourceRect.Width * 0.5f, sourceRect.Width * 0.5f), scale: new Vector2(1 * (size.X / (float)sourceRect.Width), 1 * (size.Y / (float)sourceRect.Height)), effects: SpriteEffects.None, layerDepth: 1); //LineRenderer.DrawLine(spriteBatch, pos, pos - new Vector2(size.X, size.X) * 0.5f, Color.Red, 3f); }
public override void Draw(SpriteBatch spriteBatch) { frame++; sourceRect = animation.getSourceRectange(); animation.update(); this.angle = (float)(Math.Sin(frame * 0.1f) * 0.1f) + MapTools.VectorToAngle(WorldInfo.gravity) - 3.1415f * 0.5f; base.Draw(spriteBatch); }
public override bool CollidesWithPlayer() { return((MapTools.distanceOfVecs(Game1.getPlayer().getCenter(), getCenter()) < size.X * 0.5f || MapTools.distanceOfVecs(Game1.getPlayer().downPoint(), getCenter()) < size.X * 0.5f) || MapTools.distanceOfVecs(Game1.getPlayer().upPoint(), getCenter()) < size.X * 0.5f || MapTools.distanceOfVecs(Game1.getPlayer().leftPoints()[0], getCenter()) < size.X * 0.5f || MapTools.distanceOfVecs(Game1.getPlayer().rightPoints()[0], getCenter()) < size.X * 0.5f ); }
public List <Vector2> leftPoints() { List <Vector2> points = new List <Vector2>(); points.Add(getCenter() - (new Vector2(MapTools.getXMultiplier(), MapTools.getYMultiplier())) * size.X * 0.51f); points.Add(getCenter() - (new Vector2(MapTools.getXMultiplier(), MapTools.getYMultiplier())) * size.X * 0.51f + WorldInfo.gravity * size.Y * 0.4f); points.Add(getCenter() - (new Vector2(MapTools.getXMultiplier(), MapTools.getYMultiplier())) * size.X * 0.51f - WorldInfo.gravity * size.Y * 0.4f); return(points); }
public List <Vector2> upPoints() { List <Vector2> points = new List <Vector2>(); points.Add(getCenter() - WorldInfo.gravity * size.Y * 0.51f); points.Add(getCenter() - WorldInfo.gravity * size.Y * 0.51f + MapTools.getMultiplierVec() * size.X * 0.4f); points.Add(getCenter() - WorldInfo.gravity * size.Y * 0.51f - MapTools.getMultiplierVec() * size.X * 0.4f); return(points); }
public bool[,] getBlockSetArray() { bool[,] setArray = new bool[2, 2]; setArray[0, 0] = Game1.world.get((int)MapTools.mapToGridCoords(getCenter() + new Vector2(-1, -1)).X, (int)MapTools.mapToGridCoords(getCenter() + new Vector2(-1, -1)).Y).Type != BlockType.AIR; setArray[0, 1] = Game1.world.get((int)MapTools.mapToGridCoords(getCenter() + new Vector2(-1, +1)).X, (int)MapTools.mapToGridCoords(getCenter() + new Vector2(-1, +1)).Y).Type != BlockType.AIR; setArray[1, 0] = Game1.world.get((int)MapTools.mapToGridCoords(getCenter() + new Vector2(+1, -1)).X, (int)MapTools.mapToGridCoords(getCenter() + new Vector2(+1, -1)).Y).Type != BlockType.AIR; setArray[1, 1] = Game1.world.get((int)MapTools.mapToGridCoords(getCenter() + new Vector2(+1, +1)).X, (int)MapTools.mapToGridCoords(getCenter() + new Vector2(+1, +1)).Y).Type != BlockType.AIR; return(setArray); }
public bool beamCollidesWithPlayer() { Player player = Game1.getPlayer(); return(MapTools.PointCollidesWithRect(player.getCenter(), getUpLeftBeamPoint(), getDownRightBeamPoint()) || MapTools.PointCollidesWithRect(player.leftPoints()[0], getUpLeftBeamPoint(), getDownRightBeamPoint()) || MapTools.PointCollidesWithRect(player.rightPoints()[0], getUpLeftBeamPoint(), getDownRightBeamPoint())); }
public override void Update() { angle = MapTools.VectorToAngle(Game1.getPlayer().getCenter() - getCenter()); if (frames % 120 == 119) { Game1.world.addItem(new Rocket(content, pos.X, pos.Y, size.X, size.Y * 0.5f, Game1.getPlayer().getCenter() - getCenter())); frames = 0; } frames++; base.Update(); }
public void Draw(SpriteBatch spriteBatch) { rect.X = (int)(Math.Round(pos.X)); rect.Y = (int)(Math.Round(pos.Y)); SpriteEffects effect; if (flipped) { effect = SpriteEffects.FlipHorizontally; } else { effect = SpriteEffects.None; } sourceRectange = animation.getSourceRectange(); spriteBatch.Draw( textureTest, position: pos, sourceRectangle: sourceRectange, color: Color.White, rotation: MapTools.VectorToAngle(WorldInfo.gravity) - (float)Math.PI * 0.5f, origin: new Vector2((float)sourceRectange.Width * 0.501f, (float)sourceRectange.Height * 0.501f), scale: 1, effects: effect, layerDepth: 1); int flameId = 0; foreach (GravityFlame flame in flames) { flame.draw(spriteBatch); flameId++; } int playerPosID = 30; if (!Game1.running && showPlayerPositions) { foreach (PlayerPositionShow pl in playerPositions) { pl.Draw(spriteBatch, playerPosID); playerPosID--; } } }
public override void Update() { angle += angleSpeed * 0.001f; raycast.dir = MapTools.AngleToVector(angle - MathHelper.Pi * 0.5f); raycast.pos = pos + raycast.dir * 10; hitOfRaycast = raycast.getHit(); if (hitOfRaycast.obj is Player) { Game1.getPlayer().die(); } // Game1.world.particles.Add(new Particle(hitOfRaycast.pos.X - raycast.dir.X * 5, hitOfRaycast.pos.Y - raycast.dir.Y * 5, 5, 5, new Vector2(((float)new Random().NextDouble() - 0.5f) * 20.0f, ((float)new Random().NextDouble() - 0.5f) * 20.0f))); particleEmitter.pos.X = hitOfRaycast.pos.X; particleEmitter.pos.Y = hitOfRaycast.pos.Y; particleEmitter.Direction = angle - Math.PI * (0.5f - Math.Sign(angleSpeed) * 0.2f) + Math.PI; particleEmitter.update(); base.Update(); }
public CollisionInfo collidesUp() { Vector2 pos = MapTools.mapToGridCoords(upPoint()); if (Game1.world.get((int)pos.X, (int)pos.Y).Type.Collision) { return(new CollisionInfo(true, Vector2.Zero)); } else { foreach (CollisionBox box in Game1.world.collisionBoxes) { if (collidesUpWithCollisionBox(box)) { return(new CollisionInfo(true, box.speed)); } } } return(new CollisionInfo(false, Vector2.Zero)); }
public void update(float delta) { collisionInfoDownBeginOfFrame = isGrounded(); applySpeed(); applyFallSpeed(delta); Vector2 gridCoords = MapTools.mapToGridCoords(getCenter()); if (Game1.world.get((int)gridCoords.X, (int)gridCoords.Y).Type.Killing) { die(); } animation.update(); int flameId = 0; foreach (GravityFlame flame in flames) { flame.update(flameId); flameId++; } }
public virtual CollisionInfo collidesWithMap() { Vector2 pos = MapTools.mapToGridCoords(getCenter()); if (Game1.world.get((int)pos.X, (int)pos.Y).Type.Collision) { return(new CollisionInfo(true, Vector2.Zero)); } else { foreach (CollisionBox box in Game1.world.collisionBoxes) { if (collidesWithCollisionBox(box)) { return(new CollisionInfo(true, speed));; } } } return(new CollisionInfo(false, Vector2.Zero)); }
public void applySpeed() { Vector2 speedVec = new Vector2((float)((speed) * Math.Round(MapTools.getXMultiplier())), (float)((speed) * Math.Round(MapTools.getYMultiplier()))); if ((speed > 0 && !collidesRight(false))) { raycast = new Raycast(rightPoints()[0], MapTools.getMultiplierVec() + new Vector2(0.0000001f, 0.0000001f), 1000, true); CollisionInfo hit = raycast.getHit(); if ((hit.pos - rightPoints()[0]).Length() < speedVec.Length()) { speedVec = hit.pos + MapTools.getMultiplierVec() * 0.1f - rightPoints()[0]; } pos += speedVec; } else if ((speed < 0 && !collidesLeft(false))) { raycast = new Raycast(leftPoints()[0], -MapTools.getMultiplierVec() + new Vector2(0.0000001f, 0.0000001f), 1000, true); CollisionInfo hit = raycast.getHit(); if ((hit.pos - leftPoints()[0]).Length() < speedVec.Length()) { speedVec = hit.pos - MapTools.getMultiplierVec() * 0.1f - leftPoints()[0]; } pos += speedVec; } else { speed = 0; } if ((collisionInfoDownBeginOfFrame.getRealSpeed() > 0 && !collidesRight(false)) || (collisionInfoDownBeginOfFrame.getRealSpeed() < 0 && !collidesLeft(false))) { pos.X += (float)((collisionInfoDownBeginOfFrame.getRealSpeed()) * Math.Round(MapTools.getXMultiplier())); pos.Y += (float)((collisionInfoDownBeginOfFrame.getRealSpeed()) * Math.Round(MapTools.getYMultiplier())); } rect.X = (int)pos.X; rect.Y = (int)pos.Y; }
public void Draw(SpriteBatch spriteBatch) { if (Keyboard.GetState().IsKeyDown(Keys.L)) { Game1.getCam().TargetZoom = 4f; } if (Keyboard.GetState().IsKeyDown(Keys.K)) { Game1.getCam().TargetZoom = 2f; } if (Keyboard.GetState().IsKeyDown(Keys.J)) { Game1.getCam().TargetZoom = 1f; } Vector2 startVec = MapTools.mapToGridCoords(Game1.getCam().Pos); for (int x = (int)startVec.X - 100; x < (int)startVec.X + 100; x++) { for (int y = (int)startVec.Y - 64; y < (int)startVec.Y + 64; y++) { if (x > 0 && y > 0 && x < width && y < height && blocks[x, y] != airDefault) { blocks[x, y].draw(spriteBatch, x, y); } } } foreach (Item item in items) { item.Draw(spriteBatch); } foreach (Particle particle in particles) { particle.draw(spriteBatch); } }
public CollisionInfo isGrounded() { Vector2 pos = MapTools.mapToGridCoords(downPoint() + WorldInfo.gravity * 0.1f); if (Game1.world.get((int)pos.X, (int)pos.Y).Type.Collision) { if (Game1.world.get((int)pos.X, (int)pos.Y).Type == BlockType.ICE) { return(new CollisionInfo(true, Vector2.Zero, BlockType.ICE, pos)); } return(new CollisionInfo(true, Vector2.Zero)); } else { foreach (CollisionBox box in Game1.world.collisionBoxes) { if (collidesDownWithCollisionBox(box)) { return(new CollisionInfo(true, box.speed));; } } } return(new CollisionInfo(false, Vector2.Zero)); }
public Boolean collidesLeft(bool withFreeGravityBox) { Vector2 pos; List <Vector2> points = leftPoints(); foreach (Vector2 point in points) { pos = MapTools.mapToGridCoords(point); if (Game1.world.get((int)pos.X, (int)pos.Y).Type.Collision) { return(true); } } foreach (CollisionBox box in Game1.world.collisionBoxes) { if (!(box is FreeGravityBox && !withFreeGravityBox) && collidesLeftWithCollisionBox(box)) { return(true); } } return(false); }
public ConeParticleEmitter(ParticleType particleType, Vector2 pos, Vector2 direction, float coneRadius) : base(particleType, pos) { this.direction = MapTools.VectorToAngle(direction); this.coneRadius = coneRadius; }
public CollisionInfo setLine(Vector2 pos, Vector2 dir, float length) { int x = (int)MapTools.mapToGridCoords(pos).X; int y = (int)MapTools.mapToGridCoords(pos).Y; int stepX = 1; int stepY = 1; if (dir.X < 0) { stepX = -1; } if (dir.Y < 0) { stepY = -1; } float tMaxXVal = pos.X % 16; float tMaxYVal = pos.Y % 16; if (stepX == 1) { tMaxXVal = 16f - tMaxXVal; } if (stepY == 1) { tMaxYVal = 16f - tMaxYVal; } float tMaxX = tMaxXVal / dir.X * stepX; float tMaxY = tMaxYVal / dir.Y * stepY; float tDeltaX = 16f / dir.X * stepX; float tDeltaY = 16f / dir.Y * stepY; while (true) { bool delX = false; if (tMaxX < tMaxY) { tMaxX = tMaxX + tDeltaX; x = x + stepX; delX = true; } else { tMaxY = tMaxY + tDeltaY; y = y + stepY; delX = false; } if (x < 0 || y < 0 || x >= Game1.world.width || y >= Game1.world.height) { break; } if (Game1.world.blocks[x, y].Type.Collision) { float min; if (delX) { min = Math.Min(tMaxX - tDeltaX, tMaxY); } else { min = Math.Min(tMaxX, tMaxY - tDeltaY); } Vector2 hitPos = pos + min * dir; //hitPos = new Vector2((hitPos.X - hitPos.X % 16) + hitPos.Y % 16, (hitPos.Y - hitPos.Y % 16) + hitPos.X % 16); return(new CollisionInfo(true, Vector2.Zero, null, hitPos)); } } return(new CollisionInfo(false, Vector2.Zero, null, dir * length)); }
public CollisionInfo getHit() { Vector2 res = new Vector2(pos.X, pos.Y); List <CollisionInfo> collisionInfos = new List <CollisionInfo>(); dir.Normalize(); Vector2 posOnGrid = MapTools.mapToGridCoords(pos); Vector2 endPointOnGrid = MapTools.mapToGridCoords(pos) + dir * length / 16f; CollisionInfo raytraversalInfo = setLine(pos, dir, length); if (raytraversalInfo.collided) { collisionInfos.Add(new CollisionInfo(true, Vector2.Zero, null, raytraversalInfo.pos)); } Player player = Game1.getPlayer(); if (!ignorePlayer && MapTools.lineCollidesWithRect(pos, pos + dir * length, player.pos - player.size * 0.5f, player.size.X, player.size.Y).collided) { res = MapTools.lineCollidesWithRect(pos, pos + dir * length, player.pos - player.size * 0.5f, player.size.X, player.size.Y).pos; collisionInfos.Add(new CollisionInfo(true, Vector2.Zero, player, res)); } foreach (CollisionBox box in Game1.world.collisionBoxes) { if (box.active) { if (MapTools.lineCollidesWithRect(pos, pos + dir * length, box.pos - box.size * 0.5f, box.size.X, box.size.Y).collided) { res = MapTools.lineCollidesWithRect(pos, pos + dir * length, box.pos - box.size * 0.5f, box.size.X, box.size.Y).pos; collisionInfos.Add(new CollisionInfo(true, Vector2.Zero, box, res)); } } } if (collisionInfos.Count == 0) { return(new CollisionInfo(true, Vector2.Zero, null, pos + dir * length)); } while (collisionInfos.Count > 1) { if ((pos - collisionInfos[0].pos).LengthSquared() > (pos - collisionInfos[1].pos).LengthSquared()) { collisionInfos.RemoveAt(0); } else { collisionInfos.RemoveAt(1); } } return(collisionInfos[0]); /* * while (!Game1.world.collidesWithPoint(res).collided && !Game1.getPlayer().collidesWithMovingPoint(res, Vector2.Zero)) * { * res += dir; * if ((pos - res).Length() > length) * break; * } * * * * if (Game1.getPlayer().collidesWithMovingPoint(res, Vector2.Zero)) * return new CollisionInfo(true, Vector2.Zero, Game1.getPlayer(), res);*/ }
public void drawOutlines(SpriteBatch batch) { rect.X = (int)(pos.X + offset.X); rect.Y = (int)(pos.Y + offset.Y); rect.Width = (int)size.X; rect.Height = (int)size.Y; SpriteEffects effect; if (flipped) { effect = SpriteEffects.FlipHorizontally; } else { effect = SpriteEffects.None; } batch.Draw(textureTest, position: pos + offset + new Vector2(1f / Game1.getCam().Zoom, 0), scale: new Vector2(1, 1), color: Color.Black, rotation: MapTools.VectorToAngle(WorldInfo.gravity) - (float)Math.PI * 0.5f, origin: new Vector2(textureTest.Width * 0.5f, textureTest.Height * 0.5f), effects: effect); batch.Draw(textureTest, position: pos + offset + new Vector2(0, 1f / Game1.getCam().Zoom), scale: new Vector2(1, 1), color: Color.Black, rotation: MapTools.VectorToAngle(WorldInfo.gravity) - (float)Math.PI * 0.5f, origin: new Vector2(textureTest.Width * 0.5f, textureTest.Height * 0.5f), effects: effect); batch.Draw(textureTest, position: pos + offset + new Vector2(-1f / Game1.getCam().Zoom, 0), scale: new Vector2(1, 1), color: Color.Black, rotation: MapTools.VectorToAngle(WorldInfo.gravity) - (float)Math.PI * 0.5f, origin: new Vector2(textureTest.Width * 0.5f, textureTest.Height * 0.5f), effects: effect); batch.Draw(textureTest, position: pos + offset + new Vector2(0, -1f / Game1.getCam().Zoom), scale: new Vector2(1, 1), color: Color.Black, rotation: MapTools.VectorToAngle(WorldInfo.gravity) - (float)Math.PI * 0.5f, origin: new Vector2(textureTest.Width * 0.5f, textureTest.Height * 0.5f), effects: effect); }
public Vector2 getDownRightBeamPoint() { return(getCenter() + new Vector2(MapTools.getXMultiplier() * size.X * 0.5f, MapTools.getYMultiplier() * size.Y * 0.5f) + WorldInfo.gravity * length); }
public Vector2 getUpLeftBeamPoint() { return(getCenter() - new Vector2(MapTools.getXMultiplier() * size.X * 0.5f, MapTools.getYMultiplier() * size.Y * 0.5f)); }
public override void Update() { speed *= 1.0125f; Vector2 playerPos = Game1.getPlayer().getCenter(); speed.Normalize(); Vector2 pointRotatedUp = getCenter() + Vector2.Transform(speed, Matrix.CreateRotationZ(0.1f)); Vector2 pointRotatedDown = getCenter() + Vector2.Transform(speed, Matrix.CreateRotationZ(-0.1f)); if ((playerPos - pointRotatedUp).Length() < (playerPos - pointRotatedDown).Length()) { if (angleSpeed < 0) { angleSpeed = 0; } angleSpeed += 0.001f; } if ((playerPos - pointRotatedUp).Length() > (playerPos - pointRotatedDown).Length()) { if (angleSpeed > 0) { angleSpeed = 0; } angleSpeed -= 0.001f; } angle += angleSpeed; speed = MapTools.AngleToVector(angle); speed *= travelSpeed; if (collidesWithMap().collided) { destroy = true; Light light = new PointLight { Position = new Vector2(getCenter().X, getCenter().Y) - speed, Scale = new Vector2(500), // Range of the light source (how far the light will travel) Radius = 1f, Intensity = 1f, Color = new Color(1f, 0.5f, 0, 1), CastsShadows = false, ShadowType = ShadowType.Illuminated // Will not lit hulls themselves }; ExplosionHandler.addExplosion(light); } if (CollidesWithPlayer()) { Game1.getPlayer().die(); Light light = new PointLight { Position = new Vector2(getCenter().X, getCenter().Y) - speed, Scale = new Vector2(1500), // Range of the light source (how far the light will travel) Radius = 1f, Intensity = 1f, Color = new Color(5f, 0.5f, 0, 1), ShadowType = ShadowType.Solid // Will not lit hulls themselves }; ExplosionHandler.addExplosion(light); } smokeEmitter.pos = oldPos; smokeEmitter.Direction = angle + Math.PI; smokeEmitter.update(); if (destroy == true) { particleEmitter.pos = oldPos; particleEmitter.start(); particleEmitter.update(); } oldPos = pos; base.Update(); }
public Vector2 getMovingVector() { return(new Vector2((int)(speed * MapTools.getXMultiplier()) + (int)(fallSpeed * (float)(WorldInfo.gravity.X)), (int)(speed * MapTools.getYMultiplier()) + (int)(fallSpeed * (float)(WorldInfo.gravity.Y)))); }