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


Java Vector2f.add方法代码示例

本文整理汇总了Java中org.joml.Vector2f.add方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2f.add方法的具体用法?Java Vector2f.add怎么用?Java Vector2f.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joml.Vector2f的用法示例。


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

示例1: update

import org.joml.Vector2f; //导入方法依赖的package包/类
@Override
public void update(float delta, Window window, Camera camera, World world) {
    Vector2f movement = new Vector2f();
    if (window.getInput().isKeyDown(GLFW_KEY_LEFT)) {
        movement.add(-10 * delta, 0);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_RIGHT)) {
        movement.add(10 * delta, 0);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_UP)) {
        movement.add(0, 10 * delta);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_DOWN)) {
        movement.add(0, -10 * delta);
    }
    move(movement);

    if(movement.x != 0|| movement.y != 0) {
        useAnimation(ANIM_WALKING);
    } else {
        useAnimation(ANIM_IDLE);
    }

    camera.getPosition().lerp(transform.pos.mul(-world.getScale(), new Vector3f()), 0.05f);
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:26,代码来源:Player.java

示例2: update

import org.joml.Vector2f; //导入方法依赖的package包/类
@Override
public void update(float delta, Window window, Camera camera, World world) {
	Vector2f movement = new Vector2f();
	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_A)){
		movement.add(-10 * delta, 0);
	}
	
	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_D)){
		movement.add(10 * delta, 0);
	}
	
	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_W)){
		movement.add(0, 10 * delta * JUMP_STRENGTH);
	}
	
	movement.add(0, -10 * delta * GRAVITATION);
	
	move(movement);
	if(movement.y > 0){
		useAnimation(ANIM_JETPACK);
	}else if (movement.x != 0){
		useAnimation(ANIM_WALK);
	}else{		
		useAnimation(ANIM_IDLE);
	}		
	camera.getPosition().lerp(transform.pos.mul(-world.getScale(), new Vector3f()), 0.2f);

	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_SPACE)){
		Rocket rocket = new Rocket(1, transform);
	}

}
 
开发者ID:MarcPopescu-Pfeiffer,项目名称:2DGame,代码行数:33,代码来源:Player.java

示例3: update

import org.joml.Vector2f; //导入方法依赖的package包/类
@Override
public void update(float delta, Window window, Camera camera, World world) {
	Vector2f movement = new Vector2f();
	movement.add(0,-15);
	move(movement);
}
 
开发者ID:MarcPopescu-Pfeiffer,项目名称:2DGame,代码行数:7,代码来源:Rocket.java

示例4: update

import org.joml.Vector2f; //导入方法依赖的package包/类
public void update(long delta){
	emitRemaining -= delta;
	
	if(emitRemaining <= 0){
		emitting = false;
	}
	
	double adjustedDelta = delta / 1000d;
	
	Vector2f velDelta = particleVelocity.mul((float)adjustedDelta, new Vector2f());
	
	for(Particle particle : particles){
		particle.position.add(velDelta);
		particle.life -= delta;
		
		if(particle.life <= 0)
			toRemove.add(particle);
	}
	
	particles.removeAll(toRemove);
	toRemove.clear();
	
	if(emitting){
		emitAccumulator -= delta;
		
		if(emitAccumulator <= 0){
			int toMax = (int)(emitAccumulator / emitDelta);
			toMax ++;
			for(int i=0;i<toMax; i++){
				//amount of time the particle has died before appearing
				float calcDeath = i * emitDelta; 
				
				//get a random position in the boundaries
				Vector2f pos = getRandomPosition();
				
				//add the back dated velocity 
				pos.add(particleVelocity.mul(calcDeath, new Vector2f()));
				
				//add the particle to the array
				particles.add(new Particle(pos, particleLife - calcDeath));
			}
			
			emitAccumulator = emitDelta;
		}
	}
}
 
开发者ID:tek256,项目名称:LD38,代码行数:47,代码来源:ParticleSystem.java


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