/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); sky = new SkySphere(ScreenManager.Game, this); player = new BallCharacter(ScreenManager.Game, this); //soundEffect.Play(1.0f, 0.0f, 0.0f, true); //sets up the level SwitchToNextLevel(); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); player = new BallCharacter(ScreenManager.Game, this); player.position = new Vector3(10f, 25f, 0f); ScreenManager.Game.Components.Add(player); m_kWallManager = new WallManager(ScreenManager.Game, this); ScreenManager.Game.Components.Add(m_kWallManager); String assetName = "checker_plane_3"; //make a few planes CollisionLevelPiece currentPlane; currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 15; currentPlane.position += new Vector3(0f, -10f, 0); planes.Add(currentPlane); currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 10; currentPlane.position += new Vector3(200f, -10f, -300f); currentPlane.setLocalRotation(0, (float)Math.PI / 18); planes.Add(currentPlane); currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 10; currentPlane.position += new Vector3(-250f, -10f, -200f); currentPlane.setLocalRotation(0.123f, -(float)Math.PI / 18); planes.Add(currentPlane); currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 5; currentPlane.position += new Vector3(-220f, 10f, 80f); planes.Add(currentPlane); //moving level piece MovingLevelPiece movingPlane; //50 is a good movement speed movingPlane = new MovingLevelPiece(ScreenManager.Game, this, assetName, new Vector3(0, 100f, 0f), 50); movingPlane.scale = 5; movingPlane.position += new Vector3(0f, 0f, -200f); planes.Add(movingPlane); foreach (LevelPiece p in planes) { ScreenManager.Game.Components.Add(p); } }
public void SwitchToNextLevel() { activeLevel = (LevelData)LevelList.ToArray()[currentLevel]; activeLevel.startLevel(ScreenManager.Game); player = new BallCharacter(ScreenManager.Game, this); player.position = activeLevel.startingLocation; ScreenManager.Game.Components.Add(player); ScreenManager.Game.Components.Add(m_kWallManager); currentLevel++; currentLevel = currentLevel % LevelList.Count; }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); player = new BallCharacter(ScreenManager.Game, this); player.position = new Vector3(0f, 25f, 0f); ScreenManager.Game.Components.Add(player); m_kWallManager = new WallManager(ScreenManager.Game, this); ScreenManager.Game.Components.Add(m_kWallManager); m_kPlane = new CollisionLevelPiece(ScreenManager.Game, this, "level1"); //m_kPlane.scale = 50; m_kPlane.position += new Vector3(0, -10f, 0); ScreenManager.Game.Components.Add(m_kPlane); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); meshes = new Model[1]; meshes[0] = ScreenManager.Game.Content.Load <Model>("meshes/cone"); player = new BallCharacter(ScreenManager.Game, this); //player.position = new Vector3(10f, 25f, 0f); player.position = new Vector3(0f, 0f, 0f); ScreenManager.Game.Components.Add(player); m_kWallManager = new WallManager(ScreenManager.Game, this); ScreenManager.Game.Components.Add(m_kWallManager); m_kPlane = new LevelPiece(ScreenManager.Game, this, "checker_plane"); m_kPlane.scale = 15; m_kPlane.position += new Vector3(150f, -10f, 0); ScreenManager.Game.Components.Add(m_kPlane); celLightingEffect = ScreenManager.Game.Content.Load <Effect>("Cel"); GetEffectParameters(); //Calculate the projection properties first on any //load callback. That way if the window gets resized, //the perspective matrix is updated accordingly float aspectRatio = (float)ScreenManager.Game.GraphicsDevice.Viewport.Width / (float)ScreenManager.Game.GraphicsDevice.Viewport.Height; float fov = MathHelper.PiOver4 * aspectRatio * 3 / 4; projection = Matrix.CreatePerspectiveFieldOfView(fov, aspectRatio, .1f, 1000f); //create a default world matrix world = Matrix.Identity; }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); player = new BallCharacter(ScreenManager.Game, this); player.position = new Vector3(10f, 25f, 0f); ScreenManager.Game.Components.Add(player); m_kWallManager = new WallManager(ScreenManager.Game, this); ScreenManager.Game.Components.Add(m_kWallManager); m_kPlane = new CollisionLevelPiece(ScreenManager.Game, this, "checker_plane_3"); m_kPlane.scale = 15; m_kPlane.position += new Vector3(150f, -10f, 0); ScreenManager.Game.Components.Add(m_kPlane); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); player = new BallCharacter(ScreenManager.Game, this); player.position = new Vector3(10f, 25f, 0f); ScreenManager.Game.Components.Add(player); m_kWallManager = new WallManager(ScreenManager.Game, this); ScreenManager.Game.Components.Add(m_kWallManager); String assetName = "checker_plane_3"; //make a few planes CollisionLevelPiece currentPlane; currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 15; currentPlane.position += new Vector3(0f, -10f, 0); planes.Add(currentPlane); currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 10; currentPlane.position += new Vector3(200f, -10f, -300f); currentPlane.setLocalRotation(0, (float) Math.PI / 18); planes.Add(currentPlane); currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 10; currentPlane.position += new Vector3(-250f, -10f, -200f); currentPlane.setLocalRotation(0.123f, -(float)Math.PI / 18); planes.Add(currentPlane); currentPlane = new CollisionLevelPiece(ScreenManager.Game, this, assetName); currentPlane.scale = 5; currentPlane.position += new Vector3(-220f, 10f, 80f); planes.Add(currentPlane); //moving level piece MovingLevelPiece movingPlane; //50 is a good movement speed movingPlane = new MovingLevelPiece(ScreenManager.Game, this, assetName, new Vector3(0, 100f, 0f), 50); movingPlane.scale = 5; movingPlane.position += new Vector3(0f, 0f, -200f); planes.Add(movingPlane); foreach (LevelPiece p in planes) { ScreenManager.Game.Components.Add(p); } }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { base.LoadContent(); meshes = new Model[1]; meshes[0] = ScreenManager.Game.Content.Load<Model>("meshes/cone"); player = new BallCharacter(ScreenManager.Game, this); //player.position = new Vector3(10f, 25f, 0f); player.position = new Vector3(0f, 0f, 0f); ScreenManager.Game.Components.Add(player); m_kWallManager = new WallManager(ScreenManager.Game, this); ScreenManager.Game.Components.Add(m_kWallManager); m_kPlane = new LevelPiece(ScreenManager.Game, this, "checker_plane"); m_kPlane.scale = 15; m_kPlane.position += new Vector3(150f, -10f, 0); ScreenManager.Game.Components.Add(m_kPlane); celLightingEffect = ScreenManager.Game.Content.Load<Effect>("Cel"); GetEffectParameters(); //Calculate the projection properties first on any //load callback. That way if the window gets resized, //the perspective matrix is updated accordingly float aspectRatio = (float)ScreenManager.Game.GraphicsDevice.Viewport.Width / (float)ScreenManager.Game.GraphicsDevice.Viewport.Height; float fov = MathHelper.PiOver4 * aspectRatio * 3 / 4; projection = Matrix.CreatePerspectiveFieldOfView(fov, aspectRatio, .1f, 1000f); //create a default world matrix world = Matrix.Identity; }
public Boolean IsCollidingWithCollectable(BallCharacter player, Game game) { Collectable holder = null; foreach (Collectable collect in collectables) { if (!collect.CollectedYet && collect.WorldBoundSphere.Intersects(player.WorldBoundSphere)) { holder = collect; break; } } if (null != holder) { holder.CollectedYet = true; game.Components.Remove(holder); return true; } return false; }
/// <summary> /// Collision resolution. Kind of a hack. /// Called from the Update function /// Tweak numbers until the feel is "right" /// </summary> /// <param name="pushAway">The normalized vector that the ball should be pushed away</param> /// <param name="timeDelta"></param> private void respondToCollision(Vector3 pushAway, Vector3 movingPlaneVel, float timeDelta, BallCharacter player) { //Vector3 v3 = m_kPlane.getPlaneNormal(); Vector3 vDiff = player.velocity; vDiff += movingPlaneVel; vDiff.X += pushAway.X * 20; vDiff.Z += pushAway.Z * 20; if (vDiff.Y < -50) { vDiff.Y /= 1.5f; } vDiff.Y += pushAway.Y; vDiff.Y -= (gravityVec.Y * timeDelta) * 2; player.velocity = vDiff; }
public void MovePlayer(BallCharacter player, GameTime gameTime) { float timeDelta = (float)gameTime.ElapsedGameTime.Ticks / System.TimeSpan.TicksPerMillisecond / 1000; player.velocity += gravityVec * timeDelta; //test for collision Vector3 pushAway = Vector3.Zero; Vector3 movingPlaneVel = Vector3.Zero; if (planes.Count != 0) { foreach (CollisionLevelPiece p in planes) { Vector3 result = p.testCollision(player); pushAway += result; if (result != Vector3.Zero && p is MovingLevelPiece) { movingPlaneVel += ((MovingLevelPiece)p).MoveVelocity / 20; } } } if (pushAway != Vector3.Zero) { pushAway.Normalize(); player.CollidedWithStage = true; respondToCollision(pushAway, movingPlaneVel, timeDelta, player); } else { player.CollidedWithStage = false; } }
public Boolean IsCollidingWithGoal(BallCharacter player) { if (goal != null) { if (goal.WorldBoundSphere.Intersects(player.WorldBoundSphere)) { return true; } } return false; }