public RequestImplementation(IPlayerController controller, GameState game,
                              IBody body, Direction2 direction)
     : base(RequestType.ShootDebugParticleFromPlanet, game, controller)
 {
     this.body      = body;
     this.direction = direction;
 }
Example #2
0
        public void Move()
        {
            if (k2 == 4 && d1 == Direction1.up)
            {
                d1 = Direction1.down;
            }
            else
            if (k2 == 4 && d1 == Direction1.down)
            {
                d1 = Direction1.up;
            }

            if (k2 == 8)
            {
                if (d2 == Direction2.right)
                {
                    d2 = Direction2.left;
                }
                else
                {
                    d2 = Direction2.right;
                }
                k2 = 0;
            }
            k2++;
        }
Example #3
0
 public HitResult(Position2 point, Direction2 normal, float rayFactor, bool fromInside)
 {
     this.Point      = point;
     this.Normal     = normal;
     this.RayFactor  = rayFactor;
     this.FromInside = fromInside;
 }
        /// <summary>
        /// Splash a bunch of trees down near (xloc, yloc).
        ///
        /// Amount of trees is controlled by terrainTreeLevel.
        /// </summary>
        /// <remarks>Trees are not smoothed.</remarks>
        /// <param name="xloc">Horizontal position of starting point for splashing trees.</param>
        /// <param name="yloc">Vertical position of starting point for splashing trees.</param>
        private void treeSplash(short xloc, short yloc)
        {
            short numTrees;

            if (terrainTreeLevel < 0)
            {
                numTrees = (short)(getRandom(150) + 50);
            }
            else
            {
                numTrees = (short)(getRandom((short)(100 + (terrainTreeLevel * 2))) + 50);
            }

            Position treePos = new Position(xloc, yloc);

            while (numTrees > 0)
            {
                Direction2 dir = (Direction2)(Direction2.DIR2_NORTH + getRandom(7));
                treePos.move(dir);

                if (!treePos.testBounds())
                {
                    return;
                }

                if ((map[treePos.posX, treePos.posY] & (ushort)MapTileBits.LOMASK) == (ushort)MapTileCharacters.DIRT)
                {
                    map[treePos.posX, treePos.posY] = (ushort)MapTileCharacters.WOODS | (ushort)MapTileBits.BLBNBIT;
                }

                numTrees--;
            }
        }
Example #5
0
 public HitResult(Position2 point, Direction2 normal, float rayFactor, bool fromInside)
 {
     this.Point = point;
     this.Normal = normal;
     this.RayFactor = rayFactor;
     this.FromInside = fromInside;
 }
Example #6
0
        public static List <Vector2> GetWirePointPositions(Vector2 start, Vector2 end, bool clamp = true, bool straight = false)
        {
            List <Vector2> points = new List <Vector2>();

            if (straight)
            {
                points.Add(start);
                Direction2 cardinal = start.CardinalTo(end);
                points.Add(cardinal.GetAxis() == Axis.X ? new Vector2(end.X, start.Y) : new Vector2(start.X, end.Y));
            }
            else if (clamp)
            {
                return(GetWirePointPositions(ClampWire(start), ClampWire(end), false));
            }
            else
            {
                // Direction2 cardinal = start.CardinalTo(end);
                // int dx = Math.Abs(cardinal.Offset().X);
                // int dy = Math.Abs(cardinal.Offset().Y);

                // float mx = (1 - dx) * start.X + dx * end.X;
                // float my = (1 - dy) * start.Y + dy * end.Y;

                points.Add(start);
                points.Add(new Vector2(start.X, end.Y));
                points.Add(end);
            }

            return(points);
        }
Example #7
0
 public Snake(int x, int y)
 {
     this.x = x;
     this.y = y;
     d1     = Direction1.up;
     d2     = Direction2.right;
 }
Example #8
0
 public RequestImplementation(IPlayerController controller, GameState game,
                              IBody body, Direction2 direction)
     : base(RequestType.ShootProjectileFromPlanet, game, controller)
 {
     this.body        = body;
     this.direction   = direction;
     this.validPlayer = true;
 }
Example #9
0
        public static Direction2 MoveCoin()
        {
            Array values = Enum.GetValues(typeof(Direction2));

            Random     random    = new Random();
            Direction2 randomBar = (Direction2)values.GetValue(random.Next(values.Length));

            return(randomBar);
        }
