keyPressed and keyReleased with java(eclipse)

I believe you’ve got it from here perhaps: :question:

What do you mean by that? This sketch is already cross-mode. :negative_squared_cross_mark:

That is, the same code runs on both offline Java Mode (Processing’s IDE) & online JavaScript Mode (Pjs): ProcessingJS.org

DIAM stands for diameter and SPD stands for speed. :racing_car:

d >> 1 gets the half of d, which stands for diameter btW. Thus r is radius. :green_circle:

B/c the sketch is using the default ellipseMode(CENTER);:

The default mode is ellipseMode(CENTER) , which interprets the first two parameters of ellipse() as the shape’s center point, while the third and fourth parameters are its width and height.

And the coordinate pair origin of an ellipse() is its CENTER, knowing the RADIUS of it is essential for collision checks: :heavy_check_mark:

In this specific sketch, the collision check is to constrain() the ellipse() within the sketch’s rectangular canvas when we move it: :face_with_monocle:
x = constrain(x + v*(int(isRight) - int(isLeft)), r, width - r);

Again I don’t get what you mean. B/c we can totally copy & paste the whole code in Processing IDE’s Java Mode in order to run it offline. :coffee:

1 Like