Ejemplo n.º 1
0
        public CellSet(Game1 game, int rows, int cols)
        {
            this.game = game;
            this.rows = rows;
            this.cols = cols;
            if (this.cols > 10) this.cols = 10; // Hardcode - ensure we dont add more cols
                                                // than the current window size

                        //Calculate where to start drawing the cells
            //so that the cell matrix would be center-aligned.
            int topLeft = (game.GameArea.Width - (cols * Cell.width)) / 2;

            position = new Vector2(topLeft, HUD.height + 40);
            CellsAlive = rows * cols;

            Cells = new Cell[rows][];
            for (int i = 0; i < rows; i++){
                Cells[i] = new Cell[cols];
                for (int j = 0; j < cols; j++){
                    bool alternateColor = ((i % 2) == 1);
                    Cells[i][j] = new Cell(
                        game,
                        position + new Vector2(
                            j * Cell.width, i * Cell.height),
                        alternateColor);
                }
            }
        }
Ejemplo n.º 2
0
        MouseState prevMouseState; //Mouse state from previous frame stored here

        #endregion Fields

        #region Constructors

        public ControlsManager(Game1 g)
        {
            game = g;
            Mouse.SetPosition(
                (int) game.Player.Position.X,
                (int) game.Player.Position.Y);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
Ejemplo n.º 4
0
        public ConfigManager(Game1 game)
        {
            this.game = game;
            XmlNode conf = LoadConfig();

            playerLivesDefault = Int32.Parse(conf["playerlives"].InnerText);
            playerSpeedDefault = Int32.Parse(conf["playerspeed"].InnerText);
            scorePerCellDefault = Int32.Parse(conf["points_per_cell"].InnerText);
            cellRowsDefault = Int32.Parse(conf["no_of_cell_rows"].InnerText);
            cellColsDefault = Int32.Parse(conf["no_of_cell_cols"].InnerText);

            highscore = Int32.Parse(conf["highscore"].InnerText);
        }
Ejemplo n.º 5
0
        public Cell(Game1 game, Vector2 position, bool alternateColor)
        {
            this.game = game;
            this.Position = position;
            rectangle = new Rectangle(0, 0, width, height);
            if (alternateColor)
                rectangle.Y+=height;

            collisionRect = new Rectangle(
                (int)position.X,
                (int)position.Y,
                width,
                height);

            Sprite = game.Content.Load<Texture2D>(spriteTexture);
        }
Ejemplo n.º 6
0
        public Player(Game1 game)
        {
            this.game = game;

            speed = game.ConfigManager.playerSpeedDefault;
            sprite = game.Content.Load<Texture2D>(spriteTexture);
            rectangle = new Rectangle(0, 0,
                width,
                height);

            frameTwoRectangle = new Rectangle(0, height,
                width,
                2*height);

            currentAnimationFrame = 0;
        }
Ejemplo n.º 7
0
        public Ball(Game1 game, Vector2 position)
        {
            this.game = game;
            this.position = position;

            falling = false;
            launched = false;
            sprite = game.Content.Load<Texture2D>(spriteTexture);

            collisionRect = new Rectangle(
                (int) position.X,
                (int) position.Y,
                width,
                height);

            rectangle = new Rectangle(0, 0,
                width,
                height);
        }
Ejemplo n.º 8
0
 public HUD(Game1 game)
 {
     this.game = game;
     Font = game.Content.Load<SpriteFont>("Arial");
 }
Ejemplo n.º 9
0
 public Ball(Game1 game, Texture2D image, Vector2 position) : base(image, position)
 {
     MoveTo(game.GraphicsDevice.DisplayMode.Width / 2 - Width / 2, game.GraphicsDevice.DisplayMode.Height - Height * 2);
     vector    = new Vector2(0, 0);
     this.game = game;
 }