WordPress Hosting
Free Photos
WordPress Themes

new checkCollision() - gracefully turn

public void checkCollision(Dimension panelSize) { double margin = 100; Rectangle2D.Double top = new Rectangle2D.Double(-margin, -margin, panelSize.width+margin*2, margin); Rectangle2D.Double bottom = new Rectangle2D.Double(-margin, panelSize.height, panelSize.width+margin*2, margin); Rectangle2D.Double left = new Rectangle2D.Double(-margin, -margin, margin, panelSize.height+margin*2); Rectangle2D.Double right = new Rectangle2D.Double(panelSize.width, -margin, margin, panelSize.height+margin*2); float coef = .1f; PVector accel = new PVector(); if (getBoundary().intersects(left)) accel.add(1,0); else if (getBoundary().intersects(right)) accel.add(-1,0); else if (getBoundary().intersects(top)) accel.add(0,1); else if (getBoundary().intersects(bottom)) accel.add(0,-1); accel.mult(coef*maxSpeed); speed.add(accel); }
IAT 265 (Fall 2017)
Snippets for Lab 6

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.