Example #10
0
 public Projectile(GameState game, Ship owner, Vector2 position,
     Vector2 baseVelocity, Direction2 direction, float speed, float lifeTime)
     : base(game)
 {
     this.owner = owner;
     this.position = position;
     this.velocity = baseVelocity + direction.Vector * speed;
     this.deathTime = game.TimeF + lifeTime;
 }
            public RequestImplementation(PlayerConnectionLookup connectionLookup, NetConnection connection,
                                         NetBuffer buffer, GameState game)
                : base(RequestType.ShootDebugParticleFromPlanet, game, connectionLookup, connection)
            {
                var p = buffer.Read <RequestParameters>();

                this.body      = game.Bodies[p.BodyId];
                this.direction = p.Direction;
            }
Example #12
0
        /// <summary>
        /// Creates a new polar position.
        /// </summary>
        /// <param name="r">The distance of the point to the origin.</param>
        /// <param name="angle">The direction of the vector originating in the origin pointing towards the point.</param>
        public PolarPosition(float r, Direction2 angle)
        {
            if (r < 0)
            {
                throw new ArgumentException("The radius has to be non-negative.");
            }

            R     = r;
            Angle = angle;
        }
Example #13
0
 public Settings()
 {
     Width     = 16;
     Height    = 16;
     Speed     = 16;
     Score     = 0;
     Point     = 100;
     GameOver  = false;
     direction = Direction.Down;
     di        = Direction2.Left;
 }
Example #14
0
 public Parameters(Id <IBody> id, Id <IBody> parentId, Radius orbitRadius, Direction2 orbitDirection,
                   Radius radius, float mass, float health)
 {
     this.Id             = id;
     this.ParentId       = parentId;
     this.OrbitRadius    = orbitRadius;
     this.OrbitDirection = orbitDirection;
     this.Radius         = radius;
     this.Mass           = mass;
     this.Health         = health;
 }
Example #15
0
 public static void Create(GameState game, int count, Color color, Vector2 position,
     Direction2 direction, float directionVariance, float speed, float lifeTime)
 {
     for (int i = 0; i < count; i++)
     {
         new Particle(game, color, position,
             direction + (StaticRandom.Float(-1, 1) * directionVariance).Radians(),
             StaticRandom.Float(speed), StaticRandom.Float(0.5f, 1) * lifeTime
             );
     }
 }
Example #16
0
 public static Axis GetAxis(this Direction2 direction)
 {
     if (direction == Direction2.Left || direction == Direction2.Right)
     {
         return(Axis.X);
     }
     if (direction == Direction2.Up || direction == Direction2.Down)
     {
         return(Axis.Y);
     }
     return(Axis.Undefined);
 }
Example #17
0
        /// <summary>
        /// Try to drive one tile in a random direction.
        /// </summary>
        /// <param name="pos">Current position.</param>
        /// <param name="dirLast">Forbidden direction for movement (to prevent reversing).</param>
        /// <returns>Direction of movement, DIR2_INVALID is returned if not moved.</returns>
        private Direction2 tryGo(Position pos, Direction2 dirLast)
        {
            Direction2[] directions = new Direction2[4];

            // Find connections from current position.
            Direction2 dir   = Direction2.DIR2_NORTH;
            int        count = 0;
            int        i;

            for (i = 0; i < 4; i++)
            {
                if (dir != dirLast && roadTest(getTileFromMap(pos, dir, (ushort)MapTileCharacters.DIRT)))
                {
                    // found a road in an allowed direction
                    directions[i] = dir;
                    count++;
                }
                else
                {
                    directions[i] = Direction2.DIR2_INVALID;
                }

                dir = DirectionUtils.rotate90(dir);
            }

            if (count == 0)
            {
                // dead end
                return(Direction2.DIR2_INVALID);
            }

            // We have at least one way to go.

            if (count == 1)
            {
                // only one solution
                for (i = 0; i < 4; i++)
                {
                    if (directions[i] != Direction2.DIR2_INVALID)
                    {
                        return(directions[i]);
                    }
                }
            }

            // more than one choice, draw a random number.
            i = getRandom16() & 3;
            while (directions[i] == Direction2.DIR2_INVALID)
            {
                i = (i + 1) & 3;
            }
            return(directions[i]);
        }
