コード例 #1
0
        public void Draw(SpriteBatch spriteBatch)
        {
#if VISUAL_DEBUG
            VisualDebugging.DrawRectangle(spriteBatch, Bounds, Color.White);
#endif
            frames[currentFrame].Draw(spriteBatch, Position, color, 0, origin, 2, spriteEffects, 1);
        }
コード例 #2
0
        /// <summary>
        /// Draws the player sprite
        /// </summary>
        /// <param name="spriteBatch"></param>
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            // Render the santa
#if VISUAL_DEBUG
            VisualDebugging.DrawRectangle(spriteBatch, Bounds, Color.Red);
#endif
            spriteBatch.Draw(spritesheet[frameNumber], Position, sourceRect, Color.White, angle, origin, 0.3f, effects, 0.7f);
        }
コード例 #3
0
ファイル: Barrier.cs プロジェクト: Khyvvr/cis580-proj3
        /// <summary>
        /// Draws the platform
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch to render to</param>
        public void Draw(SpriteBatch spriteBatch)
        {
#if VISUAL_DEBUG
            VisualDebugging.DrawRectangle(spriteBatch, bounds, Color.Green);
#endif
            for (int i = 0; i < tileCount; i++)
            {
                sprite.Draw(spriteBatch, new Vector2(bounds.X + i * sprite.GetWidth(), bounds.Y), Color.White);
            }
        }
コード例 #4
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);

#if VISUAL_DEBUG
            VisualDebugging.LoadContent(Content);
#endif

            // Load and play music
            if (isFirstRun)
            {
                indianaJonesMusic = Content.Load <SoundEffect>("Indiana Jones");
                indianaJonesMusic.Play();
                isFirstRun = false;
            }


            // Load font
            font = Content.Load <SpriteFont>("font");

            // Background
            backgroundTexture = Content.Load <Texture2D>("Background-3584");

            // Player
            Texture2D[] playerTextures = new Texture2D[10];
            for (int i = 0; i < 10; i++)
            {
                playerTextures[i] = Content.Load <Texture2D>("Jump__00" + i);
            }
            player = new Player(playerTextures);

            // Arrow
            arrow = new Arrow(player);
            arrow.LoadContent(Content);

            // Platforms
            Texture2D pixel = Content.Load <Texture2D>("sand");
            pix = new Sprite(new Rectangle(0, 0, 100, 25), pixel);
            platforms.Add(new Platform(new BoundingRectangle(-100, 999, 1000, 25), pix));

            // Add the platforms to the axis list
            world = new AxisList();
            foreach (Platform platform in platforms)
            {
                world.AddGameObject(platform);
            }

            //Spider
            spider.LoadContent(Content);
            //Bat
            bat.LoadContent(Content);

            world.SpawnNewPlatforms(player, random, pix, platforms);
        }
コード例 #5
0
ファイル: Game1.cs プロジェクト: Khyvvr/cis580-proj3
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
#if VISUAL_DEBUG
            VisualDebugging.LoadContent(Content);
#endif
            // 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
            background = Content.Load <Texture2D>("background");
            ast        = Content.Load <Texture2D>("asteriodbarrier");
            var gTexture = Content.Load <Texture2D>("gimpMasterSchwag");
            var oTexture = Content.Load <Texture2D>("evilOlive");

            gimp  = new SpriteSheet(gTexture, 87, 87, 8, 17);
            olive = new SpriteSheet(oTexture, 87, 87, 20, 25);

            var gimpFrames  = from index in Enumerable.Range(0, 2) select gimp[index];
            var oliveFrames = from index in Enumerable.Range(0, 2) select olive[index];

            player = new Player(gimpFrames);
            olive1 = new Olive(oliveFrames);
            olive2 = new Olive(oliveFrames);
            olive3 = new Olive(oliveFrames);
            olive4 = new Olive(oliveFrames);
            olive5 = new Olive(oliveFrames);

            //create asteroid barrier here:
            barriers.Add(new Barrier(new BoundingRectangle(200, 75, 400, 125), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(50, 200, 50, 400), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(700, 200, 50, 400), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(350, 300, 100, 200), asteroid));
            barriers.Add(new Barrier(new BoundingRectangle(200, 600, 400, 125), asteroid));

            world = new AxisList();
            foreach (Barrier barrier in barriers)
            {
                world.AddGameObject(barrier);
            }
        }
コード例 #6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
#if Debug
            VisualDebugging.LoadContent(Content);
#endif
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //load in spritefont
            spriteFont = Content.Load <SpriteFont>("File");

            // TODO: use this.Content to load your game content here
            var t = Content.Load <Texture2D>("spritesheet");
            sheet = new SpriteSheet(t, 21, 21, 1, 2);

            // Create the player with the corresponding frames from the spritesheet
            var playerFrames = from index in Enumerable.Range(139, 150) select sheet[index]; //19 is the 0 in player currentFrame
            player = new Player(playerFrames);

            // Create the platforms //platforms will randomly not register any collision with player, reasoning is unknown
            platforms.Add(new Platform(new BoundingRectangle(1, 980, 1600, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1, 900, 800, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(920, 860, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1020, 800, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(920, 770, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1050, 700, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1200, 650, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1250, 600, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1300, 550, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1350, 500, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1450, 450, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1500, 400, 42, 20), sheet[121]));
            platforms.Add(new Platform(new BoundingRectangle(1550, 350, 42, 20), sheet[121]));

            Alist = new AxisList();
            foreach (Platform platform in platforms)
            {
                Alist.AddGameObject(platform);
            }

            //ghosts buggy, explained in draw commented out section
            var GhostFrames = from index in Enumerable.Range(445, 449) select sheet[index];
            ghost1 = new GhostEnemy(GhostFrames, player);

            ghost2          = new GhostEnemy(GhostFrames, player);
            ghost2.Position = new Vector2(100, 700);

            ghost3          = new GhostEnemy(GhostFrames, player);
            ghost3.Position = new Vector2(200, 800);

            ghost4          = new GhostEnemy(GhostFrames, player);
            ghost4.Position = new Vector2(1500, 550);

            ghost5          = new GhostEnemy(GhostFrames, player);
            ghost5.Position = new Vector2(550, 900);

            ghost6          = new GhostEnemy(GhostFrames, player);
            ghost6.Position = new Vector2(900, 950);

            ghost7          = new GhostEnemy(GhostFrames, player);
            ghost7.Position = new Vector2(200, 400);

            ghost8          = new GhostEnemy(GhostFrames, player);
            ghost8.Position = new Vector2(1200, 600);

            ghost9          = new GhostEnemy(GhostFrames, player);
            ghost9.Position = new Vector2(800, 400);
        }