Ejemplo n.º 1
0
 // draw the particleExplosion
 public void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D particleTexture)
 {
     for (int i = 0; i < numberOfParticles; i++)
     {
         particles[i].Draw(spriteBatch, camera, particleTexture);
     }
 }
Ejemplo n.º 2
0
        public void Draw(SpriteBatch spriteBatch, Camera cam, float elapsedTime)
        {
            frameCount++;

            if (frameCount <= 32)
            {

                goneTime += elapsedTime;
                if (goneTime > explosionTime)
                {
                    goneTime = 0;
                }
                float animatedTime = goneTime / explosionTime;

                frame = (int)(animatedTime * numberOfFrames);
                frameX = frame % xframes;
                frameY = frame / xframes;

                spriteBatch.Begin();
                spriteBatch.Draw(explosionTexture, camera.getScreenCord(currentPos),
                new Rectangle((int)(expWidth * frameX), (int)(expHeight * frameY), (int)expWidth, (int)expHeight),
                Color.White, 0, new Vector2(expWidth / 2, expHeight / 2), scale, SpriteEffects.None, 0);
                spriteBatch.End();

            }
        }
Ejemplo n.º 3
0
 //construct
 public SmokeView(SpriteBatch Sprite, Camera camera2, Texture2D particleTexture2)
 {
     spriteBatch = Sprite;
     particleTexture = particleTexture2;
     camera = camera2;
     durationTime = 0;
     systems = new List<ParticleSystem<SmokeParticle>>();
 }
Ejemplo n.º 4
0
 public GameView(SpriteBatch Sprite, Camera camera2, Texture2D particleTexture2)
 {
     spriteBatch = Sprite;
     particleTexture = particleTexture2;
     camera = camera2;
     durationTime = 0;
     createParticle();
 }
Ejemplo n.º 5
0
 public ExplosionView(Camera camera, SpriteBatch spriteBatch, Vector2 explosionPosition, Texture2D explosionTexture)
 {
     this.camera = camera;
     this.spriteBatch = spriteBatch;
     this.explosionPosition = explosionPosition;
     this._explosionTexture = explosionTexture;
     explosion = new Explosion(_explosionTexture, spriteBatch, camera, explosionPosition);
 }
Ejemplo n.º 6
0
        public Explosion(Texture2D explosionTexture, SpriteBatch sprite, Camera cam, Vector2 startPos)
        {
            this.explosionTexture = explosionTexture;
            camera = cam;
            currentPos = startPos;

            explosionTime = 1000.0f;
            expHeight = explosionTexture.Height / yframes;
            expWidth = explosionTexture.Width / xframes;

            scale = camera.getScale(expWidth, size);
        }
        /// en konstruktor som laddar in först i klassen!
        public BallView(GraphicsDeviceManager graphics, BallSimulation BallSimulation, ContentManager Content)
        {
            ball = Content.Load<Texture2D>("master_ball");///laddar in bollen //detta görs bara en gång!

            box = new Texture2D(graphics.GraphicsDevice, 1, 1);///denna skapar en box
            box.SetData<Color>(new Color[]
            {
                Color.Black
            });/// denna sätter vilken färg!

            camera = new Camera(graphics.GraphicsDevice.Viewport);/// skapar en ny camera instans
            ballSimulation = BallSimulation;
        }
Ejemplo n.º 8
0
        public void Draw(float elapsedTime, SpriteBatch spriteBatch, Camera camera, Texture2D smokeTexture)
        {
            spriteBatch.Begin();

            foreach (ParticleSystem<SmokeParticle> s in systems)
            {
                s.Update(elapsedTime);

                // draw the animation

                s.Draw(spriteBatch, camera, smokeTexture);

            }

            spriteBatch.End();
        }
Ejemplo n.º 9
0
        public void Draw(SpriteBatch spriteBatch, Camera cam, float elapsedTime)
        {
            goneTime += elapsedTime;
            if(goneTime >= explosionTime)
            {
                goneTime = 0;
            }

            float animatedTime = goneTime / explosionTime;

            frame = (int)(numberOfFrames * animatedTime);
            frameX = frame / xFrames;
            frameY = frame % yFrames;

            spriteBatch.Draw(explosionTexture, cam.getScreenCord(new Vector2(0.5f, 0.5f)),
                new Rectangle((int)(expWidth * frameX), (int)(expHeight * frameY), (int)expWidth, (int)expHeight),
                Color.White, 0, new Vector2(expWidth / 2, expHeight / 2), scale, SpriteEffects.None, 0);
        }
Ejemplo n.º 10
0
        public void Draw(SpriteBatch spriteBatch, Camera cam, float elapsedTime)
        {
            scale = cam.getScale(0.7f, explosionTexture.Bounds.Width);
            goneTime += elapsedTime;
            if (goneTime >= explosionTime)
            {
                goneTime = 2; // time between explosion
            }
            float animatedTime = goneTime / explosionTime;

            // calc for the imageAnimation
            frame = (int)(animatedTime * numberOfFrames);
            frameX = frame % xframes;
            frameY = frame / xframes;

            // draw the explosion in center
            spriteBatch.Draw(explosionTexture, cam.getScreenCord(new Vector2(1.0f, 1.0f)),
                new Rectangle((int)(expWidth * frameX), (int)(expHeight * frameY), (int)expWidth, (int)expHeight),
                Color.White, 0, new Vector2(expWidth / 2, expHeight / 2), scale, SpriteEffects.None, 0);
        }
Ejemplo n.º 11
0
 // construct
 public GameView(SpriteBatch sprite, Camera cam, Texture2D explosionTexture)
 {
     camera = cam;
     spriteBatch = sprite;
     explosion = new Explosion(explosionTexture);
 }
Ejemplo n.º 12
0
        internal void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D particleTexture)
        {
            Rectangle sparkRectangleTexture = camera.getRectangle(position, radius);

            spriteBatch.Draw(particleTexture, sparkRectangleTexture, Color.White);
        }
Ejemplo n.º 13
0
        // draw
        internal void Draw(SpriteBatch spriteBatch, Camera camera, Texture2D particleTexture)
        {
            //Rectangle sparkRectangleTexture = camera.getRectangle(position.X, position.Y);

            spriteBatch.Draw(particleTexture, camera.getScreenCord(position), null, null, null, 2, Vector2.One * camera.getScale(particleTexture.Width, 0.025f), Color.White,SpriteEffects.None, 0);
        }