Keeps track of the world that the user builds.
Inheritance: Microsoft.Xna.Framework.DrawableGameComponent
コード例 #1
0
ファイル: SpriteManager.cs プロジェクト: alexcoco/trace_racer
        public SpriteManager(Game game, Vector2 touchPosition, Boolean isPressed, WorldObject world, ParticleEngine part)
            : base(game)
        {
            this.touchPosition = touchPosition;
            this.isPressed = isPressed;
            this.world = world;

            this.spriteBatch = new SpriteBatch(game.GraphicsDevice);
            this.part = part;

            if (content == null)
                content = new ContentManager(Game.Services, "Content");

            mainFont = content.Load<SpriteFont>("mainFont");
            touchTexture = content.Load<Texture2D>("sprites/touch");
            tileGrass = content.Load<Texture2D>("tiles/WorldLineTexture");
            gameOverlay = content.Load<Texture2D>("bg/gameOver");
            background = content.Load<Texture2D>("bg/background_gradient");
            parallax = content.Load<Texture2D>("bg/parallax_layer_cont");
            gatekeeper = content.Load<Texture2D>("gates/gatekeeper");

            tree2 = content.Load<Texture2D>("sprites/tree2");
            tree3 = content.Load<Texture2D>("sprites/tree3");
            tree4 = content.Load<Texture2D>("sprites/tree4");
        }
コード例 #2
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                    content = new ContentManager(ScreenManager.Game.Services, "Content");

                List<Texture2D> textures = new List<Texture2D>();
                textures.Add(content.Load<Texture2D>("tex/star"));
                part = new ParticleEngine(textures, new Vector2(400, 240));

                world = new WorldObject(ScreenManager.Game, ScreenManager.SpriteBatch);

                // create worldline queue
                for (int i = 0; i < 800; i++)
                {
                    world.addLine(-1);
                }

                spriteManager = new SpriteManager(ScreenManager.Game, touchPosition, isPressed, world, part);
                ScreenManager.Game.Components.Add(spriteManager);
                Thread.Sleep(1000);

                ScreenManager.Game.ResetElapsedTime();
            }

#if WINDOWS_PHONE
            if (Microsoft.Phone.Shell.PhoneApplicationService.Current.State.ContainsKey("PlayerPosition"))
            {
                // playerPosition = (Vector2)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["PlayerPosition"];
                // enemyPosition = (Vector2)Microsoft.Phone.Shell.PhoneApplicationService.Current.State["EnemyPosition"];
            }
        }
コード例 #3
0
ファイル: PlayerObject.cs プロジェクト: alexcoco/trace_racer
        /// <summary>
        /// Constructor initializes everything.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="world"></param>
        public PlayerObject(Game game, SpriteBatch givenSpriteBatch, WorldObject world)
            : base(game)
        {
            World = world;
            mySpriteBatch = givenSpriteBatch;

            IsAlive = false;
            Texture = Game.Content.Load<Texture2D>("bike");

            Speed = new Vector2(Constants.NORMAL_SPEED, 0);
            Score = new TraceRacer.Score(game);
            //Position = new Vector2(Speed.X, -Texture.Height);
            Position = new Vector2(100, -Texture.Height);
            CurrentLine = world.getLine((int)Position.X);
        }
コード例 #4
0
ファイル: SpriteManager.cs プロジェクト: alexcoco/trace_racer
        private void drawPlayer(WorldObject world)
        {
            float rotationAngle;
            Vector2 origin;

            //spriteBatch.Draw(Texture, Position, Color.White);

            int difference = world.getPositionDifference();
            if (difference > 0)
            {
                // decel - bring to min
                rotationAngle = Constants.ROTATION_ANGLE_DOWN;
                origin = new Vector2(0, 0);
            }
            else if (world.player.airtime > 14)
            {
                // accel - bring to max
                rotationAngle = Constants.ROTATION_ANGLE_UP;
                origin = new Vector2(100, 10);
            }
            else
            {
                // flat - bring to normal speed
                rotationAngle = Constants.ROTATION_ANGLE_NORMAL;
                origin = new Vector2(40, -10);
            }

            spriteBatch.Draw(world.player.Texture, world.player.Position, null, Color.White, rotationAngle, origin, 1f, SpriteEffects.None, 0);
        }