当前位置: 首页>>代码示例>>Java>>正文


Java Point类代码示例

本文整理汇总了Java中org.newdawn.slick.geom.Point的典型用法代码示例。如果您正苦于以下问题:Java Point类的具体用法?Java Point怎么用?Java Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Point类属于org.newdawn.slick.geom包,在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: IsColliding

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public boolean IsColliding(Point translation, MapData mapData) {
  Point newPoint = new Point(position.getX() + translation.getX(), position.getY() + translation.getY());

  for (TileData tileData : mapData.GetTiles()) {
    // TODO: Get width & height from somewhere
    boolean collideRight = newPoint.getX() + size.width > tileData.x;
    boolean collideLeft = newPoint.getX() < tileData.x + 8;
    boolean collideBottom = newPoint.getY() + size.height > tileData.y;
    boolean collideTop = newPoint.getY() < tileData.y + 8;

    if (collideRight && collideLeft && collideBottom && collideTop) {
      return true;
    }
  }
  return false;
}
 
开发者ID:Pheelbert,项目名称:chatterino,代码行数:17,代码来源:Player.java

示例2: getGridAlignedCoordinates

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
private Point getGridAlignedCoordinates(int x, int y) {
	x -= this.tileImage.getWidth() / 2;
	y -= this.tileImage.getHeight() / 2;
	int newX = ((x / (SCREEN_WIDTH / (BOARD_SIZE + 2))) * (SCREEN_WIDTH / (BOARD_SIZE + 2)))
			+ (SCREEN_WIDTH / (BOARD_SIZE + 2));
	int newY = ((y / (SCREEN_HEIGHT / (BOARD_SIZE + 2))) * (SCREEN_HEIGHT / (BOARD_SIZE + 2)))
			+ (SCREEN_HEIGHT / (BOARD_SIZE + 2));
	newX -= this.tileImage.getWidth() / 2;
	newY -= this.tileImage.getHeight() / 2;

	// Limit values on each axis to a maximum
	if (newX > SCREEN_WIDTH - 1.5 * TILE_SIZE)
		newX = (int) (SCREEN_WIDTH - 1.5 * TILE_SIZE);
	if (newY > SCREEN_HEIGHT - 1.5 * TILE_SIZE)
		newY = (int) (SCREEN_HEIGHT - 1.5 * TILE_SIZE);

	return new Point(newX, newY);
}
 
开发者ID:DominikHorn,项目名称:Go,代码行数:19,代码来源:ClientMain.java

示例3: PageInfantry

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public PageInfantry(Point pos) {
super(pos);

addButton(new InfantrySidebarButton("Shock Trooper", "shokicon.shp", this.getPosition(), 0, 4, false, null));

//addButton(new InfantrySidebarButton("", "icon.shp", this.getPosition(), 1, 5, false, null));
//addButton(new InfantrySidebarButton("", "icon.shp", this.getPosition(), 1, 5, false, null));

addButton(new InfantrySidebarButton("Flamethrower", "e4icon.shp", this.getPosition(), 0, 6, false, null));
//addButton(new InfantrySidebarButton("", "icon.shp", this.getPosition(), 1, 6, false, null));

addButton(new InfantrySidebarButton("Rocket Soldier", "e3icon.shp", this.getPosition(), 0, 7, false, null));
addButton(new InfantrySidebarButton("Tanya", "e7icon.shp", this.getPosition(), 1, 7, false, null));

addButton(new InfantrySidebarButton("Grenade Trooper", "e2icon.shp", this.getPosition(), 0, 8, false, null));
//addButton(new InfantrySidebarButton("", "icon.shp", this.getPosition(), 1, 8, false, null));

addButton(new InfantrySidebarButton("Riffle Trooper", "e1icon.shp", this.getPosition(), 0, 9, false, null));
addButton(new InfantrySidebarButton("Engineer", "e6icon.shp", this.getPosition(), 1, 9, false, null));
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:21,代码来源:PageInfantry.java

示例4: calculateNextPosition

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
/**
 * Calculates the next position the model would be at by checking the user
 * input and the model's movement speed. Also sets the model's isMoving
 * property.
 * 
 * 
 * @param input
 *            Input object to mouse position against.
 * @param model
 *            Model to calculate facing for.
 * @param delta
 *            The time in milliseconds since the last update.
 * @return The next position the model would be in.
 */
private Point calculateNextPosition(Input input,
		AbstractCharacterModel model, int delta) {
	boolean goingUp = input.isKeyDown(KeyBindings.getBinding(Key.UP));
	boolean goingDown = input.isKeyDown(KeyBindings.getBinding(Key.DOWN));
	boolean goingRight = input.isKeyDown(KeyBindings.getBinding(Key.RIGHT));
	boolean goingLeft = input.isKeyDown(KeyBindings.getBinding(Key.LEFT));

	// Calculate move direction and move
	float speedY = (goingUp ? 1 : 0) - (goingDown ? 1 : 0);
	float speedX = (goingLeft ? 1 : 0) - (goingRight ? 1 : 0);

	if (speedY != 0 || speedX != 0) {
		double direction = Math.atan2(speedY, speedX);
		speedY = (float) (model.getVelocity() * Math.sin(direction));
		speedX = (float) (model.getVelocity() * Math.cos(direction));
	}

	float newX = model.getX() - (delta * speedX);
	float newY = model.getY() - (delta * speedY);

	model.setMoving(speedY != 0 || speedX != 0);

	return new Point(newX, newY);
}
 
开发者ID:verath,项目名称:ESCP,代码行数:39,代码来源:HeroController.java

示例5: SendPosition

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void SendPosition(Point position) {
  if (!IsConnected()) {
    return;
  }

  PointInfo point = new PointInfo();
  point.x = position.getX();
  point.y = position.getY();
  client.sendTCP(point);
}
 
开发者ID:Pheelbert,项目名称:chatterino,代码行数:11,代码来源:NetworkClient.java

示例6: Translate

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void Translate(Point point) {
  if (point.getX() != 0 || point.getY() != 0) {
    position.setX(position.getX() + point.getX());
    position.setY(position.getY() + point.getY());
    NetworkClient.GetInstance().SendPosition(position);
  }
}
 
开发者ID:Pheelbert,项目名称:chatterino,代码行数:8,代码来源:Player.java

示例7: Update

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void Update(int delta) {
  Point translation = new Point(0, 0);
  if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
    translation.setY(translation.getY() + GetSpeed() * delta);
  } if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
    translation.setY(translation.getY() - GetSpeed() * delta);
  } if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
    translation.setX(translation.getX() - GetSpeed() * delta);
  } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
    translation.setX(translation.getX() + GetSpeed() * delta);
  }
  if (!IsColliding(translation, Game.GetCurrentRoom().GetMapData())) {
    Translate(translation);
  }
}
 
