Combine use of oscP5 and Fisica

edited April 2016 in Library Questions

Hello,

to make this fast: i'm a noob at processing and programming in general (started a couple of weeks ago), but I LOVE IT! Very fun so far.

My problem with this game I'm trying to create is, well I want to be able to control the "FBox player" (a rectangle that serves as the player) using oscP5. When I move the "//Player" part into draw I'm able to do it but it generates LOTS of boxes and trying to use background() to clean doesn't work. Can anyone help me out with this issue?

To sum up: let me control the box without the program generating hundreds of boxes:)

Many thanks in advance!

OscP5 oscP5;

FWorld world;

float x, y, inputX, inputY;

void setup() {

size(500, 500);

Fisica.init(this);  
world = new FWorld();
world.setEdges();
world.setEdgesRestitution(0.5);

oscP5 = new OscP5(this, 12000);

 // Player
FBox player = new FBox(80, 20);
player.setPosition(x, 450);
world.add(player);

 // Ball
FCircle ball = new FCircle(25);
ball.setPosition(250, 250);
world.add(ball);
}

void draw() {
background(0, 150, 150);

world.step();
world.draw();

x = lerp(x, inputX, 0.08f);
 // y = lerp(y, inputY, 0.08f);

}

void oscEvent(OscMessage msg) {
if (msg.checkAddrPattern("/multi/1")) {
inputX = msg.get(0).floatValue() * width;
 // inputY = msg.get(1).floatValue() * height;

println(x + " " + y);

} }

Sign In or Register to comment.