Example #18
0
 public Settings()
 {
     Width      = 16;
     Height     = 16;
     x          = 8;
     Wynik      = 0;
     Wynik2     = 0;
     Punkty     = 100;
     GameOver   = false;
     direction  = Direction.Down;
     direction2 = Direction2.Down;
 }
            public CommandImplementation(GameState game, IBody body, Direction2 direction)
                : base(CommandType.ShootDebugParticleFromPlanet, game)
            {
                var bodyShape = body.Shape;

                var d = Difference2.In(direction, 1.U());

                this.ps = new CommandParameters(
                    this.game.GetUniqueId <FreeObject>(),
                    bodyShape.Center + d * bodyShape.Radius.NumericValue * 1.5f,
                    d * 1 / TimeSpan.One
                    );
            }
Example #20
0
            public CommandImplementation(GameState game, IBody body, Player player, Direction2 direction)
                : base(CommandType.ShootProjectileFromPlanet, game)
            {
                var bodyShape = body.Shape;

                var d = Difference2.In(direction, 0.9f.U());

                this.ps = new CommandParameters(
                    this.game.GetUniqueId <FreeObject>(),
                    player,
                    bodyShape.Center + d * bodyShape.Radius.NumericValue * 1.5f,
                    body.Velocity + d / TimeSpan.One
                    );
            }
        public static Direction2 Right(this Direction2 dir)
        {
            if (dir == Direction2.None)
            {
                return(dir);
            }
            Direction2 right = (Direction2)(((int)dir + 1) % 4);

            if (dir > Direction2.Left)
            {
                right += 4;
            }
            return(right);
        }
        public static Direction2 Left(this Direction2 dir)
        {
            if (dir == Direction2.None)
            {
                return(dir);
            }

            Direction2 left = (Direction2)Helper.Wrap((int)dir % 4 - 1, 0, 3);

            if (dir > Direction2.Left)
            {
                left += 4;
            }
            return(left);
        }
Example #23
0
        public Ship(GameState game, Vector2 position,
            IShipController controller, int faction = 0, float acceleration = 5,
            Direction2 direction = default(Direction2), float inverseFriction = 0.8f)
            : base(game)
        {
            this.position = position;
            this.controller = controller;
            this.faction = faction;
            this.acceleration = acceleration;
            this.forwards = direction;
            this.inverseFriction = inverseFriction;
            controller.SetShip(this);

            game.Ships.Add(this);
        }
Example #24
0
        private void updateMovement(TimeSpan elapsedTime, float acceleration, float leftRight)
        {
            var t = (float)elapsedTime.NumericValue;

            this.speed += new Acceleration(acceleration * 50) * elapsedTime;
            this.speed *= Mathf.Pow(1e-3f, t);

            this.turnSpeed += AngularAcceleration.FromRadians(leftRight * 5) * elapsedTime;
            this.turnSpeed *= Mathf.Pow(1e-7f, t);

            this.Direction += this.turnSpeed * (elapsedTime * this.speed.NumericValue);

            this.Position += this.Direction * this.speed * elapsedTime;

            this.distanceTraveled += this.speed * elapsedTime;
        }
Example #25
0
        /// <summary>
        /// Try to drive to a destination.
        /// </summary>
        /// <param name="startPos">Starting position.</param>
        /// <param name="destZone">Zonetype to drive to.</param>
        /// <returns>Was drive succesful?</returns>
        bool tryDrive(Position startPos, ZoneType destZone)
        {
            Direction2 dirLast  = Direction2.DIR2_INVALID;
            Position   drivePos = new Position(startPos);

            /* Maximum distance to try */
            for (short dist = 0; dist < MAX_TRAFFIC_DISTANCE; dist++)
            {
                Direction2 dir = tryGo(drivePos, dirLast);
                if (dir != Direction2.DIR2_INVALID)
                {
                    // we found a road
                    drivePos.move(dir);
                    dirLast = DirectionUtils.rotate180(dir);

                    /* Save pos every other move.
                     * This also relates to
                     * Micropolis::trafficDensityMap::MAP_BLOCKSIZE
                     */
                    if ((dist & 1) != 0)
                    {
                        pushPos(drivePos);
                    }

                    if (driveDone(drivePos, destZone))
                    {
                        // if destination is reached
                        return(true); /* pass */
                    }
                }
                else
                {
                    if (curMapStackPointer > 0)
                    {
                        /* dead end, backup */
                        curMapStackPointer--;
                        dist += 3;
                    }
                    else
                    {
                        return(false); /* give up at start  */
                    }
                }
            }

            return(false); /* gone MAX_TRAFFIC_DISTANCE */
        }
