本文整理汇总了Java中org.newdawn.slick.geom.Rectangle类的典型用法代码示例。如果您正苦于以下问题:Java Rectangle类的具体用法?Java Rectangle怎么用?Java Rectangle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于org.newdawn.slick.geom包,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
rect = new Rectangle(400,100,200,150);
round = new RoundedRectangle(150,100,200,150,50);
round2 = new RoundedRectangle(150,300,200,150,50);
center = new Rectangle(350,250,100,100);
poly = new Polygon();
poly.addPoint(400,350);
poly.addPoint(550,320);
poly.addPoint(600,380);
poly.addPoint(620,450);
poly.addPoint(500,450);
gradient = new GradientFill(0,-75,Color.red,0,75,Color.yellow,true);
gradient2 = new GradientFill(0,-75,Color.blue,0,75,Color.white,true);
gradient4 = new GradientFill(-50,-40,Color.green,50,40,Color.cyan,true);
}
示例2: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
image1 = new Image("testdata/grass.png");
image2 = new Image("testdata/rocks.png");
fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
shape = new Rectangle(336,236,128,128);
poly = new Polygon();
poly.addPoint(320,220);
poly.addPoint(350,200);
poly.addPoint(450,200);
poly.addPoint(480,220);
poly.addPoint(420,400);
poly.addPoint(400,390);
}
示例3: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
shapes = new ArrayList();
rect = new Rectangle(10, 10, 100, 80);
shapes.add(rect);
roundRect = new RoundedRectangle(150, 10, 60, 80, 20);
shapes.add(roundRect);
ellipse = new Ellipse(350, 40, 50, 30);
shapes.add(ellipse);
circle = new Circle(470, 60, 50);
shapes.add(circle);
polygon = new Polygon(new float[]{550, 10, 600, 40, 620, 100, 570, 130});
shapes.add(polygon);
keys = new boolean[256];
lastChar = new char[256];
createPoly(200,200);
}
示例4: setWorldClip
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* Set clipping that controls which areas of the world will be drawn to.
* Note that world clip is different from standard screen clip in that it's
* defined in the space of the current world coordinate - i.e. it's affected
* by translate, rotate, scale etc.
*
* @param x
* The x coordinate of the top left corner of the allowed area
* @param y
* The y coordinate of the top left corner of the allowed area
* @param width
* The width of the allowed area
* @param height
* The height of the allowed area
*/
public void setWorldClip(float x, float y, float width, float height) {
predraw();
worldClipRecord = new Rectangle(x, y, width, height);
GL.glEnable(SGL.GL_CLIP_PLANE0);
worldClip.put(1).put(0).put(0).put(-x).flip();
GL.glClipPlane(SGL.GL_CLIP_PLANE0, worldClip);
GL.glEnable(SGL.GL_CLIP_PLANE1);
worldClip.put(-1).put(0).put(0).put(x + width).flip();
GL.glClipPlane(SGL.GL_CLIP_PLANE1, worldClip);
GL.glEnable(SGL.GL_CLIP_PLANE2);
worldClip.put(0).put(1).put(0).put(-y).flip();
GL.glClipPlane(SGL.GL_CLIP_PLANE2, worldClip);
GL.glEnable(SGL.GL_CLIP_PLANE3);
worldClip.put(0).put(-1).put(0).put(y + height).flip();
GL.glClipPlane(SGL.GL_CLIP_PLANE3, worldClip);
postdraw();
}
示例5: fillRect
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* Tile a rectangle with a pattern specifing the offset from the top corner
* that one tile should match
*
* @param x
* The x coordinate of the rectangle
* @param y
* The y coordinate of the rectangle
* @param width
* The width of the rectangle
* @param height
* The height of the rectangle
* @param pattern
* The image to tile across the rectangle
* @param offX
* The offset on the x axis from the top left corner
* @param offY
* The offset on the y axis from the top left corner
*/
public void fillRect(float x, float y, float width, float height,
Image pattern, float offX, float offY) {
int cols = ((int) Math.ceil(width / pattern.getWidth())) + 2;
int rows = ((int) Math.ceil(height / pattern.getHeight())) + 2;
Rectangle preClip = getWorldClip();
setWorldClip(x, y, width, height);
predraw();
// Draw all the quads we need
for (int c = 0; c < cols; c++) {
for (int r = 0; r < rows; r++) {
pattern.draw(c * pattern.getWidth() + x - offX, r
* pattern.getHeight() + y - offY);
}
}
postdraw();
setWorldClip(preClip);
}
示例6: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
sb = sbg;
InputProvider provider = new InputProvider(gc.getInput());
provider.addListener(this);
fps = new TrueTypeFont(Fonts.fpsCounter.getFont(), true);
active = new TrueTypeFont(Fonts.active.getFont(), true);
inactive = new TrueTypeFont(Fonts.inactive.getFont(), true);
provider.bindCommand(new KeyControl(Input.KEY_UP), up);
provider.bindCommand(new KeyControl(Input.KEY_DOWN), down);
provider.bindCommand(new KeyControl(Input.KEY_LEFT), left);
provider.bindCommand(new KeyControl(Input.KEY_RIGHT), right);
provider.bindCommand(new KeyControl(Input.KEY_ENTER), enter);
for (int i = 0; i < rect.length; i++) {
rect[i] = new Rectangle(20, 20 + (70 * i), statValues[i] * 40, Play.width/30);
}
}
示例7: Particle
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
public Particle(String image_, Color color_, Pair<Float> position_, float velocity_,
float theta_, float angularVelocity_, Pair<Float> size_, long lifespan_,
long created_) {
this.image = image_;
this.color = color_;
this.position = position_;
this.velocity = velocity_;
this.theta = theta_;
this.angularVelocity = angularVelocity_;
this.size = size_;
this.lifespan = lifespan_;
this.created = created_;
this.collision = false;
this.bounds = new Rectangle((position.x - (size.x / 2)), (position.y - (size.y / 2)), size.x, size.y);
}
示例8: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
@Override
public void init(GameContainer gc, StateBasedGame game) throws SlickException {
shopBoxes = new Rectangle[SHOP_ROWS][SHOP_COLS];
for(int r = 0; r < SHOP_ROWS; r++) {
for(int c = 0; c < SHOP_COLS; c++) {
float x = SHOP_CONTAINER.x + 3.0f + ((c * ITEM_BOX_SIZE) + (c * 2.0f));
float y = SHOP_CONTAINER.y + 3.0f + ((r * ITEM_BOX_SIZE) + (c * 2.0f));
shopBoxes[r][c] = new Rectangle(x, y, ITEM_BOX_SIZE, ITEM_BOX_SIZE);
}
}
inventoryBoxes = null;
selected = null;
selectedInInventory = false;
buyButton = new TransactionButton(new Pair<Float>((float)((Globals.WIDTH / 2) - 58.0f), (Globals.HEIGHT - 70.0f)), TransactionButton.Type.BUY);
sellButton = new TransactionButton(new Pair<Float>((float)((Globals.WIDTH / 2) + 58.0f), (Globals.HEIGHT - 70.0f)), TransactionButton.Type.SELL);
inventorySize = 0;
exit = false;
}
示例9: enter
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
@Override
public void enter(GameContainer gc, StateBasedGame game) {
exit = false;
if(Globals.player.getInventory().getCapacity() != inventorySize) {
// Inventory size has changed. Re-build inventory layout.
inventorySize = Globals.player.getInventory().getCapacity();
int cols = SHOP_COLS;
int rows = (int)(Math.ceil((float)inventorySize / (float)cols));
if(inventoryBoxes == null) {
inventoryBoxes = new Rectangle[rows][cols];
}
for(int r = 0; r < rows; r++) {
for(int c = 0; c < cols; c++) {
float x = INVENTORY_CONTAINER.x + 3.0f + ((c * ITEM_BOX_SIZE) + (c * 2.0f));
float y = INVENTORY_CONTAINER.y + 3.0f + ((r * ITEM_BOX_SIZE) + (c * 2.0f));
inventoryBoxes[r][c] = new Rectangle(x, y, ITEM_BOX_SIZE, ITEM_BOX_SIZE);
}
}
}
}
示例10: render
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
@Override
public void render(GameContainer container, Graphics g) throws SlickException {
if (canSeePlayer()) {
g.drawImage(ResourceManager.getImage(G.SHADOW), x, y);
super.render(container, g);
int w = (32 * hp) / maxHp;
if (w < 0) {
w = 0;
} else if (w > 32) {
w = 32;
}
hbar = new Rectangle(x, y, w, 3);
g.setColor(Color.red);
g.fill(hbar);
g.resetTransform();
}
}
示例11: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
@Override
public void init() {
selected = 0;
amountOptions = 2;
image = Sprite.get("menu.png");
try {
sfx_select = new Sound(GamePanel.resfolder + "sound" + File.separator + "select.wav");
} catch (SlickException e) {
e.printStackTrace();
}
Entity.getEntities().clear();
play = new Rectangle(40, 50, 50, 24);
quit = new Rectangle(40, 86, 50, 24);
}
示例12: init
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
CHANGE_SEASON_SIZE = 150;
CHANGE_SEASON_PADDING = 150;
this.initProcessor(container, game);
this.pressed = new LinkedList<TouchPosition>();
this.vibration = (Vibrator)AndroidLoader.ANDROID_CONTEXT.getSystemService(Context.VIBRATOR_SERVICE);
//Obt�m as imagens dos controles.
PackedSpriteSheet pack = new PackedSpriteSheet("data/sprites/control.def", Image.FILTER_NEAREST);
this.controls = new Image[3];
this.controls[0] = pack.getSprite("control_left");
this.controls[1] = pack.getSprite("control_right");
this.controls[2] = pack.getSprite("control_up");
//Posi��es dos bot�es do controle.
this.left = new Rectangle(5, 347, 80, 128);
this.right = new Rectangle(85, 347, 80, 128);
this.up = new Rectangle(667, 347, 128, 128);
this.lastDragPoint = new Vec2(0,0);
}
示例13: deleteTile
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* Delete o tile na posi��o atual do mundo.
*/
private void deleteTile() {
//Verifica se h� algum sprite na posi��o atual.
for (int i = this.tiles.size() - 1; i >= 0; i--) {
TileData data = this.tiles.get(i);
Image sprite = this.packs.get(data.definitionFileId).getSprite(data.spriteName);
//Cria um ret�ngulo representando a imagem.
float width = this.transform.convertPixelsInWorldScale(sprite.getWidth());
float height = this.transform.convertPixelsInWorldScale(sprite.getHeight());
float x = data.position.x - width / 2;
float y = data.position.y - height / 2;
Rectangle rec = new Rectangle(x, y, width, height);
//Verifica se o ponto est� no ret�ngulo.
Vec2 worldPosition = this.transform.screenToWorld(this.currentTilePosition);
if (rec.contains(worldPosition.x, worldPosition.y)) {
this.tiles.remove(i);
break;
}
}
}
示例14: isInViewport
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
/**
* Verifica qual a porcentagem de um determinado objeto de um determinado tamanho no viewport.
* @param objCenter Centro do corpo, em unidades do mundo.
* @param halfWidth Metade da largura do corpo, em unidades do mundo.
* @param halfHeight Metade da largura do corpo, em unidades do mundo.
* @param offset Extens�es da �rea de avalia��o de som.
* @return Porcentagem da �rea do objeto no viewport.
*/
public float isInViewport(Vec2 objCenter, float halfWidth, float halfHeight, Vec2 offset) {
//Por padr�o, o fatro de som � 0.
float factor = 0;
//O corpo tem suas medidas convertidas para unidades de tela e sua posi��o no canto superior esquerdo.
Vec2 wObjCenter = this.worldToScreen(objCenter);
Vec2 size = new Vec2(this.convertWorldScaleInPixels(halfWidth), this.convertWorldScaleInPixels(halfHeight));
size.x *= offset.x;
size.y *= offset.y;
Rectangle body = new Rectangle(wObjCenter.x - size.x, wObjCenter.y - size.y, size.x * 2, size.y * 2);
//Primeiramente, verifica se os ret�ngulos interseccionaram.
if (Utils.intersect(cam, body)) {
/* Caso tenham interseccionado, verifica o fator de som
* de acordo com a �rea de r2 em r1.*/
Rectangle overlap = Utils.getOverlapArea(cam, body);
factor = (overlap.getWidth() * overlap.getHeight()) / (body.getWidth() * body.getHeight());
//Normaliza o fator.
if (factor > 1.0f) factor = 1.0f;
}
return factor;
}
示例15: TileMatrixManager
import org.newdawn.slick.geom.Rectangle; //导入依赖的package包/类
public TileMatrixManager(ArrayList<Rectangle> rectangleList, ArrayList<Tile> savedTileList, int savedScore)
{
this(rectangleList);
score = savedScore;
//create the tile matrix
for (int y = 0; y < tileMatrix.getMatrixSize(); y++)
for (int x = 0; x < tileMatrix.getMatrixSize(); x++)
{
Tile currentTile = savedTileList.get(y * tileMatrix.getMatrixSize() + x);
if (currentTile != null)
{
tileMatrix.set(x, y, currentTile);
currentTile.setX(goodPositions.get(x, y).getX());
tileMatrix.get(x, y).setY(goodPositions.get(x, y).getY());
}
}
nextTileMatrix = tileMatrix;
}