Android Open Source - Slime-Volleyball-for-Android A I






From Project

Back to project page Slime-Volleyball-for-Android.

License

The source code is released under:

Copyright (c) 2011 Philip Bjorge Permission is hereby granted, free of charge, to any person obtaining a copy of this hardware, software, and associated documentation files (the "Product"), to deal i...

If you think the Android project Slime-Volleyball-for-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.philipbjorge;
//from w w  w. jav a2  s .  c o  m
import android.graphics.PointF;

public class AI {
  PointF ball;
  PointF self;
  int half;
  
  public AI(int half, PointF ballPos, PointF self) {
    ball =  ballPos;
    this.self = self;
    this.half = half;
  }
  
  public void update(PointF b, PointF s) {
    ball = b;
    self = s;
  }
  
  public char move() {
    // return left,right,up,upleft=q,upright=p
    if(ball.x >= self.x) {
      if(ball.y < self.y-55)
        return 'p';
      else
        return 'r';
    } else if (ball.x >= half){
      if(ball.y < self.y-55)
        return 'q';
      else
        return 'l';
    } else {
      if(self.x < 1.3*half)
        return 'r';
      else if(self.x > 1.7*half)
        return 'l';
      else
        return 'u';
    }
  }
}




Java Source Code List

com.philipbjorge.AI.java
com.philipbjorge.AnimatedSprite.java
com.philipbjorge.GameThread.java
com.philipbjorge.GameView.java
com.philipbjorge.Game.java
com.philipbjorge.Match.java
com.philipbjorge.PhysicsEngine.java
com.philipbjorge.RigidBody.java
com.philipbjorge.Settings.java
com.philipbjorge.SlimeVolleyball.java