Package net.shadewind.racetrack

Examples of net.shadewind.racetrack.Vector2i


    game.start(this, mapId, enableCollisions);
  }
 
  private void processDrive(Command command) throws RacetrackException
  {
    game.drive(this, new Vector2i(
        command.intArgument(0),
        command.intArgument(1)));
  }
View Full Code Here


  }
 
  private void checkCrash(Client client)
  {
    Car car = cars.get(client);
    Vector2i position = car.getPosition();
    if (map.getBlockType(position.x(), position.y()) == '#') {
      deactivateClient(client);
      car.setCrashed(true);
      for (Client c : clients)
        c.carCrashed(client.getId());
    }
View Full Code Here

    int dx = Math.abs(start.x() - end.x());
    int stepX = (start.x() < end.x()) ? 1 : -1;
    double stepY = (double)(end.y() - start.y()) / dx;
    double y = start.y();
    for (int x = start.x(); x != end.x(); x += stepX) {
      line.add(new Vector2i(x, (int)Math.round(y)));
      y += stepY;
    }
   
    return line;
  }
View Full Code Here

    int dy = Math.abs(start.y() - end.y());
    int stepY = (start.y() < end.y()) ? 1 : -1;
    double stepX = (double)(end.x() - start.x()) / dy;
    double x = start.x();
    for (int y = start.y(); y != end.y(); y += stepY) {
      line.add(new Vector2i((int)Math.round(x), y));
      x += stepX;
    }
   
    return line;
  }
View Full Code Here

      c.playerTurn(client.getId(), TIMEOUT);
   
    //Timeout timer
    timeoutTask = new TimerTask() {
      @Override
      public void run() { drive(client, new Vector2i(0, 0)); }
    };
    timer.schedule(timeoutTask, TIMEOUT * 1000);
  }
 
View Full Code Here

   *
   * @return The acceleration.
   */
  public Vector2i getAcceleration()
  {
    return new Vector2i(acceleratorX, acceleratorY);
  }
View Full Code Here

  private void paintAcceleratorControls(Graphics2D g)
  {
    Player player = client.getPlayer();
    Car car = player.getCar();
    Vector2i pos = car.getPosition();
    if (pos == null)
      return;
   
    double originX = pos.x() + 0.5;
    double originY = pos.y() + 0.5;
    for (int y = -1; y <= 1; y++) {
      for (int x = -1; x <= 1; x++) {
        g.setColor(Color.WHITE);
        fillCircle(originX + x, originY + y, 0.5, g);
        g.setColor(Color.BLACK);
View Full Code Here

     
      g.setColor(COLORS[colorIndex]);
      g.setStroke(new BasicStroke(0.1f));
     
      for (int i = 0; i < path.size(); i++) {
        Vector2i start = path.get(i);
        if (i < (path.size() - 1)) {
          Vector2i end = path.get(i + 1);
          Line2D line = new Line2D.Double(
              start.x() + 0.5, start.y() + 0.5,
              end.x() + 0.5, end.y() + 0.5);
          g.draw(line);
          fillCircle(start.x() + 0.5, start.y() + 0.5, 0.2, g);
        } else {
          fillCircle(start.x() + 0.5, start.y() + 0.5, 0.5, g);
        }
View Full Code Here

    Player player = players.get(playerId);
    if (player == null)
      throw new CommException("Unknown player id = " + playerId);
    Car car = player.getCar();
    car.reset();
    car.pushPosition(new Vector2i(
        command.intArgument(1),
        command.intArgument(2)));
    listener.carReset(player);
  }
View Full Code Here

    Player player = players.get(command.intArgument(0));
    if (player == null)
      throw new CommException("Player is unknown.");
   
    Car car = player.getCar();
    car.pushPosition(new Vector2i(command.intArgument(1), command.intArgument(2)));
    car.setVelocity(new Vector2i(command.intArgument(3), command.intArgument(4)));
    listener.carDriven(player);
  }
View Full Code Here

TOP

Related Classes of net.shadewind.racetrack.Vector2i

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.