/// <summary> /// The update for the cooldown bar, goes down if shooting, rises if not shooting /// </summary> /// <param name="gameTime">used to track time</param> /// <param name="player">passes which player the bar refers to, in case more players are made later in development(e.g. multiplayer)</param> public void Update(GameTime gameTime, Player player) { KeyboardState state = Keyboard.GetState(); if (state.IsKeyDown(Keys.Space) ) { if (length > -1) length -= (float)gameTime.ElapsedGameTime.TotalSeconds * 15; //down as far as 0 if (length > 1) player.Shoot(); //if space player shoots only if over 1 left } else { if(length < 200 ) length += (float)gameTime.ElapsedGameTime.TotalSeconds*20; } }
/// <summary> /// The update for the cooldown bar, goes down if shooting, rises if not shooting /// </summary> /// <param name="gameTime">used to track time</param> /// <param name="player">passes which player the bar refers to, in case more players are made later in development(e.g. multiplayer)</param> public void Update(GameTime gameTime, Player player) { KeyboardState state = Keyboard.GetState(); if (state.IsKeyDown(Keys.Space)) { if (length > -1) { length -= (float)gameTime.ElapsedGameTime.TotalSeconds * 15; //down as far as 0 } if (length > 1) { player.Shoot(); //if space player shoots only if over 1 left } } else { if (length < 200) { length += (float)gameTime.ElapsedGameTime.TotalSeconds * 20; } } }