All pastes #1031728 Raw Edit

Extension of SlickSet's Actor

public java v1 · immutable
#1031728 ·published 2008-05-28 04:12 UTC
rendered paste body
package org.keithd.fuzzball.slickset;import org.newdawn.slick.Graphics;import org.newdawn.slick.Image;import com.slickset.Actor;import com.slickset.collision.DynamicShape;import com.slickset.layer.Viewport;public class CustomHitboxActor extends Actor {	private float xOffset, yOffset;		public CustomHitboxActor(float x, float y, float xOffset, float yOffset) {		super(x, y);		this.xOffset = xOffset;		this.yOffset = yOffset;	}		public CustomHitboxActor(Image image, float x, float y, DynamicShape shape, float xOffset, float yOffset) {		super(image, x, y, shape);		this.xOffset = xOffset;		this.yOffset = yOffset;	}		public CustomHitboxActor(Image image, float x, float y, DynamicShape shape, boolean fixedBody, float xOffset, float yOffset) {		super(image, x, y, shape, fixedBody);		this.xOffset = xOffset;		this.yOffset = yOffset;	}		public CustomHitboxActor(Image image, float x, float y, DynamicShape shape, float mass, boolean fixedBody, float xOffset, float yOffset) {		super(image, x, y, shape, mass, fixedBody);		this.xOffset = xOffset;		this.yOffset = yOffset;	}		public void render(Graphics g)	{		float screenX = getScreenX();		float screenY = getScreenY();				Viewport viewport = getLayer().getViewport();		screenX += viewport.getClip().getX();		screenY += viewport.getClip().getY();		render(g, screenX, screenY);	}		//Translate from world to screen coordinates.	private float getScreenX()	{		return getX() - getLayer().getViewport().getX() - xOffset;	}		private float getScreenY()	{		return getY() - getLayer().getViewport().getY() - yOffset;	}		public float getXOffset() { 		return xOffset; 	}		public float getYOffset() { 		return yOffset;	}}