
Untitled
By: a guest on
May 5th, 2012 | syntax:
Java | size: 1.24 KB | hits: 14 | expires: Never
Override
public void render(GameContainer container, Graphics g) throws SlickException {
int w = container.getWidth();
int h = container.getHeight();
// Fill the world Colours
g.setColor(Color.darkGray);
g.fillRect(0, 0, w, h);
// Push transform matrix
g.pushTransform();
// Work out the translation to center the world on screen and for zooming
float center_x = (float) ((w/2) - (world.getWidth() * zoom) /2);
float center_y = (float) ((h/2) - (world.getHeight() * zoom) /2);
g.translate(center_x, center_y);
g.scale(zoom, zoom);
g.translate(viewer_x, viewer_y);
g.pushTransform();
g.setColor(Color.black);
g.setLineWidth(2);
float x = -(viewer_x + (center_x / zoom));
float y = -(viewer_y + (center_y / zoom));
float w2 = w /zoom ;
float h2 = h /zoom;
world.drawClip.setBounds( x, y, w2, h2);
g.setWorldClip(x, y, w2, h2);
if (zoom < 0.8)
world.disableRotation();
else
world.enableRotation();
world.draw(g);
g.popTransform();
g.popTransform();
g.setColor(Color.magenta);
g.drawString("Ant Arena", 10, 25);
g.setColor(Color.magenta);
g.drawString("Zoom: " + zoom, 10, 50);
}