• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Point类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getTileTextureSheetCoord

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public Point getTileTextureSheetCoord(TileReference<Integer, Byte> tile) {
String tileName = this.tileSet.getTiles().get(Integer.valueOf(tile.getTile()));

TmpTexture t = getTileTmp(tile);

int index = (short) (tile.getIndex() & 0xFF);

if (t != null && t.isInSpriteSheet()) {
    return t.getSpriteSheetCoords();
} else return new Point(-1, -1);
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:12,代码来源:Theater.java


示例17: renderLayer

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
private void renderLayer(Graphics g, HashMap<Pos, Smudge> layer) {
for (Entry<Pos, Smudge> v : layer.entrySet()) {
    Pos pos = v.getKey();
    Smudge smudge = v.getValue();

    int x = (int) pos.getX();
    int y = (int) pos.getY();

    // Check viewport bounds
    if (x < (int) -Main.getInstance().getCamera().offsetX / 24 - 1
	    || x > (int) -Main.getInstance().getCamera().offsetX / 24 + (int) Main.getInstance().getContainer().getWidth()
	    / 24 + 1) {
	continue;
    }

    if (y < (int) -Main.getInstance().getCamera().offsetY / 24 - 1
	    || y > (int) -Main.getInstance().getCamera().offsetY / 24 + (int) Main.getInstance().getContainer().getHeight()
	    / 24 + 1) {
	continue;
    }

    // Don't draw shrouded smudges
    if (Main.getInstance().getPlayer().getShroud() != null && !Main.getInstance().getPlayer().getShroud().isExplored(pos)) {
	continue;
    }

    String textureName = smudge.type + "." + this.map.getTileSet().getSetName().toLowerCase().substring(0, 3);
    Point sheetPoint = map.getTheater().getShpTexturePoint(textureName);

    int sX = (int) sheetPoint.getX();
    int sY = (int) sheetPoint.getY();

    if (sX != -1 && sY != -1) {
	this.map.getTheater().getSpriteSheet().renderInUse(x * 24, y * 24, sX / 24, (sY / 24) + smudge.depth);
    }		    
}	
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:38,代码来源:SmudgeLayer.java


示例18: render

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void render(GameContainer c, Graphics g, Camera camera) {
Color pColor = g.getColor();	
this.theater.getSpriteSheet().startUse();

// Draw tiles layer
for (int y = (int) (-Main.getInstance().getCamera().getOffsetY()) / 24; y < this.getHeight(); y++) {
    for (int x = (int) (-Main.getInstance().getCamera().getOffsetX()) / 24; x < this.getWidth(); x++) {
	// Don't render tile, if it shrouded and surrounding tiles shrouded too
	if (Main.getInstance().getPlayer().getShroud() != null && Main.getInstance().getPlayer().getShroud().isAreaShrouded(x, y, 2, 2)) {
	    continue;
	}

	if ((int) this.mapTiles[x][y].getTile() != 0) {
	    Point sheetPoint = this.theater
		    .getTileTextureSheetCoord(this.mapTiles[x][y]);

	    int index = (int) ((byte) this.mapTiles[x][y].getIndex() & 0xFF);

	    int sX = (int) sheetPoint.getX();
	    int sY = (int) sheetPoint.getY();

	    if (sX != -1 && sY != -1) {
		this.theater.getSpriteSheet().renderInUse(x * 24, y * 24, sX / 24, (sY / 24) + index);
	    }
	    
	    this.resourcesLayer.renderCell(x, y);
	}
    }
}

this.smudges.render(g);

this.theater.getSpriteSheet().endUse();	
//this.theater.getSpriteSheet().draw(24 * 20, 24 * 20);
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:36,代码来源:TileMap.java


示例19: renderMapEntities

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void renderMapEntities(GameContainer c, Graphics g, Camera camera) {
this.theater.getSpriteSheet().startUse();
// Draw map entities
for (MapEntity me : this.mapEntities) {
    int x = me.getX();
    int y = me.getY();

    // Don't draw invisible entities
    if (x < (int) -camera.offsetX / 24 - 2
	    || x > (int) -camera.offsetX / 24 + (int) c.getWidth() / 24 + 2) {
	continue;
    }

    if (y < (int) -camera.offsetY / 24 - 2
	    || y > (int) -camera.offsetY / 24 + (int) c.getHeight() / 24 + 2) {
	continue;
    }

    ShpTexture t = me.getTexture();

    Point sheetPoint = this.theater.getShpTexturePoint(t.getTextureName());

    int sX = (int) sheetPoint.getX();
    int sY = (int) sheetPoint.getY();

    this.theater.getSpriteSheet()
    .getSubImage(sX, sY, t.width, t.height)
    .drawEmbedded(x * 24, y * 24, t.width, t.height);
}

this.theater.getSpriteSheet().endUse();	
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:33,代码来源:TileMap.java


示例20: renderAll

import org.newdawn.slick.geom.Point; //导入依赖的package包/类
public void renderAll(Graphics g) {
// Draw tiles layer
for (int y = 0; y < this.map.getHeight(); y++) {
    for (int x = 0; x < this.map.getWidth(); x++) {
	if (x < (int) -Main.getInstance().getCamera().offsetX / 24 - 1
		|| x > (int) -Main.getInstance().getCamera().offsetX / 24 + (int) Main.getInstance().getContainer().getWidth()
		/ 24 + 1) {
	    continue;
	}

	if (y < (int) -Main.getInstance().getCamera().offsetY / 24 - 1
		|| y > (int) -Main.getInstance().getCamera().offsetY / 24 + (int) Main.getInstance().getContainer().getHeight()
		/ 24 + 1) {
	    continue;
	}

	if (Main.getInstance().getPlayer().getShroud() != null && Main.getInstance().getPlayer().getShroud().isAreaShrouded(x, y, 2, 2)) {
	    continue;
	}

	if (this.resources[x][y] != null) {
	    byte index = (byte) (this.resources[x][y].getFrameIndex() & 0xFF);
	    
	    Point sheetPoint = map.getTheater().getShpTexturePoint(this.resources[x][y].getSpriteName());
	    
	    int sX = (int) sheetPoint.getX();
	    int sY = (int) sheetPoint.getY();

	    if (sX != -1 && sY != -1) {
		this.map.getTheater().getSpriteSheet().renderInUse(x * 24, y * 24, sX / 24, (sY / 24) + index);
	    }		    
	}
    }
}	
   }
 
开发者ID:Cr0s,项目名称:JavaRA,代码行数:36,代码来源:ResourcesLayer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ToDefinition类代码示例发布时间:2022-05-22
下一篇:
Java ServiceLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap