コード例 #1
0
ファイル: CellSet.cs プロジェクト: jaks6/arkanoid
        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);
                }
            }
        }
コード例 #2
0
ファイル: ControlsManager.cs プロジェクト: jaks6/arkanoid
        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);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: jaks6/arkanoid
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
コード例 #4
0
ファイル: ConfigManager.cs プロジェクト: jaks6/arkanoid
        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);
        }
コード例 #5
0
ファイル: Cell.cs プロジェクト: jaks6/arkanoid
        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);
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: jaks6/arkanoid
        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;
        }
コード例 #7
0
ファイル: Ball.cs プロジェクト: jaks6/arkanoid
        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);
        }
コード例 #8
0
ファイル: HUD.cs プロジェクト: jaks6/arkanoid
 public HUD(Game1 game)
 {
     this.game = game;
     Font = game.Content.Load<SpriteFont>("Arial");
 }
コード例 #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;
 }