public GroundedObject(string FilePath, Character[] Player, MoveableObject Camera, Type ObjectType) : base(FilePath) { this.ObjectType = ObjectType; this.Camera = Camera; this.Player = Player; MyRandom = new Random(); Lanes = new float[3]; Lanes[0] = -28; Lanes[1] = 0; Lanes[2] = 28; StartAnimation((animType)0); List <mat4> Rotations = new List <mat4>(); Rotations.Add(glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0))); Rotations.Add(glm.rotate((float)((270.0f / 180) * Math.PI), new vec3(0, 1, 0))); rotationMatrix = MathHelper.MultiplyMatrices(Rotations); Scale = 0.3f * Constants.AspectRatio; scaleMatrix = glm.scale(new mat4(1), new vec3(Scale, Scale, Scale)); Position = new vec3(Lanes[MyRandom.Next(0, 3)], 550, MyRandom.Next(-1100, -800)) * Constants.AspectRatio; Target = Position; }
public bool DetectCollision(MoveableObject Target) { return(DistanceFrom(Target) < 2.5f); }
public double DistanceFrom(MoveableObject Target) { return(Math.Sqrt(Math.Pow(Position.x - Target.Position.x, 2) + Math.Pow(Position.y - Target.Position.y, 2) + Math.Pow(Position.z - Target.Position.z, 2))); }