Rectangle2D.Double top = new Rectangle2D.Double(env.X_LEFT, env.Y_TOP-50, env.X_RIGHT-env.X_LEFT, 50);
if (getBoundary().intersects(top) && speed.y < 0) speed.y *= -1;
Rectangle2D.Double bottom = new Rectangle2D.Double(env.X_LEFT, env.Y_BTM, env.X_RIGHT-env.X_LEFT, 50);
if (getBoundary().intersects(bottom) && speed.y > 0) speed.y *= -1;
Rectangle2D.Double left = new Rectangle2D.Double(env.X_LEFT-50, env.Y_TOP, 50, env.Y_BTM-env.Y_TOP);
if (getBoundary().intersects(left) && speed.x < 0) speed.x *= -1;
Rectangle2D.Double right = new Rectangle2D.Double(env.X_RIGHT, env.Y_TOP, 50, env.Y_BTM-env.Y_TOP);
if (getBoundary().intersects(right) && speed.x > 0) speed.x *= -1;
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.