Created
April 8, 2013 10:02
-
-
Save monkstone/5335685 to your computer and use it in GitHub Desktop.
Fisica test sketch
This file contains hidden or 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
# | |
# Buttons and bodies | |
# | |
# by Ricard Marxer | |
# | |
# This example shows how to create a blob. | |
# | |
load_library :fisica | |
include_package 'fisica' | |
CIRCLE_COUNT = 20 | |
HOLE = 50 | |
TOP_MARGIN = 50 | |
BOTTOM_MARGIN = 300 | |
SIDE_MARGIN = 100 | |
attr_reader :world, :x_pos | |
def setup | |
size(400, 400) | |
smooth | |
@x_pos = 0 | |
Fisica.init(self) | |
@world = FWorld.new | |
world.setGravity(0, -300) | |
l = FPoly.new | |
l.vertex(width/2-HOLE/2, 0) | |
l.vertex(0, 0) | |
l.vertex(0, height) | |
l.vertex(0 + SIDE_MARGIN, height) | |
l.vertex(0 + SIDE_MARGIN, height-BOTTOM_MARGIN) | |
l.vertex(width/2-HOLE/2, TOP_MARGIN) | |
l.set_static(true) | |
#l.set_fill(0) | |
l.set_friction(0) | |
world.add(l) | |
r = FPoly.new | |
r.vertex(width/2 + HOLE/2, 0) | |
r.vertex(width, 0) | |
r.vertex(width, height) | |
r.vertex(width-SIDE_MARGIN, height) | |
r.vertex(width-SIDE_MARGIN, height-BOTTOM_MARGIN) | |
r.vertex(width/2 + HOLE/2, TOP_MARGIN) | |
r.set_static(true) | |
#r.set_fill(0) | |
r.set_friction(0) | |
world.add(r) | |
end | |
def draw | |
background(80, 120, 200) | |
fill(0) | |
if ((frame_count % 40) == 1) | |
b = FBlob.new | |
s = rand(30 .. 40) | |
space = (width - SIDE_MARGIN * 2-s) | |
@x_pos = (x_pos + rand(s .. space/2.0)) % space | |
b.set_as_circle(SIDE_MARGIN + x_pos + s / 2, height - rand(100), s, 20) | |
#b.set_stroke(0) | |
b.set_stroke_weight(2) | |
#b.set_fill(255) | |
b.set_friction(0) | |
world.add(b) | |
end | |
world.step | |
world.draw | |
end | |
def key_pressed | |
save_frame("screenshot.png") | |
end | |
setFill raises a NoMethodError using the bundled jruby. I get no errors when i run with my rvm-install jruby. https://gist.github.com/alexdean/5337168. Again, it looks like some methods are missing.
Is this an issue related to how jruby was compiled? I'm still using the java 6 bundled with OSX. I understand there are some features in java 7 which affect dynamic languages (invokedynamic), but i'm not sure if that's relevant here or not.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example seems to work as expected allbeit you can't use setFill or setStroke method. Did it run for you with external JRuby? @alexdean