Copper Mayhem

Copper Mayhem is a dungeon explorer game mixed with a bullet hell. This game is made with C# in MonoGame. It was made with a team of 4 developers. We wanted to challenge ourselves by making a 3D game in MonoGame. It was the first time I made a game in 3D.


My addition to this game are all the enemy’s behavior, so how the move. At first I created a follow behavior that follows the player. The only thing was the enemy followed the player too close so I needed to add a radius to the behavior so the enemy would follow from a distance. I did this by calculating the distance between the player and the enemy and if the radius is bigger than the distance the enemy’s velocity would be set at 0.

protected void FollowBehavior(GameTime gameTime)
        {
            Vector3 newFollowPosition = Position;
            Vector3 newFollowRotation = Rotation;

            newFollowRotation = MathHelper3D.GetRotationToPoint(Position, new Vector3(target.Position.X, target.Position.Y + 6, target.Position.Z));

            if (MathHelper3D.GetDistanceBetween2Points(Position, new Vector3(target.Position.X, target.Position.Y + 6, target.Position.Z)) > radius)
            {
                desiredVelocity = Vector3.Normalize(new Vector3(target.Position.X, target.Position.Y + 6, target.Position.Z) - Position) * maxSpeed;
                steering = desiredVelocity - enemyVelocity;
                if (steering.Length() > maxForce)
                {
                    steering = Truncate(steering, maxForce);
                }
                steering /= mass;
                enemyVelocity = Truncate(enemyVelocity + steering, maxSpeed);

                newFollowPosition += enemyVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds;

            }
            Translate(newFollowPosition, newFollowRotation);
        }

After making the follow behavior I created the Orbit behavior which is basically a follow behavior but if the player is within the follow range it orbits around the player. The speed takes into account how close the player is to the enemy.
So I basically made a circle around the player and made the enemy follow that. A team mate made a helper that had a hover effect in it which basically is a sinus wave in to the movement which makes the enemy appear to hover.

It looked like this:

This was all not really hard to do, because my teammate made it really simple by making a 3DMathHelper class, that had some actions that I could simply implement. I wanted to challenge myself by learning how flocking behavior works and how I could add it to the game. I wanted to create a flock of bees. I first searched the main components of flocking behavior:

  • Separation, the bees want to seperate from ech other.
  • Alignment, the bees want to rotate to each others direction.
  • Cohesion, the bees want to go to each other.
  • Colliders, the bees dont want to bump in to objects.
  • *Extra* Exploration, the bees want to explore new places.

This was very hard for me, I didn’t know where to begin. I asked a student teacher who had introduced me to flocking where I could begin. He started to explain to me what a dot product is and explained how it works. So what I did is finding which bees are in the dot product of a bee and looking at their variables.
After that I began to make Alignment. By trying to let a bee compare and turn to other bees in the dot product. It took me a while to figure out, I watched many tutorials and read many sites. Eventually I got it. I got the variables of all the bees in the dot product and added them all up and divided them by the amount of bees in the list. With this I got the average of each bee. By making them going to the average direction they will all go to a similar direction so this is alignment. I did almost the same for cohesion and avoidance, but with the position and added a weight, because otherwise the cohesion and separation would cancel eachother out.

I put all the flocking code in 1 function because at the time I couldn’t figure out how to use more than 1 scripts for 1 game object.
This was the result after tweaking a lot of variables and testing (also in an early version of the game):

I was really really proud of this, but if I would make this with my current knowledge, I would firstly make it in Unity, because Unity works a lot simpeler and better than MonoGame. Also I would make it in seperate files and more optimized.
I wanted to make a quadtree, but didn’t have enough time, because I needed to hand in my work. I haven’t worked on this game since because I didn’t really want to anymore.

I and an other team mate found al the models for our game so I did some of that aswell

But here is some gameplay of our game:

https://youtu.be/p1eog_OtdEw