Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Frustration

 
Noah Faust
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code has no errors and checks out fine, but when I run it, all I get is a single point at 500,500. It may be that the setup is looping, but I don't really know. If someone has a solution, it would be great. Here is the code:

import processing.core.PApplet;
public class incoming extends PApplet {

/**
*
*/
private static final long serialVersionUID = 1L;
public int xmissle;
public int ymissle;
public int xforce;
public int yforce;
public void setup() {
xmissle = 500;
ymissle = 500;
xforce = 0;
yforce = 0;
size(1000,1000);
loop();

}
public void draw() {
point(xmissle,ymissle);
if (xmissle >= mouseX){
xforce = xforce--;
System.out.println("!!!");
}
if (xmissle < mouseX){
xforce = xforce++;

}
if (ymissle >= mouseY){
yforce = yforce++;

}
if (ymissle < mouseY){
yforce = yforce--;

}
xmissle = xmissle + xforce;
ymissle = ymissle + yforce;
}
}
 
Noah Faust
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind, I had a simple error! I said xforce = xforce++; instead of xforce++;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic