# Help with java library (AI for Games)

**URL:** https://discourse.processing.org/t/help-with-java-library-ai-for-games/18039
**Category:** Libraries
**Created:** [February 23, 2020, 7:16am UTC](https://discourse.processing.org/t/help-with-java-library-ai-for-games/18039 "2020-02-23T07:16:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)
#### Post date: [February 23, 2020, 7:16am UTC](https://discourse.processing.org/t/help-with-java-library-ai-for-games/18039/1 "2020-02-23T07:16:44Z")

</div>

I found an ai library in java & thought should try it. I’m doing the tutorial, but get an error Idk how to fix.  
this is in main

```auto
import game2dai.*;
import game2dai.entities.*;
import game2dai.entityshapes.*;
import game2dai.entityshapes.ps.*;
import game2dai.fsm.*;
import game2dai.graph.*;
import game2dai.maths.*;
import game2dai.steering.*;
import game2dai.utils.*;

World world;
StopWatch sw;
Vehicle tank;
Vector2D target = new Vector2D();
BitmapPic view;

public void setup() {
  size(600, 320);
  world = new World(width, height);
  sw = new StopWatch();
  // Create the mover
  tank = new Vehicle(new Vector2D(width/2, height/2), // position
    40, // collision radius
    new Vector2D(0, 0), // velocity
    40, // maximum speed
    new Vector2D(1, 0), // heading
    15, // mass
    1.5f, // turning rate
    1000 // max force
  ); 
  // What does this mover look like
//here where I get the error
  view = new BitmapPic(this, "tanks.png", 8, 1, 0);    
  view.showHints(Hints.HINT_COLLISION | Hints.HINT_HEADING | Hints.HINT_VELOCITY);
  tank.renderer(view);
  // Finally we want to add this to our game domain
  world.add(tank);
  sw.reset();
}

public void draw() {
  double elapsedTime = sw.getElapsedTime();
  target.set(mouseX, mouseY);
  tank.AP().arriveOn(target);
  float speed = (float) tank.speed();
  float maxSpeed = (float) tank.maxSpeed();    
  if (speed > 1) {
    float newInterval = map(speed, 0, maxSpeed, 0.6, 0.04);
    view.setAnimation(newInterval, 1);
  }
  else {
    view.pauseAnimation();
  }
  world.update(elapsedTime);
  background(218, 140, 54);
  world.draw(elapsedTime);
}

```

the error is ps.BitmapPic steering test string int int int does not exist

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [February 24, 2020, 5:08pm UTC](https://discourse.processing.org/t/help-with-java-library-ai-for-games/18039/2 "2020-02-24T17:08:32Z")

</div>

> [@ctrembla](#):
>
> view = new BitmapPic(this, “tanks.png”, 8, 1, 0);

This is wrong the constructor is expecting just 2 numbers for the number of columns and rows of sprites are in the image. You have three values `8, 1, 0`

Here is the source code for the constructor

```auto
	/**
	 * An animated image. <br>
	 * The image frames are stored as tiles within a single image
	 *  
	 * @param papp
	 * @param fname the name of the bitmap image file
	 * @param nCols number of tiles horizontally
	 * @param nRows number of rows vertically
	 */
	public BitmapPic(PApplet papp, String fname, int nCols, int nRows){
		super(papp);
		img = ImageBank.getImage(papp, fname, nCols, nRows);
	}

```

---

<div class="post-metadata">

### Author: ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)
#### Post date: [February 25, 2020, 9:48pm UTC](https://discourse.processing.org/t/help-with-java-library-ai-for-games/18039/3 "2020-02-25T21:48:40Z")

</div>

ty, I copied the code straight from the tutorial. Can you tall me how to find the vechile’s current x and y?

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [February 26, 2020, 9:22am UTC](https://discourse.processing.org/t/help-with-java-library-ai-for-games/18039/4 "2020-02-26T09:22:38Z")

</div>

If the game object (e.g. vehicle) is called `go` then you can get the x and y with

```auto
float x = (float) go.pos().x;
float y = (float) go.pos().y;

```

> [@ctrembla](#):
>
> I copied the code straight from the tutorial.

There are loads of web pages dedicated to this library please provide a link to the one where you got the code. Thanks 😄
