Function movement() does not exist. (Solved)
Answered
- Need more info
- Answered
- Working on it
in
Programming Questions
•
1 year ago
I just started programming, so I was going to make a program of a ball bouncing off the walls; very simple.
Unfortunately, the program says "The function movement () does not exist." Ball.display would probably be the same.
It didn't make much sense, since it seemed that you would be able to define functions of what they are.
Like for pseudo code,
Unfortunately, the program says "The function movement () does not exist." Ball.display would probably be the same.
It didn't make much sense, since it seemed that you would be able to define functions of what they are.
Like for pseudo code,
- ...
- person.move;
- }
- function move () {
- xloc = xloc + xspd;
- }
- ...
- Ball B;
- class Ball {
- int locx;
- int locy;
- int spdx;
- int spdy;
- color c;
- Ball (int tlocx, int tlocy, int tspdx, int tspdy, int tc) {
- locx = tlocx;
- locy = tlocy;
- spdx = tspdx;
- spdy = tspdy;
- c = tc;
- }
- }
- void setup () {
- B = new Ball (200, 200, 10, -10, color (200));
- size (250, 250);
- smooth ();
- }
- void draw () {
- background (200);
- Ball.movement();
- Ball.display();
- }
- void display() {
- smooth ();
- fill (c);
- ellipseMode (CENTER);
- ellipse (locx, locy, 20, 20);
- }
- void movement() {
- locx = locx + spdx;
- locy = locy + spdy;
- if (xloc > width || xloc < width) {
- xloc = invert (xloc);
- }
- if (yloc > height || yloc > height) {
- yloc = invert (yloc);
- }
- }
1