/// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
Beispiel #2
0
 public ObjectSpawner(Game1 game)
     : base(game)
 {
     this.game = game;
     random = new Random();
     Reset();
 }
Beispiel #3
0
        public Background(Game1 game)
            : base(game)
        {
            back = new List<BackgroundElement>();
            farBack = new List<BackgroundElement>();

            int statX = 0;
            Texture2D tex = game.Content.Load<Texture2D>(@"Backgrounds/bg_0");
            for (int i = 0; i < 4; i++)
            {
                BackgroundElement b = new BackgroundElement(game, tex, 0.3f, statX, 0.2f, 0.27f);
                this.farBack.Add(b);
                statX += (int)(tex.Bounds.Width * b.scale);
            }

            statX = 0;
            tex = game.Content.Load<Texture2D>(@"Backgrounds/bg_1");
            for (int i = 0; i < 4; i++)
            {
                BackgroundElement b = new BackgroundElement(game, tex, 0.3f, statX, 0.4f, 0.32f);
                this.farBack.Add(b);
                statX += (int)(tex.Bounds.Width * b.scale);

                //Console.WriteLine("Covered in terrains: {0} rad, left uncovered: {1}", angle - 4.4f, 2 * Math.PI - angle + 4.4f);
            }
        }
Beispiel #4
0
        public AscentTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly)
            : base(game, startAngle, terrianHeight, hasFly)
        {
            texture = game.Content.Load<Texture2D>(@"Terrains/gr_2");
            origin.X = texture.Width / 2 * scale;
            origin.Y = texture.Height / 2 * scale;
            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale));
            offsetAngle = 0.029f;

            // create list of smaller colliders that will act as steps:
            /*
             *                -------|
             *           ------------|
             *       ----------------|
             * ----------------------|
             */
            stepColliders = new List<Rectangle>();
            widthStep = (int)(texture.Width * scale / 4);
            int heightOffset = (int)(texture.Height * scale / 4);
            heightStep = (int)(heightOffset / 4);
            for (int i = 0; i < 4; i++)
            {
                Rectangle step = new Rectangle(0, 0, widthStep * (i + 1), heightStep);
                stepColliders.Add(step);
            }
        }
Beispiel #5
0
 public PlainTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly)
     : base(game, startAngle, terrianHeight, hasFly)
 {
     texture = game.Content.Load<Texture2D>(@"Terrains/gr_0");
     origin.X = texture.Width / 2 * scale;
     origin.Y = texture.Height / 2 * scale;
     boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale));
     offsetAngle = 0.03f;
 }
Beispiel #6
0
        public ScoreDisplay(Game1 game)
            : base(game)
        {
            currentPoints = 0;
            currentSize = 50;
            timeElapsed = 0;

            this.game = game;
            pointsPosition = new Vector2(20, 15);
            sizePosition = new Vector2(20, 65);
            timerPosition = new Vector2(game.screenWidth - 450, game.screenHeight - 50);
        }
        public BackgroundElement(Game1 game, Texture2D texture, float alpha, int startX, float movementOffset, float yOffset)
            : base(game)
        {
            this.game = game;
            this.texture = texture;
            this.alpha = alpha;
            this.position.X = startX;
            this.movementOffset = movementOffset;
            this.yOffset = yOffset;

            scale = 0.25f;
        }
Beispiel #8
0
        public MeteorBig(Game1 game)
            : base(game)
        {
            texture = game.Content.Load<Texture2D>(@"ObjectsAnimations/MeteorBig/bm_0");
            position.X = game.screenWidth - 50;
            position.Y = 10;

            origin.X = texture.Width / 2 * scale;
            origin.Y = texture.Height / 2 * scale;

            rotationAngle = 0.9f;
            scale = 0.05f;

            Initialize();
        }
Beispiel #9
0
        public Terrain(Game1 game, float startAngle, double terrianHeight, bool hasFly)
            : base(game)
        {
            this.game = game;
            angle = startAngle;
            tHeight = terrianHeight;

            Random r = new Random();
            float flyOffset = (float)r.NextDouble() * 0.055f; // max offfset angle
            if (hasFly)
            {
                fly = new Fly(game, startAngle + flyOffset, this);
            }

            isOnScreen = false;
        }
Beispiel #10
0
        public MeteorSmall(Game1 game)
            : base(game)
        {
            this.game = game;

            texture = game.Content.Load<Texture2D>(@"ObjectsAnimations/MeteorSmall/sm_0");
            Random r = new Random();
            position.X = r.Next(game.screenWidth);
            position.Y = -10;

            scale = 0.13f;

            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale * 0.6f), (int)(texture.Bounds.Height * scale * 0.6f));

            Initialize();
        }
Beispiel #11
0
        public Earth(Game1 game)
            : base(game)
        {
            this.game = game;
            this.position = new Vector2(game.screenWidth * 0.5f, game.screenHeight * 6.97f);
            // earth center
            texture = game.Content.Load<Texture2D>(@"Earth");
            origin.X = texture.Width / 2;
            origin.Y = texture.Height / 2;
            radius = texture.Bounds.Height * 0.5f * scale;
            lowestH = 0.01;
            secondH = 0.08;
            thirdH = 0.15;
            topH = 0.2;

            Initialize();
        }
