/// <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); }