Skip to content

Instantly share code, notes, and snippets.

@alphaneet
Created February 12, 2012 11:40
Show Gist options
  • Save alphaneet/1808124 to your computer and use it in GitHub Desktop.
Save alphaneet/1808124 to your computer and use it in GitHub Desktop.
processing と scala で弾をまっすぐ飛ばすサンプル
import processing.core._
object Main extends processing.core.PApplet {
import PConstants._
val pos = new PVector()
val bullets = scala.collection.mutable.ArrayBuffer[PVector]()
override def setup() {
size(800, 400)
}
override def draw() {
background(0, 0, 0)
pos.x = mouseX
pos.y = mouseY
fill(255, 0, 0)
ellipseMode(CENTER)
ellipse(pos.x, pos.y, 30, 30)
bullets foreach {
b =>
b.y -= 20
fill(255, 255, 0)
ellipse(b.x, b.y, 15, 15)
}
}
override def mousePressed() {
bullets += new PVector(pos.x, pos.y)
}
def main(args: Array[String]) = runSketch()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment