Need help fixing my code and implementing stuff

edited March 2018 in Questions about Code

https://drive.google.com/open?id=10vAw-4kFWOX48ufyf6lK5tel_zcWolWv

hi im a student at uni that neds help with his project as my teacher has taughter me muc for the project because of illness and other personal reasons but i tried to code a game in processing but i got overwhelmed i left a linkif you could help debug and help me with inserting the images as players and timer that would be swell

class AI

{

String team;

int xPos;

int yPos;

boolean isLeft, isRight, isUp, isDown;

public PVector pos;

int v;

int playerRadius = 10;

AI(int xx, int yy, int speed, String tm)

{

team = tm;

pos = new PVector(xx, yy);

xPos = xx;

yPos = yy;

v = speed;

}

void display()

{

if (team.equals("home"))

{

stroke(255);

fill(0, 0, 255);

}

if (team.equals("red"))

{

stroke(255);

fill(255, 0, 0);

}

ellipseMode(RADIUS);

ellipse(pos.x, pos.y, playerRadius, playerRadius);

}

void moveToBallFree()

{

if (pos.x >= (int)ball.pos.x)

{

pos.x = pos.x - random(1, 2);

}

if (pos.x <= (int)ball.pos.x)

{

pos.x = pos.x + random(1, 2);

}

if (pos.y >= (int)ball.pos.y)

{

pos.y = pos.y - random(1, 2);

}

if (pos.y <= (int)ball.pos.y)

{

pos.y = pos.y + random(1, 2);

void moveToBall() {

{

if (pos.x >= (int)ball.pos.x)

{

pos.x = constrain(pos.x - random(1, 2), xPos-115, xPos+115);

}

if (pos.x <= (int)ball.pos.x){

pos.x = constrain(pos.x + random(1, 2), xPos-115, xPos+115); }

if (pos.y >= (int)ball.pos.y){

pos.y = constrain(pos.y - random(1, 2), yPos-70, yPos+70);

}

if (pos.y <= (int)ball.pos.y){

pos.y = constrain(pos.y + random(1, 2), yPos-70, yPos+70); }

I left a link to the file if anyone would like to help me it would greatly appreciated

Tagged:

Answers

  • First, edit your post with the gear icon above and format your code (highlight + Ctrl-o).

    Next, this isn't a Processing sketch. Where is draw()? Where is setup()? Is this supposed to be a processing sketch?

    Next, when you say help debug, what specific error are you getting? What is the next change you are trying to make, and what did you try that didn't work? Please don't ask people to just do your homework for you. Ask them to help you do it yourself.

Sign In or Register to comment.