Example #1
0
 public void Initialize(GameContent gameContent, string textureName, Animation animation, Vector2 position)
 {
     this.laserAnime   = animation;
     this.position     = position;
     this.active       = true;
     this.laserTexture = gameContent.getTexture(textureName);
 }
        public void Initialize(Vector2 screenSize, float speed, GameContent gameContent, string parallaxName, int scale, bool isRnd = false)
        {
            this.screenSize = screenSize;
            this.speed      = speed;
            this.scale      = scale;
            this.texture    = gameContent.getTexture(parallaxName);
            this.positions  = new Vector2[(int)screenSize.X / texture.Width + 1];
            this.isRnd      = isRnd;

            rnd = new Random();

            for (int i = 0; i < positions.Length; ++i)
            {
                int randY = rnd.Next(0, (int)screenSize.Y);
                positions[i] = new Vector2(i * texture.Width, randY);
            }
        }
Example #3
0
        public void Initialize(GameContent gameContent, string textureName, Vector2 position, int frameWidth, int frameHeight, int frameCount, int frametime, Color color,
                               float scale, bool looping)
        {
            this.color       = color;
            this.frameWidth  = frameWidth;
            this.frameHeight = frameHeight;
            this.frameCount  = frameCount;
            this.frametime   = frametime;
            this.scale       = scale;

            this.looping  = looping;
            this.position = position;
            this.texture  = gameContent.getTexture(textureName);

            this.elapsedTime  = 0;
            this.currentFrame = 0;

            this.active = true;
        }
Example #4
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            gameContent = new GameContent(Content);

            Animation playerAnimation = new Animation();

            playerAnimation.Initialize(gameContent, "PlaneSheet", Vector2.Zero, 128, 128, 3, 20, Color.White, 1f, true);

            Vector2 playerPosition = new Vector2(128, GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition, gameContent);

            mainBg     = gameContent.getTexture("parallax-Background");
            mainBgRect = new Rectangle(0, 0, 1280, 720);

            p1.Initialize(1, 30, gameContent, "parallax-BigPlanet", 1);
            p2.Initialize(new Vector2(1280, 720), -50, gameContent, "parallax-SpaceStars", 2);
            p2.InitRnd(1, 2);
        }