/// <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); }
/// <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 }
public void LoadContent(SpriteBatch _spritebatch, ContentManager _content, Camera _camera) { spriteBatch = _spritebatch; Content = _content; camera = _camera; ballsim = new BallSimulation(); playersim = new Playersimulation(); drawmap = new Drawmap(); lvlone = new LevelOne(); startview = new Startview(Content, camera, spriteBatch, ballsim, playersim, drawmap, graphics); //Loads the map once when the application starts. Will use update function to call a function in drawmap that allows me to place new tiles.. map = lvlone.getmap(); textures = startview.ReturnedTextures(); drawmap.Drawlevel(map, textures, spriteBatch, camera); }