All Downloads are FREE. Search and download functionalities are using the official Maven repository.

examples.Life.src.main.gosu.life.ScrollHandler.gs Maven / Gradle / Ivy

There is a newer version: 1.18.1
Show newest version
package life

uses java.awt.event.MouseEvent
uses java.awt.Point
uses java.awt.event.MouseWheelEvent

class ScrollHandler extends AbstractHandler {
  var _anchor: Point
  var _origin: Point

  construct( board: Board ) {
    super( board )
  }

  override function mousePressed( e: MouseEvent ) {
    _anchor = e.Point
    _origin = Board.Origin
  }

  override function mouseDragged( e: MouseEvent ) {
    scroll( e.Point )
  }

  private function scroll(pt: Point) {
    var xDiff = (_anchor.x - pt.x) / Board.CellSize
    var yDiff = (_anchor.y - pt.y) / Board.CellSize
    Board.Origin = new Point( _origin.x - xDiff, _origin.y - yDiff )
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy