Exemplo n.º 1
0
        //initailize all the character data
        public Character(GameContent gameContent, SpriteBatch spriteBatch, float x, float y, float screenWidth, float screenHeight)
        {
            this.head      = gameContent.head;
            this.body      = gameContent.body;
            this.face1     = gameContent.face1;
            this.face2     = gameContent.face2;
            this.face3     = gameContent.face3;
            this.leftArm   = gameContent.leftArm;
            this.leftHand  = gameContent.leftHand;
            this.leftLeg   = gameContent.leftLeg;
            this.rightArm  = gameContent.rightArm;
            this.rightHand = gameContent.rightHand;
            this.rightLeg  = gameContent.rightLeg;

            stable            = false;
            Width             = 30;
            Height            = 55;
            landOnIce         = false;
            landOnSpike       = false;
            FacingLeft        = false;
            this.screenWidth  = screenWidth;
            this.screenHeight = screenHeight;

            this.X           = x;
            this.Y           = y;
            this.xVector     = 0;
            this.yVector     = 0;
            this.spriteBatch = spriteBatch;
            distance         = x;
            WinLevel         = false;
        }
Exemplo n.º 2
0
 public LevelCounter(GameContent gameContent, SpriteBatch spriteBatch)
 {
     levCounterDisplay = gameContent.labelFont;
     this.spriteBatch  = spriteBatch;
     X = 20;
     Y = 20;
 }
Exemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            gameContent  = new GameContent(Content);
            screenWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            if (screenWidth >= 1080)
            {
                screenWidth = 1080;
            }
            if (screenHeight >= 720)
            {
                screenHeight = 720;
            }

            graphics.PreferredBackBufferWidth  = screenWidth;
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.ApplyChanges();
            charX     = 300;
            charY     = 300;
            character = new Character(gameContent, spriteBatch, charX, charY, screenWidth, screenHeight);
            floor     = new Floor(gameContent, spriteBatch, screenWidth, screenHeight);
            //create all the buttons needed for the game and place them
            startButtonPosition   = new Vector2((screenWidth / 2 - 40), (screenHeight / 10) * 5);
            exitButtonPosition    = new Vector2((screenWidth / 2 - 40), (screenHeight / 10) * 6);
            startButton           = new Button(this, spriteBatch, gameContent, "Start", screenHeight / 10, screenWidth / 5, startButtonPosition);
            ContinueButton        = new Button(this, spriteBatch, gameContent, "Continue", screenHeight / 10, screenWidth / 5, startButtonPosition);
            ControlsButton        = new Button(this, spriteBatch, gameContent, "Controls", screenHeight / 10, screenWidth / 5, exitButtonPosition);
            exitButtonPosition.Y += 100;
            exitButton            = new Button(this, spriteBatch, gameContent, "Exit", screenHeight / 10, screenWidth / 5, exitButtonPosition);
            exitButtonPosition.Y -= 50;
            ReturnButton          = new Button(this, spriteBatch, gameContent, "Return", screenHeight / 10, screenWidth / 5, exitButtonPosition);
            //create the bool for if the game has started and is not paused
            isPlaying = false;
            //load in all the levels
            level     = new Level(gameContent, spriteBatch, screenWidth, screenHeight, floor, 1);
            level2    = new Level(gameContent, spriteBatch, screenWidth, screenHeight, level, 2);
            level3    = new Level(gameContent, spriteBatch, screenWidth, screenHeight, level2, 3);
            level4    = new Level(gameContent, spriteBatch, screenWidth, screenHeight, level3, 4);
            level5    = new Level(gameContent, spriteBatch, screenWidth, screenHeight, level4, 5);
            levels    = new Level[5];
            levels[0] = level;
            levels[1] = level2;
            levels[2] = level3;
            levels[3] = level4;
            levels[4] = level5;
            //create the level counter
            levCounter = new LevelCounter(gameContent, spriteBatch);
            //create the mouse object so player can see a mouse in the menus
            mouse = new DrawMouse(spriteBatch, gameContent);
            //create a controls list so the control menu can be seen
            controlsList = new ControlsList(this, spriteBatch, gameContent);
        }
Exemplo n.º 4
0
 //Constructor to create a basic tile
 public Tile(GameContent gameContent, SpriteBatch spriteBatch, float x, float y)
 {
     platform         = gameContent.JumpTile;
     this.spriteBatch = spriteBatch;
     Height           = 20;
     Width            = 50;
     X    = x;
     Y    = y;
     rect = new Rectangle((int)X, (int)Y, (int)Width, (int)Height);
 }
Exemplo n.º 5
0
 public Land(GameContent gameContent, SpriteBatch spriteBatch, float screenWidth, float screenHeight, float x, float y)
 {
     land              = gameContent.landTile;
     this.spriteBatch  = spriteBatch;
     this.screenWidth  = screenWidth;
     this.screenHeight = screenHeight;
     Height            = land.Height;
     Width             = land.Width;
     X    = x;
     Y    = y;
     rect = new Rectangle((int)X, (int)Y, land.Width, 1);
 }
Exemplo n.º 6
0
        /*public Button(Game1 game, string text, int height, int width, Vector2 position)
         * {
         *  Game1 = game;
         *  GraphicsDevice = game.GraphicsDevice;
         *  Color = Color.Black;
         *  this.text = text;
         *  this.height = height;
         *  this.width = width;
         *  Texture = new Texture2D(GraphicsDevice, width, height);
         *  Position = position;
         *  prevMouseState = Mouse.GetState();
         *  button = new Rectangle((int)Position.X, (int)Position.Y, this.width, this.height);
         * }*/

        public Button(Game1 game, SpriteBatch spriteBatch, GameContent gameContent, string text, int height, int width, Vector2 position)
        {
            Game1            = game;
            this.spriteBatch = spriteBatch;
            GraphicsDevice   = game.GraphicsDevice;
            spriteFont       = gameContent.labelFont;
            this.Color       = Color.Black;
            this.text        = text;
            Texture          = gameContent.ButtonTexture;
            this.height      = Texture.Height;
            this.width       = Texture.Width;
            Position         = position;
            prevMouseState   = Mouse.GetState();
            button           = new Rectangle((int)Position.X, (int)Position.Y, this.width * 2, this.height * 2);
        }
Exemplo n.º 7
0
        public Floor(GameContent gameContent, SpriteBatch spriteBatch, float screenWidth, float screenHeight)
        {
            Width  = 0;
            Height = 0;
            Land land = new Land(gameContent, spriteBatch, screenWidth, screenHeight, 0, 0);

            X = 0;
            Y = screenHeight - (land.Height / 2);
            float spaces = screenWidth / land.Width;

            floor = new Land[(int)spaces + 1];
            for (int i = 0; i < spaces; i++)
            {
                floor[i] = new Land(gameContent, spriteBatch, screenWidth, screenHeight, land.Width * i, screenHeight - (land.Height / 2));
                Width   += floor[i].Width;
                Height  += floor[i].Height;
            }
        }
Exemplo n.º 8
0
 //Constructor to create a special tile, the last param is used to determine the type of special tiel
 public Tile(GameContent gameContent, SpriteBatch spriteBatch, float x, float y, int type)
 {
     platformType = type;
     if (platformType == 2)
     {
         platform = gameContent.SpikyPad;
         Width    = 50;
     }
     else if (platformType == 3)
     {
         platform = gameContent.IcyPad;
         Width    = 67;
     }
     else if (platformType == 4)
     {
         platform = gameContent.BramblePad;
         Width    = 100;
     }
     this.spriteBatch = spriteBatch;
     Height           = 20;
     X    = x;
     Y    = y;
     rect = new Rectangle((int)X, (int)Y, (int)Width, (int)Height);
 }
Exemplo n.º 9
0
 public DrawMouse(SpriteBatch spriteBatch, GameContent gameContent)
 {
     this.spriteBatch = spriteBatch;
     this.gameContent = gameContent;
     MouseTexture     = gameContent.MouseTexture;
 }
Exemplo n.º 10
0
 public ControlsList(Game1 game, SpriteBatch spriteBatch, GameContent gameContent)
 {
     this.spriteBatch = spriteBatch;
     this.spriteFont  = gameContent.labelFont;
     Game1            = game;
 }
Exemplo n.º 11
0
        //Generate the level randomly based on several parameters
        public Level(GameContent gameContent, SpriteBatch spriteBatch, float screenWidth, float screenHeight, Floor floor, int levelNum)
        {
            levelCount      = levelNum;
            variation       = 100;                                        //How far up or down the tile with be
            platformNumber  = 20 * levelCount;                            // the number of platforms in the level
            specPlatformNum = 5 * levelCount;                             //the number of special platforms in the level
            level           = new Tile[platformNumber + specPlatformNum]; //create a tile array to hold all platforms needed for level
            Width           = 0;
            Height          = 0;
            Tile platform = new Tile(gameContent, spriteBatch, 0, 0);

            X          = floor.X + floor.Width;             // the base X coordinate used to determine first tile location
            Y          = screenHeight - (screenHeight / 4); //the base Y coordinate used to determine first tile location
            prevHeight = 0;
            visible    = true;

            //loop to create all the basic tiles in the game
            for (int i = 0; i < platformNumber; i++)
            {
                level[i] = new Tile(gameContent, spriteBatch, X + (100 * i + 1), Y);
                Width   += level[i].Width;
                int zerOne = randGen.Next(0, 2);
                prevHeight = Y;
                if (Y > 100 && Y <= (screenHeight - 200))
                {
                    if (zerOne == 1)
                    {
                        Y = (Y + variation);
                    }
                    else
                    {
                        Y = Y - variation;
                    }
                }
                else
                {
                    Y = screenHeight - 300;
                }
            }

            for (int i = platformNumber; i < platformNumber + specPlatformNum; i++)
            {
                int type          = randGen.Next(2, 4);
                int offsetShift   = randGen.Next(1, 4);
                int platformPlace = randGen.Next(0, platformNumber);
                int Y             = 0;
                int x             = 0;
                if (type == 2)
                {
                    //Spike platform creation
                    xOffset = 50;
                    yOffset = (int)level[platformPlace].Y;
                    X       = level[platformPlace].X - xOffset;
                    Y       = yOffset;
                }
                else
                {
                    //Icy Platform creation
                    xOffset = 0;
                    yOffset = -70 * offsetShift;
                    X       = level[platformPlace].X - xOffset;
                    if (level[platformPlace].Y < screenHeight / 2)
                    {
                        Y = (int)level[platformPlace].Y - yOffset;
                    }
                    else
                    {
                        Y = (int)level[platformPlace].Y + yOffset;
                    }
                }
                level[i] = new Tile(gameContent, spriteBatch, X, Y, type);
            }
            X = level[0].X;
        }