OOP Problem
in
Programming Questions
•
2 years ago
hello,
iam pretty new to OOP with processing and i dont find a mistake in my code =/
it complies correctly but nothing is drawn
iam pretty new to OOP with processing and i dont find a mistake in my code =/
it complies correctly but nothing is drawn
Ball myBall;
void setup() {
size(1000, 1000);
smooth();
myBall = new Ball(200, 500, 200, 200, 1);
}
void draw() {
background(255);
myBall.display();
myBall.movement();
}- class Ball {
float x;
float y;
float w;
float h;
float speed;
Ball(float tempX, float tempY, float tempW, float tempH, float tempSpeed) {
tempX = x;
tempY = y;
tempW = w;
tempH = h;
tempSpeed = speed;
}
void movement() {
x = x + speed;
if (x>=width) {
x = x * -1;
}
}
void display() {
ellipse(x, y, w, h);
}
}
1