コード例 #1
0
ファイル: Player.cs プロジェクト: paulfysh/CriminalEmpires
 //I dont like this get move commit move model, but frankly my code base is a bit nasty so, Ill do that for now and tidy it if I get chance.
 public void DoMove(Map terrain)
 {
     if (!terrainCollision(nextLocation, terrain))
     {
         location = nextLocation;
     }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: paulfysh/CriminalEmpires
        private bool terrainCollision(Vector2 nextLocation, Map terrain)
        {
            Matrix playerMat = Matrix.CreateTranslation(nextLocation.X, nextLocation.Y, 0);
            Matrix terrainMat = Matrix.CreateTranslation((terrain.getDisplayRectangle().X * -1), (terrain.getDisplayRectangle().Y * -1), 0) * Matrix.CreateTranslation(terrain.getDisplayRectangle().X, terrain.getDisplayRectangle().Y, 0);

            Vector2 collisionPoint = Helpers.TexturesCollide(playerColors, playerMat, terrainColors, terrainMat);

            if (collisionPoint.X != -1)
            {
                return true;
            }

            return false;
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: paulfysh/CriminalEmpires
        /// <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);
            device = graphics.GraphicsDevice;

            officeTexture = Content.Load<Texture2D>("OfficeTemplate");
            playerTexture = Content.Load<Texture2D>("You");
            NPCTexture = Content.Load<Texture2D>("NPC");
            font = Content.Load<SpriteFont>("Georgia");
            menuTexture = CreateRectangle(400, 400);

            screenWidth = device.PresentationParameters.BackBufferWidth;
            screenHeight = device.PresentationParameters.BackBufferHeight;

            gameOverTexture = CreateRectangle(screenWidth, screenHeight);
            alertTexture = CreateRectangle(screenWidth / 2, screenHeight / 2);

            playerObject = new Player(playerTexture, officeTexture);
            level = new Map(officeTexture, screenWidth, screenHeight, playerObject.getLocation());
            menu = new GameMenu();

            gameEvents = new RandomGameEvents(playerObject);
        }