Example #26
0
        public static HitResult?TryHit(this IProjectileCollider collider, Ray ray)
        {
            var start  = ray.Start.NumericValue;
            var dir    = ray.Direction.NumericValue;
            var center = collider.Position.NumericValue;
            var radius = collider.Radius.NumericValue;

            var a  = start.X - center.X;
            var b  = start.Y - center.Y;
            var r2 = radius * radius;

            var c2 = dir.X * dir.X;
            var d2 = dir.Y * dir.Y;
            var cd = dir.X * dir.Y;

            var s = (r2 - a * a) * d2
                    + (r2 - b * b) * c2
                    + 2 * a * b * cd;

            // if s is less than 0, the solutions for f are imaginary
            // and the ray's line does not intersect the circle
            if (s >= 0)
            {
                var f = (Mathf.Sqrt(s) + a * dir.X + b * dir.Y) / -(c2 + d2);

                if (f <= 1)
                {
                    var isInside = a * a + b * b < r2;
                    if (f >= 0 || (isInside && !float.IsNegativeInfinity(f)))
                    {
                        // TODO: currently returns negative f if ray starts inside
                        // consider treating this case differently?
                        // do we ever care about 'exit hits'?
                        // probably want to split entry/exit hits
                        // how to handle moving targets?
                        return(new HitResult(
                                   new Position2(start + dir * f),
                                   Direction2.Of(new Vector2(a, b)),
                                   f,
                                   isInside
                                   ));
                    }
                }
            }

            return(null);
        }
