We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Someone please help me out. I really want to run this but it won't let me. This is the code:
http://oneslime.net/two/Slime2P.java
That is some pure Java code. You better use some other IDE like Eclipse, NetBeans, BlueJ, etc.
So there's no way to bring it into processing?
Sure there is. Rewrite it. It's simple enough.
Hmmm.
void setup(){ size(600,400); } void draw(){ background(0,0,255); noStroke(); fill(128); rect(0,height-20,width,20); fill(255); rect(295,height-80,10,60); }
you can use javac to compile it and appletviewer to run it. no need for processing.
class Slime { int px=100, py=20; boolean jumping = false; boolean can_jump = false; Slime(){ } void draw(){ simulate(); render(); } void simulate(){ if(jumping){ can_jump = false; py-=2; if(py<height-50){ jumping = false; } } if(py<height-20){ if(!jumping){ py+=2; } } else { can_jump = true; } } void render(){ fill(255,0,0); noStroke(); arc(px,py,100,100,-PI,0); } } Slime p1; void setup(){ size(600,400); p1 = new Slime(); } void draw(){ background(0,0,255); noStroke(); fill(128); rect(0,height-20,width,20); fill(255); rect(295,height-80,10,60); p1.draw(); } void keyPressed(){ if(keyCode == UP ){ if( p1.can_jump ) p1.jumping = true; } } void keyReleased(){ if(keyCode == UP ){ p1.jumping = false; } }
class Slime { int px=100, py=20; boolean jumping = false; boolean can_jump = false; boolean move_left = false; boolean move_right = false; Slime() { } void draw() { simulate(); render(); } void simulate() { if (jumping) { can_jump = false; py-=2; if (py<height-50) { jumping = false; } } if (py<height-20) { if (!jumping) { py+=2; } } else { can_jump = true; } if (move_left) { if ( p1.px > 50 ) p1.px-=2; } if ( move_right ) { if ( p1.px < 245 ) p1.px+=2; } } void render() { fill(255, 0, 0); noStroke(); arc(px, py, 100, 100, -PI, 0); } } Slime p1; void setup() { size(600, 400); p1 = new Slime(); } void draw() { background(0, 0, 255); noStroke(); fill(128); rect(0, height-20, width, 20); fill(255); rect(295, height-80, 10, 60); p1.draw(); } void keyPressed() { if (keyCode == LEFT) { p1.move_left = true; } if (keyCode == RIGHT) { p1.move_right = true; } if (keyCode == UP ) { if ( p1.can_jump ) p1.jumping = true; } } void keyReleased() { if (keyCode == LEFT) { p1.move_left = false; } if (keyCode == RIGHT) { p1.move_right = false; } if (keyCode == UP ) { p1.jumping = false; } }
I got that far with it. But i couldn't control how the ball landed because I couldn't calculate the tangent of it.
Thanks for helping!
I'm having a problem with the collision of the ball
Can someone help me with how the ball moves? I've been trying to find the right collision code but nothing is working .
Answers
That is some pure Java code. You better use some other IDE like Eclipse, NetBeans, BlueJ, etc.
So there's no way to bring it into processing?
Sure there is. Rewrite it. It's simple enough.
Hmmm.
you can use javac to compile it and appletviewer to run it. no need for processing.
I got that far with it. But i couldn't control how the ball landed because I couldn't calculate the tangent of it.
Thanks for helping!
I'm having a problem with the collision of the ball
Can someone help me with how the ball moves? I've been trying to find the right collision code but nothing is working .