热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

com.badlogic.gdx.math.MathUtils.floor()方法的使用及代码示例

本文整理了Java中com.badlogic.gdx.math.MathUtils.floor()方法的一些代码示例,展示了MathUtils.floor()的具体用法。这些代码示例主要来源于Gith

本文整理了Java中com.badlogic.gdx.math.MathUtils.floor()方法的一些代码示例,展示了MathUtils.floor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MathUtils.floor()方法的具体详情如下:
包路径:com.badlogic.gdx.math.MathUtils
类名称:MathUtils
方法名:floor

MathUtils.floor介绍

[英]Returns the largest integer less than or equal to the specified float. This method will only properly floor floats from -(2^14) to (Float.MAX_VALUE - 2^14).
[中]返回小于或等于指定浮点的最大整数。此方法只能正确地将地板浮动从-(2^14)调整到(Float.MAX_VALUE-2^14)。

代码示例

代码示例来源:origin: mstojcevich/Radix

@Override
public int getChunkPosition(float value) {
int subtraction = MathUtils.floor(value) & (CHUNK_SIZE-1);
return MathUtils.floor(value - subtraction);
}

代码示例来源:origin: SquidPony/SquidLib

protected int translateX(int screenX) {
return MathUtils.floor((screenX + offsetX) / cellWidth);
}

代码示例来源:origin: SquidPony/SquidLib

protected int translateY(int screenY) {
return MathUtils.floor((screenY + offsetY) / cellHeight);
}

代码示例来源:origin: SquidPony/SquidLib

/**
* Converts the provided color into a three dimensional coordinate point for
* use in the Bresenham algorithms.
*
* @param color
* @return
*/
private Coord3D scolorToCoord3D(SColor color) {
return new Coord3D(MathUtils.floor(color.r * 255), MathUtils.floor(color.g * 255), MathUtils.floor(color.b * 255));
}

代码示例来源:origin: mstojcevich/Radix

