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

Java GameMath类代码示例

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

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



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

示例1: proc

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {

	int level = (int) GameMath.gate(0, armor.level, 6);

	if (Dungeon.level.adjacent(attacker.pos, defender.pos)
			&& Random.Int(level / 2 + 5) >= 4) {

		int duration = Random.IntRange(3, 7);

		Buff.affect(attacker, Charm.class, Charm.durationFactor(attacker)
				* duration).object = defender.id();
		attacker.sprite.centerEmitter().start(Speck.factory(Speck.HEART),
				0.2f, 5);

		//duration *= Random.Float(0.5f, 1);

		//Buff.affect(defender, Charm.class, Charm.durationFactor(defender)
		//		* duration).object = attacker.id();
		//defender.sprite.centerEmitter().start(Speck.factory(Speck.HEART),
		//		0.2f, 5);
	}

	return damage;
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:26,代码来源:Affection.java


示例2: zoom

import com.watabou.utils.GameMath; //导入依赖的package包/类
private float zoom( float value ) {

		value = GameMath.gate( PixelScene.minZoom, value, PixelScene.maxZoom );
		UNISTPixelDungeon.zoom((int) (value - PixelScene.defaultZoom));
		camera.zoom( value );

		//Resets character sprite positions with the new camera zoom
		//This is important as characters are centered on a 16x16 tile, but may have any sprite size
		//This can lead to none-whole coordinate, which need to be aligned with the zoom
		for (Char c : Actor.chars()){
			if (c.sprite != null && !c.sprite.isMoving){
				c.sprite.point(c.sprite.worldToCamera(c.pos));
			}
		}

		return value;
	}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:18,代码来源:CellSelector.java


示例3: updateMotion

import com.watabou.utils.GameMath; //导入依赖的package包/类
protected void updateMotion()
{

    float elapsed = Game.elapsed;

    float d = (GameMath.speed(speed.x, acc.x) - speed.x) / 2;
    speed.x += d;
    x += speed.x * elapsed;
    speed.x += d;

    d = (GameMath.speed(speed.y, acc.y) - speed.y) / 2;
    speed.y += d;
    y += speed.y * elapsed;
    speed.y += d;

    angle += angularSpeed * elapsed;
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:18,代码来源:Visual.java


示例4: updateMotion

import com.watabou.utils.GameMath; //导入依赖的package包/类
protected void updateMotion() {
	
	float elapsed = Game.elapsed;
	
	float d = (GameMath.speed( speed.x, acc.x ) - speed.x) / 2;
	speed.x += d;
	x += speed.x * elapsed;
	speed.x += d;
	
	d = (GameMath.speed( speed.y, acc.y ) - speed.y) / 2;
	speed.y += d;
	y += speed.y * elapsed;
	speed.y += d;
	
	angle += angularSpeed * elapsed;
}
 
开发者ID:ConsideredHamster,项目名称:YetAnotherPixelDungeon,代码行数:17,代码来源:Visual.java


示例5: updateMotion

import com.watabou.utils.GameMath; //导入依赖的package包/类
protected void updateMotion() {

        float elapsed = Game.elapsed;

        float d = (GameMath.speed(speed.x, acc.x) - speed.x) / 2;
        speed.x += d;
        x += speed.x * elapsed;
        speed.x += d;

        d = (GameMath.speed(speed.y, acc.y) - speed.y) / 2;
        speed.y += d;
        y += speed.y * elapsed;
        speed.y += d;

        angle += angularSpeed * elapsed;
    }
 
开发者ID:skynet67,项目名称:pixel-dungeon-rebirth,代码行数:17,代码来源:Visual.java


示例6: zoom

import com.watabou.utils.GameMath; //导入依赖的package包/类
private float zoom( float value ) {

		value = GameMath.gate( PixelScene.minZoom, value, PixelScene.maxZoom );
		ShatteredPixelDungeon.zoom((int) (value - PixelScene.defaultZoom));
		camera.zoom( value );

		//Resets character sprite positions with the new camera zoom
		//This is important as characters are centered on a 16x16 tile, but may have any sprite size
		//This can lead to none-whole coordinate, which need to be aligned with the zoom
		for (Char c : Actor.chars()){
			if (c.sprite != null && !c.sprite.isMoving){
				c.sprite.point(c.sprite.worldToCamera(c.pos));
			}
		}

		return value;
	}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:18,代码来源:CellSelector.java


示例7: getDoorCenter

import com.watabou.utils.GameMath; //导入依赖的package包/类
protected final Point getDoorCenter(){
	PointF doorCenter = new PointF(0, 0);

	for (Door door : connected.values()) {
		doorCenter.x += door.x;
		doorCenter.y += door.y;
	}

	Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size());
	if (Random.Float() < doorCenter.x % 1) c.x++;
	if (Random.Float() < doorCenter.y % 1) c.y++;
	c.x = (int) GameMath.gate(left+2, c.x, right-2);
	c.y = (int)GameMath.gate(top+2, c.y, bottom-2);

	return c;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:17,代码来源:SewerPipeRoom.java


示例8: getDoorCenter

import com.watabou.utils.GameMath; //导入依赖的package包/类
protected final Point getDoorCenter(){
	PointF doorCenter = new PointF(0, 0);

	for (Door door : connected.values()) {
		doorCenter.x += door.x;
		doorCenter.y += door.y;
	}

	Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size());
	if (Random.Float() < doorCenter.x % 1) c.x++;
	if (Random.Float() < doorCenter.y % 1) c.y++;
	c.x = (int)GameMath.gate(left+1, c.x, right-1);
	c.y = (int)GameMath.gate(top+1, c.y, bottom-1);

	return c;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:17,代码来源:TunnelRoom.java


示例9: screenToTile

import com.watabou.utils.GameMath; //导入依赖的package包/类
public int screenToTile(int x, int y, boolean wallAssist ) {
	PointF p = camera().screenToCamera( x, y ).
		offset( this.point().negate() ).
		invScale( SIZE );
	
	//snap to the edges of the tilemap
	p.x = GameMath.gate(0, p.x, Dungeon.level.width()-0.001f);
	p.y = GameMath.gate(0, p.y, Dungeon.level.height()-0.001f);

	int cell = (int)p.x + (int)p.y * Dungeon.level.width();

	if (wallAssist
			&& map != null
			&& DungeonTileSheet.wallStitcheable(map[cell])){

		if (cell + mapWidth < size
				&& p.y % 1 >= 0.75f
				&& !DungeonTileSheet.wallStitcheable(map[cell + mapWidth])){
			cell += mapWidth;
		}

	}

	return cell;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:26,代码来源:DungeonTilemap.java


示例10: screenToTile

import com.watabou.utils.GameMath; //导入依赖的package包/类
public int screenToTile(int x, int y, boolean wallAssist ) {
	PointF p = camera().screenToCamera( x, y ).
			offset( this.point().negate() ).
			invScale( SIZE );
	
	//snap to the edges of the tilemap
	p.x = GameMath.gate(0, p.x, Dungeon.level.width()-0.001f);
	p.y = GameMath.gate(0, p.y, Dungeon.level.height()-0.001f);

	int cell = (int)p.x + (int)p.y * Dungeon.level.width();

	if (wallAssist
			&& map != null
			&& DungeonTileSheet.wallStitcheable(map[cell])){

		if (cell + mapWidth < size
				&& p.y % 1 >= 0.75f
				&& !DungeonTileSheet.wallStitcheable(map[cell + mapWidth])){
			cell += mapWidth;
		}

	}

	return cell;
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon-gdx,代码行数:26,代码来源:DungeonTilemap.java


示例11: onDrag

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
protected void onDrag(Touch t) {

	camera.target = null;

	if (pinching) {

		float curSpan = PointF.distance(touch.current, another.current);
		camera.zoom(GameMath.gate(PixelScene.minZoom, startZoom * curSpan
				/ startSpan, PixelScene.maxZoom));

	} else {

		if (!dragging
				&& PointF.distance(t.current, t.start) > dragThreshold) {

			dragging = true;
			lastPos.set(t.current);

		} else if (dragging) {
			camera.scroll.offset(PointF.diff(lastPos, t.current).invScale(
					camera.zoom));
			lastPos.set(t.current);
		}
	}

}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:28,代码来源:CellSelector.java


示例12: onDrag

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
protected void onDrag( Touch t ) {
	 
	camera.target = null;

	if (pinching) {

		float curSpan = PointF.distance( touch.current, another.current );
		camera.zoom( GameMath.gate(
			PixelScene.minZoom,
			startZoom * curSpan / startSpan,
			PixelScene.maxZoom ) );

	} else {
	
		if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) {
			
			dragging = true;
			lastPos.set( t.current );
			
		} else if (dragging) {
			camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) );
			lastPos.set( t.current );
		}
	}
	
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:28,代码来源:CellSelector.java


示例13: randomArmor

import com.watabou.utils.GameMath; //导入依赖的package包/类
public static Armor randomArmor(int floorSet) {

		floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1);

		try {
			Armor a = (Armor)Category.ARMOR.classes[Random.chances(floorSetTierProbs[floorSet])].newInstance();
			a.random();
			return a;
		} catch (Exception e) {
			UNISTPixelDungeon.reportException(e);
			return null;
		}
	}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:14,代码来源:Generator.java


示例14: randomWeapon

import com.watabou.utils.GameMath; //导入依赖的package包/类
public static Weapon randomWeapon(int floorSet) {

		floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1);

		try {
			Category c = wepTiers[Random.chances(floorSetTierProbs[floorSet])];
			Weapon w = (Weapon)c.classes[Random.chances(c.probs)].newInstance();
			w.random();
			return w;
		} catch (Exception e) {
			UNISTPixelDungeon.reportException(e);
			return null;
		}
	}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:15,代码来源:Generator.java


示例15: onDrag

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
protected void onDrag( NoosaInputProcessor.Touch t ) {
	 
	camera.target = null;

	if (pinching) {

		float curSpan = PointF.distance( touch.current, another.current );
		camera.zoom( GameMath.gate( 
			PixelScene.minZoom, 
			startZoom * curSpan / startSpan, 
			PixelScene.maxZoom ) );

	} else {
	
		if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) {
			
			dragging = true;
			lastPos.set( t.current );
			
		} else if (dragging) {
			camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) );
			lastPos.set( t.current );	
		}	
	}
	
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:28,代码来源:CellSelector.java


示例16: onDrag

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
protected void onDrag( Touch t ) {
	 
	camera.target = null;

	if (pinching) {

		float curSpan = PointF.distance( touch.current, another.current );
		camera.zoom( GameMath.gate( 
			PixelScene.minZoom, 
			startZoom * curSpan / startSpan, 
			PixelScene.maxZoom ) );

	} else {
	
		if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) {
			
			dragging = true;
			lastPos.set( t.current );
			
		} else if (dragging) {
			camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) );
			lastPos.set( t.current );	
		}	
	}
	
}
 
开发者ID:ConsideredHamster,项目名称:YetAnotherPixelDungeon,代码行数:28,代码来源:CellSelector.java


示例17: onDrag

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
protected void onDrag( Touch t ) {
	 
	camera.target = null;

	if (pinching) {

		float curSpan = PointF.distance( touch.current, another.current );
		float zoom = (startZoom * curSpan / startSpan);
		camera.zoom( GameMath.gate(
			PixelScene.minZoom,
				zoom - (zoom % 0.1f),
			PixelScene.maxZoom ) );

	} else {
	
		if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) {
			
			dragging = true;
			lastPos.set( t.current );
			
		} else if (dragging) {
			camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) );
			lastPos.set( t.current );
		}
	}
	
}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:29,代码来源:CellSelector.java


示例18: randomArmor

import com.watabou.utils.GameMath; //导入依赖的package包/类
public static Armor randomArmor(int floorSet) {

		floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1);

		try {
			Armor a = (Armor)Category.ARMOR.classes[Random.chances(floorSetTierProbs[floorSet])].newInstance();
			a.random();
			return a;
		} catch (Exception e) {
			ShatteredPixelDungeon.reportException(e);
			return null;
		}
	}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:14,代码来源:Generator.java


示例19: randomWeapon

import com.watabou.utils.GameMath; //导入依赖的package包/类
public static Weapon randomWeapon(int floorSet) {

		floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1);

		try {
			Category c = wepTiers[Random.chances(floorSetTierProbs[floorSet])];
			Weapon w = (Weapon)c.classes[Random.chances(c.probs)].newInstance();
			w.random();
			return w;
		} catch (Exception e) {
			ShatteredPixelDungeon.reportException(e);
			return null;
		}
	}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:15,代码来源:Generator.java


示例20: proc

import com.watabou.utils.GameMath; //导入依赖的package包/类
@Override
public int proc(Armor armor, Char attacker, Char defender, int damage) {

	int level = (int) GameMath.gate(0, armor.level(), 6);

	if (Dungeon.level.adjacent(attacker.getPos(), defender.getPos()) && Random.Int(level / 2 + 5) >= 4) {

		int duration = Random.IntRange(2, 5);

		float attackerFactor = 1;
		float defenderFactor = 1;

		if(defender.buff(DriedRose.OneWayLoveBuff.class)!= null) {
			attackerFactor *= 2;
			defenderFactor *= 0;
		}

		if(defender.buff(DriedRose.OneWayCursedLoveBuff.class)!=null) {
			attackerFactor *= 0;
			defenderFactor *= 2;
		}

		Buff.affect(attacker, Charm.class, Charm.durationFactor(attacker) * duration * attackerFactor);
		attacker.getSprite().centerEmitter().start(Speck.factory(Speck.HEART), 0.2f, 5);

		Buff.affect(defender, Charm.class, Random.Float(Charm.durationFactor(defender) * duration / 2, duration) * defenderFactor);
		defender.getSprite().centerEmitter().start(Speck.factory(Speck.HEART), 0.2f, 5);
	}

	return damage;
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:32,代码来源:Affection.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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