Created
May 25, 2013 21:37
-
-
Save danirod/5650869 to your computer and use it in GitHub Desktop.
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
package danirod.snippet.test.slick2d.rrtest; | |
import org.newdawn.slick.AppGameContainer; | |
import org.newdawn.slick.BasicGame; | |
import org.newdawn.slick.GameContainer; | |
import org.newdawn.slick.Graphics; | |
import org.newdawn.slick.SlickException; | |
import org.newdawn.slick.geom.Rectangle; | |
import org.newdawn.slick.geom.RoundedRectangle; | |
import org.newdawn.slick.geom.Shape; | |
public class RRTest extends BasicGame { | |
private Shape figura, figura2; | |
public RRTest(String title) { | |
super(title); | |
} | |
@Override | |
public void render(GameContainer container, Graphics g) | |
throws SlickException { | |
g.draw(figura); | |
g.draw(figura2); | |
if(figura.intersects(figura2)) | |
g.drawString("COLISION", container.getInput().getMouseX(), | |
container.getInput().getMouseY() - 30); | |
} | |
@Override | |
public void init(GameContainer container) throws SlickException { | |
figura = new RoundedRectangle(50, 50, 50, 100, 30); | |
figura2 = new Rectangle(container.getInput().getMouseX(), | |
container.getInput().getMouseY(), 2, 2); | |
} | |
@Override | |
public void update(GameContainer container, int delta) | |
throws SlickException { | |
figura2.setX(container.getInput().getMouseX()); | |
figura2.setY(container.getInput().getMouseY()); | |
} | |
public static void main(String args[]) throws SlickException { | |
AppGameContainer app = new AppGameContainer(new RRTest("TEST")); | |
app.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment