Package pl.edu.pw.elka.mmarkiew.controller.queueevents.ViewKeyPress

Examples of pl.edu.pw.elka.mmarkiew.controller.queueevents.ViewKeyPress.Keys


    final boolean xVelocity = (player.getXVelocity() != 0);
    final boolean yVelocity = (player.getYVelocity() != 0);
   
    if (event instanceof ViewKeyPress)
    {
      final Keys code = ((ViewKeyPress) event).getKey();
      final boolean pressed = ((ViewKeyPress) event).isPress();
     
      switch (code)
      {        //set velocity only if it's needed to set it, and reset it the same
        case UP:  if (pressed && !yVelocity)
              {
                player.setYVelocity(-player.getMaxVelocity());
              }
              else if (!pressed && yVelocity)
              {
                player.setYVelocity(0);
              }
              break;
        case DOWN:  if (pressed && !yVelocity)
              {
                player.setYVelocity(player.getMaxVelocity());
              }
              else if (!pressed && yVelocity)
              {
                player.setYVelocity(0);
              }
              break;
        case LEFT:  if (pressed && !xVelocity)
              {
                player.setXVelocity(-player.getMaxVelocity());
              }
              else if (!pressed && xVelocity)
              {
                player.setXVelocity(0);
              }
              break;
        case RIGHT:  if (pressed && !xVelocity)
              {
                player.setXVelocity(player.getMaxVelocity());
              }
              else if (!pressed && xVelocity)
              {
                player.setXVelocity(0);
              }
              break;
        case PLANT:  if (pressed)
              {
                model.plantBomb();
              }
              break;
        case TIMER_1:
        case TIMER_2:
        case TIMER_3:  if (pressed)
                {
                  // depends on the number of timer enum, sets appropriate number of seconds
                  player.setBombTimer( (code.ordinal() - Keys.TIMER_1.ordinal() + 1) * 1000 );
                }
                break;
        case PAUSE:  if (pressed)
              {
                model.switchPause();
View Full Code Here

TOP

Related Classes of pl.edu.pw.elka.mmarkiew.controller.queueevents.ViewKeyPress.Keys

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.