Exemple #1
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
            grass    = Content.Load <Texture2D>("grass");
            broccoli = new SpriteClass(GraphicsDevice, "Content/broccoli.png", ScaleToHighDPI(0.2f));
            dino     = new SpriteClass(GraphicsDevice, "Content/ninja-cat-dino.png", ScaleToHighDPI(1f));

            startGameSplash = Content.Load <Texture2D>("start-splash");
            scoreFont       = Content.Load <SpriteFont>("Score");
            stateFont       = Content.Load <SpriteFont>("GameState");
            gameOverTexture = Content.Load <Texture2D>("game-over");
        }
Exemple #2
0
        // Load content (eg.sprite textures) before the app runs
        // Called once when the app is started
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load textures
            grass           = Content.Load <Texture2D>("grass");
            startGameSplash = Content.Load <Texture2D>("start-splash");
            gameOverTexture = Content.Load <Texture2D>("game-over");

            // Construct SpriteClass objects
            dino     = new SpriteClass(GraphicsDevice, "Content/ninja-cat-dino.png", ScaleToHighDPI(1f));
            broccoli = new SpriteClass(GraphicsDevice, "Content/broccoli.png", ScaleToHighDPI(0.2f));

            // Load fonts
            scoreFont = Content.Load <SpriteFont>("Score");
            stateFont = Content.Load <SpriteFont>("GameState");
        }
Exemple #3
0
 // Detect collision between two rectangular sprites
 public bool RectangleCollision(SpriteClass otherSprite)
 {
     if (this.x + this.texture.Width * this.scale * HITBOXSCALE / 2 < otherSprite.x - otherSprite.texture.Width * otherSprite.scale / 2)
     {
         return(false);
     }
     if (this.y + this.texture.Height * this.scale * HITBOXSCALE / 2 < otherSprite.y - otherSprite.texture.Height * otherSprite.scale / 2)
     {
         return(false);
     }
     if (this.x - this.texture.Width * this.scale * HITBOXSCALE / 2 > otherSprite.x + otherSprite.texture.Width * otherSprite.scale / 2)
     {
         return(false);
     }
     if (this.y - this.texture.Height * this.scale * HITBOXSCALE / 2 > otherSprite.y + otherSprite.texture.Height * otherSprite.scale / 2)
     {
         return(false);
     }
     return(true);
 }