Created
February 12, 2012 11:40
-
-
Save alphaneet/1808124 to your computer and use it in GitHub Desktop.
processing と scala で弾をまっすぐ飛ばすサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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