コード例 #1
0
ファイル: TileSet.cs プロジェクト: tojuhaka/HakaGame
        int tileWidthInPixels; // Single Tile

        #endregion Fields

        #region Constructors

        // Needs engine and filename where to load
        public TileSet(Engine engine,string filename, int tilesWide, int tilesHigh, int tileWidth, int tileHeight)
        {
            // Throw exception
            if (filename == null || engine == null)
            {
                throw new Exception("Filename or engine can't be null in tileset");
            }

            Texture = engine.Content.Load<Texture2D>(filename);
            TileWidth = tileWidth;
            TileHeight = tileHeight;
            TilesWide = tilesWide;
            TilesHigh = tilesHigh;
            int tiles = tilesWide * tilesHigh;
            sourceRectangles = new Rectangle[tiles];
            int tile = 0;

            // First x-axis, then go y-axis and again x-axis
            for (int y = 0; y < tilesHigh; y++)
                for (int x = 0; x < tilesWide; x++)
                {
                    sourceRectangles[tile] = new Rectangle(
                    x * tileWidth,
                    y * tileHeight,
                    tileWidth,
                    tileHeight);
                    tile++;
                }
        }
コード例 #2
0
ファイル: MainGame.cs プロジェクト: tojuhaka/HakaGame
        protected override void LoadContent()
        {
            engine = new Engine(this, graphics);

            startScreen = new StartScreen();
            helpScreen = new HelpScreen();
            actionScreen = new ActionScreen();
            cgScreen = new CharacterGeneratorScreen();
            titleScreen = new TitleScreen();

            engine.PushGameScreen(startScreen);
        }