private void move(InputHandlerComponent input) { int x = 0; int y = 0; //Get the y variable of the displacement if (input.getButton(ButtonType.up, false)) { y = -1; } else if (input.getButton(ButtonType.down, false)) { y = 1; } //Get the x variable of the displacement if (input.getButton(ButtonType.left, false)) { x = -1; } else if (input.getButton(ButtonType.right, false)) { x = 1; } //Create the displacement variable using the x and y values Vector2 displacement = new Vector2(x, y); //Modify the character vector by adding it to the displacement vector += displacement; }
public void movement(InputHandlerComponent i) { if (i.getButton("Down", false) && index < slides.Count - 1 && counter > interval) { slides[index].State = OptionState.standard; index++; slides[index].State = OptionState.highlighted; counter = 0; return; } else if (i.getButton("Down", false) && (index == slides.Count - 1) && (counter > interval)) { slides[index].State = OptionState.standard; index++; option.State = OptionState.highlighted; counter = 0; return; } else if (i.getButton("Up", false) && (index == slides.Count) && (counter > interval)) { option.State = OptionState.standard; index--; slides[index].State = OptionState.highlighted; counter = 0; return; } else if (i.getButton("Up", false) && index > 0 && counter > interval) { slides[index].State = OptionState.standard; index--; slides[index].State = OptionState.highlighted; counter = 0; return; } }
public void movement(InputHandlerComponent i) { if (i.getButton("Down", false) && index < options.Count - 1 && counter > interval) { //If the index has progressed past the number of options displayed, progress the list if (index + 1 >= bottom) { top++; bottom++; } options[index].State = OptionState.standard; options[++index].State = OptionState.highlighted; counter = 0; return; } else if (i.getButton("Up", false) && index > 0 && counter > interval) { if (index <= top) { top--; bottom--; } options[index].State = OptionState.standard; options[--index].State = OptionState.highlighted; counter = 0; return; } }
public override void movement(InputHandlerComponent input) { if (input.getButton(ButtonType.b, true)) { PlayPause(this, new EventArgs()); } if (input.getButton(ButtonType.left, true)) { GetPrevious(this, new EventArgs()); } if (input.getButton(ButtonType.right, true)) { GetNext(this, new EventArgs()); } if (input.getButton(ButtonType.up, true)) { MediaPlayer.Volume += 0.1f; } if (input.getButton(ButtonType.down, true)) { MediaPlayer.Volume -= 0.1f; } base.movement(input); }
public override void movement(InputHandlerComponent input) { if (input.getButton(ButtonType.down, false) && (Position != options.Count) && (Counter > 10) && (CurrentSong != playlist.Count - 1)) { options[Position].Highlight = false; if (Position == ItemNumber - 1) { CurrentSong++; getItemsDown(); Position = 0; } else { if (options[Position + 1] != null) { CurrentSong++; Position++; } else { return; } } options[Position].Highlight = true; Counter = 0; return; } else if (input.getButton(ButtonType.up, false) && (CurrentSong != 0) && (Counter > 10)) { options[Position].Highlight = false; if (Position == 0) { if (CurrentSong != 0) { CurrentSong--; getItemsUp(); Position = ItemNumber - 1; } } else { if (options[Position - 1] != null) { CurrentSong--; Position--; } else { return; } } options[Position].Highlight = true; Counter = 0; return; } }
public /*override*/ void movement(InputHandlerComponent i) { if (i.getButton("Left", true) && !left.selected && !right.selected && level > 1) { level--; left.selected = true; } if (i.getButton("Right", true) && !left.selected && !right.selected && level < levelMax) { level++; right.selected = true; } }
public void select(InputHandlerComponent i) { if (i.getButton("Select", true)) { Selected(this, new EventArgs()); } }
public static void back(InputHandlerComponent i, SystemType system, Stack <string> stack) { if (i.getButton("Back", true) && system != null) { stack.Pop(); } }
/// <summary> /// The main game update loop. /// </summary> void playingGame() { //If the game has been started, run the normal loop if (started) { //Update the level level.update(input, score); //Play a squeak at a random interval randomSqueak(); //If the pause button is pressed, call the menu pause method menus.pause(); } //Else run the start message update loop else { //If the start button is pressed, start the game if (input.getButton("Play/Pause", true)) { started = true; if (!initialized) { resetLevel(); } } } }
public override void update(GameTime gameTime, InputHandlerComponent input, Vector2 moveVector) { vector = moveVector; if (input.getButton(ButtonType.b, true)) { reload(); } if (input.getButton(ButtonType.a, true)) { shoot(gameTime); } bullet.update(gameTime, vector); }
public void scroll(InputHandlerComponent i) { if (i.getButton("Left", true) && leftState != "None") { if (leftState != "None") { Scroll(this, new DirectionArgs(Direction.left)); } } else if (i.getButton("Right", true) && rightState != "None") { if (rightState != "None") { Scroll(this, new DirectionArgs(Direction.right)); } } }
public void update(GameTime gameTime, InputHandlerComponent input, Vector2 moveVector) { currentWeapon.update(gameTime, input, moveVector); if (input.getButton(ButtonType.back, true)) { swap(moveVector); } }
public override void update(GameTime gameTime, InputHandlerComponent input, Vector2 moveVector) { vector = moveVector; bullet.update(gameTime, moveVector); if (input.getButton(ButtonType.b, true)) { reload(); } if (input.getButton(ButtonType.a, false)) { shoot(gameTime); } else if (input.getReleased(ButtonType.a, true)) { bullet.deactivate(); } }
public override void select(InputHandlerComponent i, ref string state) { if (i.getButton("Select", true)) { if (Selected != null) { Text = "Press any key"; Selected(this, new EventArgs()); } } }
public virtual void select(InputHandlerComponent i, ref string state) { if (i.getButton("Select", true)) { if (Selected != null) { Selected(this, new EventArgs()); } state = menuLink; } }
/// <summary> /// Checks to see if the user has pressed the back button, and if so, raises the Back event and resets the menu data. /// </summary> /// <param name="i">The game's menu input handler.</param> public virtual void back(InputHandlerComponent i) { if (i.getButton("Back", true)) { if (Back != null) { Back(this, new EventArgs()); } reset(); } }
public void update(InputHandlerComponent i) { arrows.update(i); if (i.getButton("Select", true)) { if (Selected != null) { Selected(this, new EventArgs()); } } }
public void movement(InputHandlerComponent i) { if (i.getButton("Left", false) && number > minimum) { number--; if (slider != null) { slider.move(number, maximum); } } if (i.getButton("Right", false) && number < maximum) { number++; if (slider != null) { slider.move(number, maximum); } } }
/// <summary> /// Turns the snake based on the input from the user. /// </summary> /// <param name="i">The game's input handler</param> private void turn(InputHandlerComponent i) { //The new orientation of the snake OrientationType newOrientation = head.Orientation; //Get the new orientation based on the input if (i.getButton("Right", true) && head.Orientation != OrientationType.left) { newOrientation = OrientationType.right; } else if (i.getButton("Up", true) && head.Orientation != OrientationType.down) { newOrientation = OrientationType.up; } else if (i.getButton("Down", true) && head.Orientation != OrientationType.up) { newOrientation = OrientationType.down; } else if (i.getButton("Left", true) && head.Orientation != OrientationType.right) { newOrientation = OrientationType.left; } //If there has been a change in the orientation, add a curve and change the snake if (newOrientation != head.Orientation) { CurveType curve = new CurveType(); curve.deepCopy(temp); curve.Vector = head.Vector; curve.Orientation = newOrientation; curve.Rotation = MovementFunctions.calculateCurveRotation(head.Orientation, newOrientation); curves.Add(curve.Vector, curve); head.Orientation = newOrientation; canTurn = false; } }
public void update(InputHandlerComponent i) { ArrowDirection direction = ArrowDirection.left; foreach (ArrowType arrow in arrows.Values) { arrow.update(); } if (i.getButton("Left", true)) { direction = ArrowDirection.left; } else if (i.getButton("Right", true)) { direction = ArrowDirection.right; } else if (i.getButton("Up", true)) { direction = ArrowDirection.up; } else if (i.getButton("Down", true)) { direction = ArrowDirection.down; } else { return; } try { getArrow(direction).press(); } catch { } }
/// <summary> /// This function sets the menu component to display the paused menu. This can be hooked into the main game /// in order to pause it and access any menus attached to the pause menu. /// </summary> /// <returns>Returns a bool value indicating whether the menus have been paused</returns> public bool pause() { if (input.getButton("Back", true)) { transitionManager.runTransition(TransitionState.intro, "Paused", getMenu("Paused").Queue); gameStack.Push("Paused"); if (Pause != null) { Pause(this, new EventArgs()); } return(true); } else { return(false); } }
//This region contains code for the Update and Draw methods for playing the game. #region Playing Game Data void playingGame(GameTime gameTime) { setPreview(); if (setNormalbool) { setNormal(); } if (dropCounter == dropTime) { setCoordinates(); blockDrop(); dropCounter = 0; } if (dropCounter > dropTime) { dropCounter = 0; } if (input.getButton(ButtonType.a, true) && rotation) { setCoordinates(); blockRotation(); if (playSound) { bloop.Play(); } } if (input.getButton(ButtonType.down, false) && accelCounter == 5) { setCoordinates(); accelDrop(); accelCounter = 0; } if (accelCounter > 5) { accelCounter = 0; } if (movementCounter == sensitivity) { setCoordinates(); blockMovement(); movementCounter = 0; } setCoordinates(); setNormalbool = false; rotation = true; update(gameTime); if (input.getButton(ButtonType.back, true)) { enableMenus(true); menus.Current = "Paused"; rotation = false; } }
public override void movement(InputHandlerComponent input) { if (!activeSubMenu) { if (input.getButton(ButtonType.down, false) && (Position != options.Count) && (Counter > 10) && MediaLibraryFunctions.canMoveDown(State, mediaLibrary, index)) { options[Position].Highlight = false; if (Position == itemNumber - 1) { index++; getItemsDown(); Position = 0; } else { if (options[Position + 1] != null) { index++; Position++; } else { return; } } options[Position].Highlight = true; Counter = 0; return; } else if (input.getButton(ButtonType.up, false) && (index != 0) && (Counter > 10)) { options[Position].Highlight = false; if (Position == 0) { if (index != 0) { index--; getItemsUp(); Position = itemNumber - 1; } } else { if (options[Position - 1] != null) { index--; Position--; } else { return; } } options[Position].Highlight = true; Counter = 0; return; } } else { subMenu.movement(input); } }