Example #27
0
        /// <summary>
        /// Check at position pos for a power-less conducting tile in the
        /// direction testDir.
        /// TODO Re-use something like Micropolis::getFromMap(), and fold this function into its caller.
        /// </summary>
        /// <param name="pos">Position to start from.</param>
        /// <param name="testDir">Direction to investigate.</param>
        /// <returns>Unpowered tile has been found in the indicated direction.</returns>
        private bool testForConductive(Position pos, Direction2 testDir)
        {
            var movedPos = new Position(pos);

            if (movedPos.move(testDir))
            {
                if ((ushort)(map[movedPos.posX, movedPos.posY] & (ushort)MapTileBits.CONDBIT) == (ushort)MapTileBits.CONDBIT)
                {
                    if (powerGridMap.worldGet(movedPos.posX, movedPos.posY) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #28
0
        public int SelectWall(Direction dir)
        {
            int        row    = 0;
            int        column = 0;
            Direction2 dir2   = Direction2.LeftRight;

            switch (dir)
            {
            case Direction.Up:
                dir2   = Direction2.LeftRight;
                row    = turtle.Row;
                column = turtle.Column;
                break;

            case Direction.Down:
                dir2   = Direction2.LeftRight;
                row    = turtle.Row + 1;
                column = turtle.Column;
                break;

            case Direction.Left:
                dir2   = Direction2.UpDown;
                row    = turtle.Row;
                column = turtle.Column;
                break;

            case Direction.Right:
                dir2   = Direction2.UpDown;
                row    = turtle.Row;
                column = turtle.Column + 1;
                break;
            }

            int index = -1;

            for (int i = 0; i < Walls.Count; i++)
            {
                if (Walls[i].Column == column && Walls[i].Row == row && Walls[i].Direction == dir2)
                {
                    index = i;
                    break;
                }
            }

            return(index);
        }
Example #29
0
        public static Direction2 GetOppositeDirection(Direction2 direction)
        {
            switch (direction)
            {
            case Direction2.East:
                return(Direction2.West);

            case Direction2.West:
                return(Direction2.East);

            case Direction2.North:
                return(Direction2.South);

            default:
                return(Direction2.North);
            }
        }
Example #30
0
            private void generateIntersectionsOnCircle(int count, float radius)
            {
                var angleBetweenIntersections = 360.Degrees() / count;
                var levelRadius = radius * Constants.Game.World.HexagonWidth.U();

                var startAngle = Direction2.FromDegrees(StaticRandom.Float(360));

                var angleVariance = angleBetweenIntersections.Radians * 0.3f;

                for (var i = 0; i < count; i++)
                {
                    var angle = startAngle + angleBetweenIntersections * i
                                + StaticRandom.Float(-angleVariance, angleVariance).Radians();
                    var point = new Position2() + angle.Vector
                                * (levelRadius * StaticRandom.Float(0.8f, 1));
                    intersections.Add(point);
                }
            }
Example #31
0
        public void MakeShip(Vector2 position, int faction,
            int minCannons = 2, int maxCannons = 5, Direction2 direction = default(Direction2))
        {
            var cannons = StaticRandom.Int(minCannons, maxCannons + 1);

            var s = new Ship(this.game, position,
                new SimpleEnemyShipController(this.game), faction,
                11 - 3f / 2f * cannons, direction, Math.Min(0.4f + 0.1f * cannons, 0.9f)
                );

            for (int j = 0; j < cannons; j++)
            {
                var x2 = (j - cannons / 2f + 0.5f) / cannons * 5;

                var a = Angle.FromDegrees(90);
                s.AddEquipment(new Cannon(this.game, new Vector2(x2, 2), a, GunControlGroup.Left));
                s.AddEquipment(new Cannon(this.game, new Vector2(x2, -2), -a, GunControlGroup.Right));
            }
        }
Example #32
0
        public OrbitingBody(GameState game, Id <IBody> id, IBody parent,
                            Radius orbitRadius, Direction2 orbitDirection, Radius radius,
                            float mass, Color color, float health)
            : base(game, id)
        {
            this.parent         = parent;
            this.orbitRadius    = orbitRadius;
            this.orbitDirection = orbitDirection;
            this.radius         = radius;
            this.mass           = mass;
            this.color          = color;
            this.health         = health;
            this.maxHealth      = health;

            this.center = this.calculatePosition();

            this.angularVelocity =
                ((Constants.G * parent.Mass / orbitRadius.NumericValue).Sqrted() / orbitRadius.NumericValue).Radians();
        }
        /// <summary>
        /// Make a small river.
        /// </summary>
        /// <param name="riverPos">Start position of making a river.</param>
        /// <param name="riverDir">Global direction of the river.</param>
        /// <param name="terrainDir">Local direction of the terrain.</param>
        /// <returns>Last used local terrain direction.</returns>
        private Direction2 doSRiver(Position riverPos, Direction2 riverDir, Direction2 terrainDir)
        {
            int rate1, rate2;

            if (terrainCurveLevel < 0)
            {
                rate1 = 100;
                rate2 = 200;
            }
            else
            {
                rate1 = terrainCurveLevel + 10;
                rate2 = terrainCurveLevel + 100;
            }

            Position pos = new Position(riverPos);

            while (Position.testBounds((short)(pos.posX + 3), (short)(pos.posY + 3)))
            {
                //printf("doSRiver %d %d td %d rd %d\n", pos.posX, pos.posY, terrainDir, riverDir);
                plopSRiver(pos);
                if (getRandom((short)rate1) < 10)
                {
                    terrainDir = riverDir;
                }
                else
                {
                    if (getRandom((short)rate2) > 90)
                    {
                        terrainDir = DirectionUtils.rotate45(terrainDir);
                    }
                    if (getRandom((short)rate2) > 90)
                    {
                        terrainDir = DirectionUtils.rotate45(terrainDir, 7);
                    }
                }
                pos.move(terrainDir);
            }

            return(terrainDir);
        }
Example #34
0
        /// <summary>
        /// Get neighbouring tile from the map.
        /// TODO should probably be in a Tile or Map class or something.
        /// </summary>
        /// <param name="pos">Current position.</param>
        /// <param name="dir">Direction of neighbouring tile, only horizontal and vertical directions are supported.</param>
        /// <param name="defaultTile">Tile to return if off-map.</param>
        /// <returns>
        /// The tile in the indicated direction. If tile is off-world or an
        /// incorrect direction is given, DIRT is returned
        /// </returns>
        private ushort getTileFromMap(Position pos, Direction2 dir, ushort defaultTile)
        {
            switch (dir)
            {
            case Direction2.DIR2_NORTH:
                if (pos.posY > 0)
                {
                    return((ushort)(map[pos.posX, pos.posY - 1] & (ushort)MapTileBits.LOMASK));
                }

                return(defaultTile);

            case Direction2.DIR2_EAST:
                if (pos.posX < WORLD_W - 1)
                {
                    return((ushort)(map[pos.posX + 1, pos.posY] & (ushort)MapTileBits.LOMASK));
                }

                return(defaultTile);

            case Direction2.DIR2_SOUTH:
                if (pos.posY < WORLD_H - 1)
                {
                    return((ushort)(map[pos.posX, pos.posY + 1] & (ushort)MapTileBits.LOMASK));
                }

                return(defaultTile);

            case Direction2.DIR2_WEST:
                if (pos.posX > 0)
                {
                    return((ushort)(map[pos.posX - 1, pos.posY] & (ushort)MapTileBits.LOMASK));
                }

                return(defaultTile);

            default:
                return(defaultTile);
            }
        }
Example #35
0
        public override void Update(TimeSpan t)
        {
            var rotation = this.controls.RotateCounterClockwise.AnalogAmount
                           - this.controls.RotateClockwise.AnalogAmount;

            this.aimDirection += 2f.Radians() * rotation * (float)t.NumericValue;

#if DEBUG
            if (this.controls.ShootDebug.Hit)
            {
                var request = ShootDebugParticleFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                this.game.RequestHandler.TryDo(request);
            }
#endif

            if (this.controls.Shoot.Active)
            {
                var fireInterval = new TimeSpan(1 / this.economy[EcoValue.FireRate].Value);

                var timeSinceLastShot = this.game.Time - this.lastShot;

                if (timeSinceLastShot > fireInterval)
                {
                    if (this.economy[EcoValue.Projectiles].Value >= 1)
                    {
                        var request = ShootProjectileFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                        this.game.RequestHandler.TryDo(request);
                        this.lastShot = this.game.Time;
                    }
                }
            }

            this.updateZoom(t);

            foreach (var stat in this.stats)
            {
                stat.Update(t);
            }
        }
Example #36
0
 public Particle(GameState game, Color color, Vector2 position, Direction2 direction, float speed, float lifeTime)
     : this(game, color, position, direction.Vector * speed, lifeTime)
 {
 }
Example #37
0
 public virtual void Update(ShipControlState controlState, float elapsedTime)
 {
     this.realPosition = this.owner.LocalToGlobalPosition(this.positionOffset);
     this.realDirection = this.owner.LocalToGlobalDirection(this.directionOffset);
 }
Example #38
0
        private void updateMovement(ShipControlState controlState, float elapsedTime)
        {
            this.forwards += Angle.FromRadians(controlState.Steer) * elapsedTime;

            if (controlState.Accelerate)
            {
                this.velocity += this.forwards.Vector * this.acceleration * elapsedTime;
            }

            var dragFactor = Mathf.Pow(this.inverseFriction, elapsedTime);

            this.velocity *= dragFactor;

            this.position += this.velocity * elapsedTime;

            this.localRotation = Matrix2.CreateRotation(-this.forwards.Radians);
        }
        public override void Update(TimeSpan t)
        {
            var rotation = this.controls.RotateCounterClockwise.AnalogAmount
                - this.controls.RotateClockwise.AnalogAmount;

            this.aimDirection += 2f.Radians() * rotation * (float)t.NumericValue;

            #if DEBUG
            if (this.controls.ShootDebug.Hit)
            {
                var request = ShootDebugParticleFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                this.game.RequestHandler.TryDo(request);
            }
            #endif

            if (this.controls.Shoot.Active)
            {
                var fireInterval = new TimeSpan(1 / this.economy[EcoValue.FireRate].Value);

                var timeSinceLastShot = this.game.Time - this.lastShot;

                if (timeSinceLastShot > fireInterval)
                {
                    if (this.economy[EcoValue.Projectiles].Value >= 1)
                    {
                        var request = ShootProjectileFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                        this.game.RequestHandler.TryDo(request);
                        this.lastShot = this.game.Time;
                    }
                }
            }

            this.updateZoom(t);

            foreach (var stat in this.stats)
            {
                stat.Update(t);
            }
        }
Example #40
0
        private void updateMovement(TimeSpan elapsedTime, float acceleration, float leftRight)
        {
            var t = (float)elapsedTime.NumericValue;

            this.speed += new Acceleration(acceleration * 50) * elapsedTime;
            this.speed *= Mathf.Pow(1e-3f, t);

            this.turnSpeed += AngularAcceleration.FromRadians(leftRight * 5) * elapsedTime;
            this.turnSpeed *= Mathf.Pow(1e-7f, t);

            this.Direction += this.turnSpeed * (elapsedTime * this.speed.NumericValue);

            this.Position += this.Direction * this.speed * elapsedTime;

            this.distanceTraveled += this.speed * elapsedTime;
        }