/// en konstruktor som laddar in först i klassen! public BallView(GraphicsDeviceManager graphics, BallSimulation BallSimulation, ContentManager Content, Texture2D Ball, Texture2D deadBall) { ballTexture = Ball;///laddar in bollen //detta görs bara en gång! this.deadBall = deadBall; box = new Texture2D(graphics.GraphicsDevice, 1, 1);///denna skapar en box box.SetData(new Color[] { Color.Black });/// denna sätter vilken färg! camera = new Camera(graphics.GraphicsDevice.Viewport);/// skapar en ny camera instans ballSimulation = BallSimulation; }
Vector2 startposition = new Vector2(1f, 1f); // hela planen är just nu 100*100// så denna börjar i mitten 50*50 #endregion Fields #region Constructors //BallView ballview; public Explosion(SpriteBatch spritebatch, Texture2D Particle, Camera Camera, Texture2D Smoke, Texture2D BangExplosion, SoundEffect explosionSound, Texture2D CursorImage, BallSimulation bs) { timeElapsed = 0; //denna ska vara 0 när programmet startas //ballview = Ballview; //this.masterBallDead = masterBallDead; cursorImage = CursorImage; //cursorPos = CursorPosition; camera = Camera;//så jag kan använda kameran i klassen! spriteBatch = spritebatch; particle = Particle; bangExplosion = BangExplosion; smoke = Smoke; Width = particle.Width; // posFramesX; //delar explosionens bredd med positions framesen! Height = particle.Height; // posFramesY; soundEffect = explosionSound; particleSystem = new ParticleSystem(startposition); smokeSystem = new SmokeSystem(smoke, startposition, camera);//får inte denna att fungera explosionManager = new ExplosionManager(spriteBatch, BangExplosion, camera, startposition); ballSimulation = bs; }
/// <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); camera = new Camera(graphics.GraphicsDevice.Viewport); Texture2D smokee = Content.Load<Texture2D>("particlesmokee"); Texture2D spark = Content.Load<Texture2D>("spark"); Texture2D bangExplosion = Content.Load<Texture2D>("explosion"); Texture2D masterBall = Content.Load<Texture2D>("master_ball"); Texture2D masterBallDead = Content.Load<Texture2D>("master_ball_dead2"); cursorImage = Content.Load<Texture2D>("Pointer"); SoundEffect explosionSound = Content.Load<SoundEffect>("firesound"); Vector2 startPosition = new Vector2(0.5f, 0.5f); ballSimulation = new BallSimulation(); explosion = new Explosion(spriteBatch, spark, camera, smokee, bangExplosion, explosionSound, cursorImage, ballSimulation); smokeSystem = new SmokeSystem(smokee, startPosition, camera); ballview = new BallView(graphics, ballSimulation, Content, masterBall, masterBallDead); // TODO: use this.Content to load your game content here }