so far I have managed to solve a lot of little bugs, mostly typos and the like. Here is a new one that is currently baffling me. After finally getting a 'bouncing ball' class to work (I call it a "banana"), I am confused about why it will not work within an if statement. The setup() and draw() blocks are below. The class works and I know this is true because if I call newBanana.display(); and newBanana.move(); on line 23 it works.
However, I want to call these functions on lines 36 & 37 and here they do not work. Everything else in this statement works. I have put in print functions and they print when the conditional is met. But the function calls do not work. I have also tried reinstantiating(?) the class on line 35 (newBanana = new Banana();) but that also did not work.
I'm sure its easy and hopefully I'll figure it out before someone tells me the answer. :)
If you think viewing the full code will help,
click here.
Car myCar; // A Car
Grape newGrape; // A Grape
Banana newBanana; // A Bananna
int hitCount = 0; // Counter for how many times the grape has been hit
int carSpeed = 7;
void setup() {
size(500, 500);
myCar = new Car();
newGrape = new Grape();
newBanana = new Banana();
}
void draw() {
background(255);
//
text (hitCount, width - 50, height - 20); // place HUD in bottom right corner
fill(0);
newGrape.display(); // draw a grape randomly on the screen
myCar.display(); // Car starts in the middle of the screen
myCar.move(); // Move the car where the user wants
// Checks for collision between grape and car
// Grape must be fully within the boundries of the car to be considered "hit"
if (rectangle_collision (myCar.xpos, myCar.ypos, myCar.sizeW, myCar.sizeH,
I've been googling and searching these forums for about an hour and I haven't been able to solve this problem.
I have a small "car" that moves around the screen and I want it to hit a "grape". I would like that grape to disappear and reappear somewhere else.
I am new to processing and I don't really understand the differences between processing and processing.js but if I could find a tutorial like
this one for Processing, that would be amazing!
My code is long and I know that this topic must have been covered already in a clear and concise manner, but I can not find it.
I am new to processing and relatively new to coding. I am working through the examples on the site and have adapted one to try and learn from it.
I would like to draw a single column of squares. I am currently getting the error 'invalid token: int' referring to the first couple of lines. What do you think? Thanks!