public Startview(ContentManager _content, Camera _camera, SpriteBatch _spritebatch,BallSimulation _ballsim,GraphicsDeviceManager _graphics) { content = _content; camera = _camera; spritebatch = _spritebatch; ballsim = _ballsim; graphics = _graphics; fieldsize = camera.ReturnFieldsize(); bordersize = camera.ReturnBorder(); rect = new Rectangle(bordersize, bordersize, fieldsize, fieldsize); splittertexture = content.Load<Texture2D>("spark"); smoketexture = content.Load<Texture2D>("smoke"); explosiontexture = content.Load<Texture2D>("explosion"); shockwavetexture = content.Load<Texture2D>("Shockwave"); balltexture = content.Load<Texture2D>("BALL"); deadball = content.Load<Texture2D>("Deadball"); crosshair = content.Load<Texture2D>("Crosshair"); firesound = content.Load<SoundEffect>("fire"); ballcenter = new Vector2(balltexture.Width / 2, balltexture.Height / 2); background = new Texture2D(graphics.GraphicsDevice, 1, 1); background.SetData(new Color[] { Color.Black }); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { camera.SetFieldSize(graphics.GraphicsDevice.Viewport); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ballsim = new BallSimulation(); //explosionview = new Applicationview(Content, camera, spriteBatch); startview = new Startview(Content, camera, spriteBatch,ballsim,graphics); // TODO: use this.Content to load your game content here }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.R)) { ballsim = new BallSimulation(); //explosionview = new Applicationview(Content, camera, spriteBatch); startview = new Startview(Content, camera, spriteBatch, ballsim, graphics); } var currentmouse = Mouse.GetState(); if (lastmouseclick.LeftButton == ButtonState.Released && currentmouse.LeftButton == ButtonState.Pressed) { startview.CreateExplosion(currentmouse.X, currentmouse.Y, spriteBatch); } lastmouseclick = currentmouse; ballsim.UpdateBall((float)gameTime.ElapsedGameTime.TotalSeconds); base.Update(gameTime); }