Beispiel #12
0
        public Fly(Game1 game, float startAngle, Terrain terrain)
            : base(game)
        {
            this.game = game;
            this.terrain = terrain;

            this.position = new Vector2();
            Random r = new Random();
            scale = 0.5f;
            //position.X = r.Next(game.screenWidth);
            position.Y = game.screenHeight * 0.5f;
            positionAngle = startAngle;
            texture = game.Content.Load<Texture2D>(@"ObjectsAnimations/Fly/fl_0");
            origin.X = texture.Width * 2 * scale;
            origin.Y = terrain.position.Y - 100;
            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale));
            Initialize();
        }
Beispiel #13
0
        public VolcanoTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly)
            : base(game, startAngle, terrianHeight, hasFly)
        {
            texture = game.Content.Load<Texture2D>(@"Terrains/vo_0");
            origin.X = texture.Width / 2 * scale;
            origin.Y = texture.Height / 2 * scale;

            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * scale));

            // create list of smaller colliders that will act as steps and lava:
            /*
             *                         |---|
             *                         |---|
             *                -------| |---| |------
             *           ------------|       |-------------
             *       ----------------|       |-----------------
             * ----------------------|       |------------------------
             */
            stepCollidersAscend = new List<Rectangle>();
            widthStep = (int)(texture.Width * scale / 10);
            int heightOffset = (int)(texture.Height * scale / 4);
            heightStep = (int)(heightOffset / 4);
            for (int i = 0; i < 4; i++)
            {
                Rectangle step = new Rectangle(0, 0, widthStep * (i + 1), heightStep);
                stepCollidersAscend.Add(step);
            }

            stepCollidersDescend = new List<Rectangle>();
            for (int i = 0; i < 4; i++)
            {
                Rectangle step = new Rectangle(0, 0, widthStep * (i + 1), heightStep);
                stepCollidersDescend.Add(step);
            }

            lavaCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.02), (int)(texture.Bounds.Height * scale));

            offsetAngle = 0.055f;

            volcanoAnimation = Textures.VolcanoAnimation;
            VolcanoAnimationController.PlayAnimation(volcanoAnimation);
        }
Beispiel #14
0
        public LavaPitTerrain(Game1 game, float startAngle, double terrianHeight, bool hasFly)
            : base(game, startAngle, terrianHeight, hasFly)
        {
            texture = game.Content.Load<Texture2D>(@"Terrains/lp_0");
            origin.X = texture.Width / 2 * scale;
            origin.Y = texture.Height / 2 * scale;

            // colliders
            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale), (int)(texture.Bounds.Height * 0.9f * scale));
            /*
             * --|     |---
             * --|     |---
             * --|=====|---
             */
            pitCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.8f), (int)(boxCollider.Height * 0.66f));
            leftRidgeCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.1f), boxCollider.Height);
            rightRidgeCollider = new Rectangle(0, 0, (int)(boxCollider.Width * 0.1f), boxCollider.Height);

            offsetAngle = 0.035f;
        }
Beispiel #15
0
        public Bird(Game1 game)
            : base(game)
        {
            this.game = game;

            this.position = new Vector2();
            Random r = new Random();
            position.X = r.Next(game.screenWidth);
            position.Y = 0;
            startPosition = position;
            target = new Vector2();

            scale = 0.3f;
            texture = game.Content.Load<Texture2D>("ObjectsAnimations/Bird/d_FLAP_0");
            origin.X = texture.Width / 2 * scale;
            origin.Y = texture.Height / 2 * scale;
            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * 0.8f * scale), (int)(texture.Bounds.Height * 0.4f * scale));

            game.birdSpawnedSound.Play();
            Initialize();
        }
Beispiel #16
0
        public Player(Game1 game)
            : base(game)
        {
            this.game = game;
            scoreDisplay = new ScoreDisplay(game);
            scoreDisplay.currentSize = (int)(scale * 1000);

            angle = MIN_ANGLE;
            this.position = new Vector2();
            position.X = game.earth.radius * (float)Math.Cos(angle) + game.screenWidth * 0.4f;
            position.Y = 100;

            texture = game.Content.Load<Texture2D>(@"PlayerAnimations/Idle/t_IDLE_0");
            origin.X = texture.Width / 2 * scale;
            origin.Y = texture.Height / 2 * scale;
            boxCollider = new Rectangle(0, 0, (int)(texture.Bounds.Width * scale * colliderOffsetX), (int)(texture.Bounds.Height * scale * colliderOffsetY));
            jumpingTime = new TimeSpan();
            crouchingTime = new TimeSpan();

            Initialize();
        }
Beispiel #17
0
 static void Main()
 {
     using (var game = new Game1())
         game.Run();
 }