/**
* Performs a scalar product on this vector
* @param f Scale factor
* @return {@code this}
*/
public Vec3i scale(float f) {
set(MathUtils.floor(x * f), MathUtils.floor(y * f), MathUtils.floor(z * f));
return this;
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void reset() {
plotted = 0;
index.x = MathUtils.floor((pos.x - off.x) / size.x);
index.y = MathUtils.floor((pos.y - off.y) / size.y);
index.z = MathUtils.floor((pos.z - off.z) / size.z);
float ax = index.x * size.x + off.x;
float ay = index.y * size.y + off.y;
float az = index.z * size.z + off.z;
max.x = (sign.x > 0) ? ax + size.x - pos.x : pos.x - ax;
max.y = (sign.y > 0) ? ay + size.y - pos.y : pos.y - ay;
max.z = (sign.z > 0) ? az + size.z - pos.z : pos.z - az;
max.set(max.x / dir.x, max.y / dir.y, max.z / dir.z);
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void renderSouth(int atlasIndex, float x1, float y1, float x2, float y2, float z, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
int zi = MathUtils.floor(z);
int xi = MathUtils.floor(x1);
int yi = MathUtils.floor(y1);
IWorld world = RadixClient.getInstance().getWorld();
IChunk chunk = world.getChunk(xi, zi);
short meta = 0;
try {
meta = chunk.getMeta(xi & (world.getChunkSize() - 1), yi, zi & (world.getChunkSize() - 1));
} catch (CoordinatesOutOfBoundsException e) {
e.printStackTrace();
}
super.renderSouth(atlasIndex, x1, y1, x2, y1 + getHeight(meta), z, lightLevel, pcld, builder);
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void renderEast(int atlasIndex, float z1, float y1, float z2, float y2, float x, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
int zi = MathUtils.floor(z1);
int xi = MathUtils.floor(x - 1);
int yi = MathUtils.floor(y1);
IWorld world = RadixClient.getInstance().getWorld();
IChunk chunk = world.getChunk(xi, zi);
short meta = 0;
try {
meta = chunk.getMeta(xi & (world.getChunkSize() - 1), yi, zi & (world.getChunkSize() - 1));
} catch (CoordinatesOutOfBoundsException e) {
e.printStackTrace();
}
super.renderEast(atlasIndex, z1, y1, z2, y1 + getHeight(meta), x, lightLevel, pcld, builder);
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void renderTop(int atlasIndex, float x1, float z1, float x2, float z2, float y, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
int zi = MathUtils.floor(z1);
int xi = MathUtils.floor(x1);
int yi = MathUtils.floor(y - 1);
IWorld world = RadixClient.getInstance().getWorld();
IChunk chunk = world.getChunk(xi, zi);
short meta = 0;
try {
meta = chunk.getMeta(xi & (world.getChunkSize()-1), yi, zi & (world.getChunkSize()-1));
} catch (CoordinatesOutOfBoundsException e) {
e.printStackTrace();
}
super.renderTop(atlasIndex, x1, z1, x2, z2, y - (1 - getHeight(meta)), lightLevel, pcld, builder);
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void renderNorth(int atlasIndex, float x1, float y1, float x2, float y2, float z, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
int zi = MathUtils.floor(z - 1);
int xi = MathUtils.floor(x1);
int yi = MathUtils.floor(y1);
IWorld world = RadixClient.getInstance().getWorld();
IChunk chunk = world.getChunk(xi, zi);
short meta = 0;
try {
meta = chunk.getMeta(xi & (world.getChunkSize() - 1), yi, zi & (world.getChunkSize() - 1));
} catch (CoordinatesOutOfBoundsException e) {
e.printStackTrace();
}
super.renderNorth(atlasIndex, x1, y1, x2, y1 + getHeight(meta), z, lightLevel, pcld, builder);
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void renderWest(int atlasIndex, float z1, float y1, float z2, float y2, float x, float lightLevel, PerCornerLightData pcld, MeshBuilder builder) {
int zi = MathUtils.floor(z1);
int xi = MathUtils.floor(x);
int yi = MathUtils.floor(y1);
IWorld world = RadixClient.getInstance().getWorld();
IChunk chunk = world.getChunk(xi, zi);
short meta = 0;
try {
meta = chunk.getMeta(xi & (world.getChunkSize() - 1), yi, zi & (world.getChunkSize() - 1));
} catch (CoordinatesOutOfBoundsException e) {
e.printStackTrace();
}
super.renderWest(atlasIndex, z1, y1, z2, y1 + getHeight(meta), x, lightLevel, pcld, builder);
}

代码示例来源:origin: mstojcevich/Radix

public int getBlockInHead(IWorld world) {
int x = MathUtils.floor(getPosition().getX());
int z = MathUtils.floor(getPosition().getZ());
int y = MathUtils.floor(getPosition().getY() + HEIGHT);
IChunk chunk = world.getChunk(x, z);
if (chunk != null) {
if (y >= world.getHeight()) return 0;
try {
return chunk.getBlockId(x & (world.getChunkSize() - 1), y, z & (world.getChunkSize() - 1));
} catch (BlockStorage.CoordinatesOutOfBoundsException e) {
e.printStackTrace();
return 0;
}
} else {
return 0;
}
}

代码示例来源:origin: mstojcevich/Radix

public boolean checkCollision(Vector3 pos) {
if (pos.y >= RadixClient.getInstance().getWorld().getHeight() || pos.y <0)
return false;
int x = MathUtils.floor(pos.x);
int y = MathUtils.floor(pos.y);
int z = MathUtils.floor(pos.z);
IChunk chunk = game.getWorld().getChunk(x, z);
if (chunk == null)
return true;
int cx = x & (game.getWorld().getChunkSize() - 1);
int cz = z & (game.getWorld().getChunkSize() - 1);
try {
Block block = chunk.getBlock(cx, y, cz);
return block != null && block.isSolid() && block.calculateBoundingBox(chunk, cx, y, cz).contains(pos);
} catch (CoordinatesOutOfBoundsException ex) {
ex.printStackTrace();
return true;
}
}

代码示例来源:origin: mstojcevich/Radix

@Override
public void run() {
try {
while (!game.isDone()) {
if (game.getPlayer() != null && game.getWorld() != null && !game.isRemote()) {
int viewDistance = game.getSettingsManager().getVisualSettings().getViewDistance();
EntityPosition playerPos = game.getPlayer().getPosition();
if (currentChunk == null) {
game.getWorld().loadChunks(playerPos, viewDistance);
currentChunk = game.getWorld().getChunk(MathUtils.floor(playerPos.getX()), MathUtils.floor(playerPos.getZ()));
} else {
if (Math.abs((int) currentChunk.getStartPosition().x - game.getPlayer().getPosition().getX()) > game.getWorld().getChunkSize() || Math.abs((int) currentChunk.getStartPosition().z - game.getPlayer().getPosition().getZ()) > game.getWorld().getChunkSize()) {
currentChunk = game.getWorld().getChunk(MathUtils.floor(playerPos.getX()), MathUtils.floor(playerPos.getZ()));
game.getWorld().loadChunks(playerPos, viewDistance);
}
}
}
Thread.sleep(1000);
}
} catch (Exception e) {
RadixClient.getInstance().handleCriticalException(e);
}
}

代码示例来源:origin: mstojcevich/Radix

public boolean checkDeltaCollision(LivingEntity e, float deltaX, float deltaY, float deltaZ) {
BoundingBox curBB = e.calculateBoundingBox();
BoundingBox newBB = new BoundingBox(curBB.min.cpy().add(deltaX, deltaY, deltaZ), curBB.max.cpy().add(deltaX, deltaY, deltaZ));
boolean collideSuccess = false;
int x = MathUtils.floor(e.getPosition().x);
int y = MathUtils.floor(e.getPosition().y);
int z = MathUtils.floor(e.getPosition().z);
IChunk chunk = game.getWorld().getChunk(x, z);
if (chunk == null)
return true;
int cx = x & (game.getWorld().getChunkSize() - 1);
int cz = z & (game.getWorld().getChunkSize() - 1);
try {
Block block = chunk.getBlock(cx, y, cz);
for (Vector3 corner : getCorners(newBB)) {
collideSuccess = collideSuccess || checkCollision(corner);
}
return collideSuccess ||
(block != null && block.isSolid()
&& block.calculateBoundingBox(chunk, cx, y, cz).intersects(newBB));
} catch(CoordinatesOutOfBoundsException ex) {
ex.printStackTrace();
return true;
}
}

代码示例来源:origin: mstojcevich/Radix

if (yVelocity <0) {// falling down and failed because we hit the ground
int x = MathUtils.floor(getPosition().getX());
int y = MathUtils.floor(getPosition().getY());
int z = MathUtils.floor(getPosition().getZ());
int cx = x & (RadixClient.getInstance().getWorld().getChunkSize() - 1);
int cz = z & (RadixClient.getInstance().getWorld().getChunkSize() - 1);

代码示例来源:origin: mstojcevich/Radix

public int getBlockInFeet(IWorld world) {
int x = MathUtils.floor(getPosition().getX());
int y = MathUtils.floor(getPosition().getY());
int z = MathUtils.floor(getPosition().getZ());
IChunk chunk = world.getChunk(x, z);
if (chunk != null && y int cx = x & (world.getChunkSize() - 1);
int cz = z & (world.getChunkSize() - 1);
try {
int id = chunk.getBlockId(cx, y, cz);
Block block = RadixAPI.instance.getBlock(id);
if (block == null) return 0;
BoundingBox blockBox = block.calculateBoundingBox(chunk, cx, y, cz);
float halfWidth = width / 2f;
Vector3 bottomBackLeft = getPosition().cpy().add(-halfWidth, 0, -halfWidth);
Vector3 bottomBackRight = bottomBackLeft.cpy().add(width, 0, 0);
Vector3 bottomFrOntRight= bottomBackRight.cpy().add(0, 0, width);
Vector3 bottomFrOntLeft= bottomBackLeft.cpy().add(width, 0, 0);
boolean inFeet = blockBox.contains(bottomBackLeft) || blockBox.contains(bottomBackRight) || blockBox.contains(bottomFrontLeft) || blockBox.contains(bottomFrontRight);
return inFeet ? id : 0;
} catch (BlockStorage.CoordinatesOutOfBoundsException ex) {
ex.printStackTrace();
return 0;
}
} else {
return 0;
}
}

代码示例来源:origin: yichen0831/Bomberman_libGdx

public void createBomb(Player player, float x, float y) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.KinematicBody;
bodyDef.position.set(MathUtils.floor(x) + 0.5f, MathUtils.floor(y) + 0.5f);

代码示例来源:origin: yichen0831/Bomberman_libGdx

public Entity createRemoteBomb(Player player, float x, float y) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.KinematicBody;
bodyDef.position.set(MathUtils.floor(x) + 0.5f, MathUtils.floor(y) + 0.5f);

代码示例来源:origin: yichen0831/Bomberman_libGdx

public void createPowerUp(float x, float y) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.DynamicBody;
bodyDef.position.set(MathUtils.floor(x) + 0.5f, MathUtils.floor(y) + 0.5f);

推荐阅读
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • 关于我们EMQ是一家全球领先的开源物联网基础设施软件供应商,服务新产业周期的IoT&5G、边缘计算与云计算市场,交付全球领先的开源物联网消息服务器和流处理数据 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • Windows7 64位系统安装PLSQL Developer的步骤和注意事项
    本文介绍了在Windows7 64位系统上安装PLSQL Developer的步骤和注意事项。首先下载并安装PLSQL Developer,注意不要安装在默认目录下。然后下载Windows 32位的oracle instant client,并解压到指定路径。最后,按照自己的喜好对解压后的文件进行命名和压缩。 ... [详细]
  • 本文介绍了OpenStack的逻辑概念以及其构成简介,包括了软件开源项目、基础设施资源管理平台、三大核心组件等内容。同时还介绍了Horizon(UI模块)等相关信息。 ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • Servlet多用户登录时HttpSession会话信息覆盖问题的解决方案
    本文讨论了在Servlet多用户登录时可能出现的HttpSession会话信息覆盖问题,并提供了解决方案。通过分析JSESSIONID的作用机制和编码方式,我们可以得出每个HttpSession对象都是通过客户端发送的唯一JSESSIONID来识别的,因此无需担心会话信息被覆盖的问题。需要注意的是,本文讨论的是多个客户端级别上的多用户登录,而非同一个浏览器级别上的多用户登录。 ... [详细]
  • 本文介绍了使用C++Builder实现获取USB优盘序列号的方法,包括相关的代码和说明。通过该方法,可以获取指定盘符的USB优盘序列号,并将其存放在缓冲中。该方法可以在Windows系统中有效地获取USB优盘序列号,并且适用于C++Builder开发环境。 ... [详细]
  • 工作经验谈之-让百度地图API调用数据库内容 及详解
    这段时间,所在项目中要用到的一个模块,就是让数据库中的内容在百度地图上展现出来,如经纬度。主要实现以下几点功能:1.读取数据库中的经纬度值在百度上标注出来。2.点击标注弹出对应信息。3 ... [详细]
  • 国庆节到了,安利一个Android的自动动态授权插件
    Android的老铁都知道申请权限时,除了要在AndroidManifest添加权限,还需要在activity中通过requestpermission对 ... [详细]
  • 程度|也就是_论文精读:Neural Architecture Search without Training
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了论文精读:NeuralArchitectureSearchwithoutTraining相关的知识,希望对你有一定的参考价值。 ... [详细]
  • OrbitDBPeer 2 Peer Database using CRDTs
    2019独角兽企业重金招聘Python工程师标准Apeer-to-peerdatabaseforthedecentralizedwebOrbitDBisaserverless ... [详细]
author-avatar
低契一巴掌
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有