开发者ID:Pheelbert,项目名称:chatterino,代码行数:16,代码来源:LocalPlayer.java

示例8: Render

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void Render(Graphics g) {
  g.setFont(Fonts.VERDANA);
  Point point = new Point(positionable.GetPosition().getX(), positionable.GetPosition().getY());

  Node next = GetHead();
  while (next != null && next.GetNext() != null && next != this) {
    point.setY(point.getY() - ((ChatBubble)next).ComputeHeight(g.getFont()) - (MARGIN * 4));
    next = next.GetNext();
  }

  Point newPoint = new Point(point.getX(), point.getY());
  ChatBubble.RenderBubble(g, text, newPoint, dimension);
}
 
开发者ID:Pheelbert,项目名称:chatterino,代码行数:14,代码来源:ChatBubble.java

示例9: RenderBubble

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
static void RenderBubble(Graphics g, String text, Point point, Dimension sizeOffset) {
  g.setColor(Color.white);
  if (!text.isEmpty()) {
    int textFontHeight = g.getFont().getLineHeight();

    int totalLineCount = Math.round((text.length() - 1) / (float) MAX_TEXT_PER_LINE) + 1;
    float textY = point.getY() - sizeOffset.height - (textFontHeight / 3.0f) - (totalLineCount * textFontHeight);
    int maxLineWidth = 0;
    int lineCount = 0;
    for (int i = 0; i < text.length(); i += MAX_TEXT_PER_LINE) {
      int start = i;
      int end = Math.min(text.length(), start + ((lineCount + 1) * MAX_TEXT_PER_LINE));
      float currentLineY = textY + (lineCount * textFontHeight) - MARGIN;
      String lineText = text.substring(start, end);
      maxLineWidth = Math.max(maxLineWidth, g.getFont().getWidth(lineText));
      g.drawString(lineText, computeCurrentLineX(point, sizeOffset, maxLineWidth), currentLineY);
      lineCount++;
    }

    float rectX = computeCurrentLineX(point, sizeOffset, maxLineWidth) - MARGIN;
    float rectY = textY - (textFontHeight * (totalLineCount - 1)) - MARGIN;
    if (totalLineCount > 1) {
      rectY += textFontHeight;
    }
    float rectWidth = maxLineWidth + (MARGIN * 2);
    float rectHeight = (textFontHeight * totalLineCount) + (MARGIN * 2);
    g.drawRoundRect(rectX, rectY, rectWidth, rectHeight, 1);
  }
}
 
开发者ID:Pheelbert,项目名称:chatterino,代码行数:30,代码来源:ChatBubble.java

示例10: mouseMoved

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
/** Mouse listener methods */
public void mouseMoved(int oldx, int oldy, int newx, int newy) {
	if (this.currentStone != null) {
		Point newPosition = getGridAlignedCoordinates(newx, newy);
		this.currentStone.setX((int) newPosition.getX());
		this.currentStone.setY((int) newPosition.getY());
	}
}
 
开发者ID:DominikHorn,项目名称:Go,代码行数:9,代码来源:ClientMain.java

示例11: makeNewStone

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
private void makeNewStone(GameContainer gc) {
	Point newPosition = getGridAlignedCoordinates(gc.getInput().getMouseX(), gc.getInput().getMouseY());
	if (this.currentStone == null) {
		if (this.blacksTurn)
			this.currentStone = new BlackStone((int) newPosition.getX(), (int) newPosition.getY());
		else
			this.currentStone = new WhiteStone((int) newPosition.getX(), (int) newPosition.getY());
	}
}
 
开发者ID:DominikHorn,项目名称:Go,代码行数:10,代码来源:ClientMain.java

示例12: GameEntity

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
/**
 * The default constructor. Sets the spawn point to the center of the screen.
 */
public GameEntity(){
	startPoint = new Point(Game.getScreenWidth() / 2, Game.getScreenHeight() / 2);
	width = 0;
	height = 0;
	movementVector = new Vector(0,0);
	collisionBox = new ArrayList<CollisionShape>();
}
 
开发者ID:dstumpff,项目名称:VortexGameLibrary,代码行数:11,代码来源:GameEntity.java

示例13: Camera

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
/**
 * A constructor that takes an entity. The Camera's point will be located at the center of the GameEntity.
 * 
 * @param entity The GameEntity to base this Camera's position on
 */
public Camera(GameEntity entity){
	super();
	localX = 0;
	localY = 0;
	viewport = new Point(Game.getScreenWidth(), Game.getScreenHeight());
	globalX = Math.round((entity.getX() + localX + (entity.getWidth() / 2)));
	globalY = Math.round((entity.getY() + localY + (entity.getHeight() / 2)));
	magnification = 1.0f;
	this.entity = entity;
	if(entity != null){
		entity.attachCamera(this);
	}
}
 
开发者ID:dstumpff,项目名称:VortexGameLibrary,代码行数:19,代码来源:Camera.java

示例14: putTextureInSheet

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
private void putTextureInSheet(Image sheet, TmpTexture texture) {
if (texture == null) {
    return;
}

if (texture.height * texture.numImages > maximumYOffset) {
    this.maximumYOffset = texture.height * texture.numImages;
}

// Overflowed, lets move down and reset to left side
if (currentSheetX + texture.width > SHEET_SIZE) {
    currentSheetY += maximumYOffset;
    currentSheetX = 0;
}

texture.setSpriteSheetCoords(new Point(currentSheetX, currentSheetY));

for (int i = 0; i < texture.numImages; i++) {
    Image img = texture.getByIndex(i);

    int deployX = currentSheetX;
    int deployY = currentSheetY + (i * img.getHeight());

    // Copy texture into sheet
    try {
	sheet.getGraphics().drawImage(img, deployX, deployY);
    } catch (SlickException e) {
	e.printStackTrace();
    }    
}

Rectangle r = new Rectangle(currentSheetX, currentSheetY, texture.width, texture.height * texture.numImages);
this.texturesBounds.add(r);

currentSheetX += texture.width;
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:37,代码来源:Theater.java

示例15: putShpTextureInSheetDissected

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
private void putShpTextureInSheetDissected(Image sheet, ShpTexture texture) {
if (texture == null) {
    return;
}

if (texture.height * texture.numImages > maximumYOffset) {
    this.maximumYOffset = texture.height * texture.numImages;
}

// Overflowed, lets move down and reset to left side
if (currentSheetX + texture.width > SHEET_SIZE) {
    currentSheetY += maximumYOffset;
    currentSheetX = 0;
}

this.shpTexturesPoints.put(texture.getTextureName(), new Point(currentSheetX, currentSheetY));

for (int i = 0; i < texture.numImages; i++) {
    Image img = texture.getAsImage(i, null);

    int deployX = currentSheetX;
    int deployY = currentSheetY + (i * img.getHeight());

    // Copy texture into sheet
    try {
	sheet.getGraphics().drawImage(img, deployX, deployY);
    } catch (SlickException e) {
	e.printStackTrace();
    }    
}

Rectangle r = new Rectangle(currentSheetX, currentSheetY, texture.width, texture.height * texture.numImages);
this.texturesBounds.add(r);

currentSheetX += texture.width;
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:37,代码来源:Theater.java


注:本文中的org.newdawn.slick.geom.Point类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。