Merge
This commit is contained in:
commit
fde77577de
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.scene.control.AbstractControl;
|
||||
|
||||
/**
|
||||
* Does nothing just to cleanup controls
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public abstract class BaseControl extends AbstractControl {
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.input.InputManager;
|
||||
import com.jme3.input.KeyInput;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.AnalogListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseAxisTrigger;
|
||||
import com.jme3.math.Matrix3f;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class PlayerMouseControl extends BaseControl implements AnalogListener {
|
||||
|
||||
private static final String MAPPING_PLAYER_LEFT = "PLAYER_Left";
|
||||
private static final String MAPPING_PLAYER_RIGHT = "PLAYER_Right";
|
||||
private static final String MAPPING_PLAYER_UP = "PLAYER_UP";
|
||||
private static final String MAPPING_PLAYER_DOWN = "PLAYER_Down";
|
||||
private static final float PITCH_LIMIT = 1.4f;
|
||||
/**/
|
||||
private float speed;
|
||||
private InputManager inputManager;
|
||||
private Camera cam;
|
||||
private Vector3f initialUpVec;
|
||||
|
||||
public PlayerMouseControl(InputManager inputManager, Camera cam) {
|
||||
this.inputManager = inputManager;
|
||||
this.cam = cam;
|
||||
initMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpatial(Spatial spatial) {
|
||||
super.setSpatial(spatial);
|
||||
initialUpVec = spatial.getLocalRotation().getRotationColumn(1).clone();
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
PlayerMouseControl control = new PlayerMouseControl(inputManager, cam);
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
public void setSpeed(float speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void onAnalog(String name, float value, float tpf) {
|
||||
if (name.equals(MAPPING_PLAYER_LEFT)) {
|
||||
rotateCamera(value, initialUpVec);
|
||||
} else if (name.equals(MAPPING_PLAYER_RIGHT)) {
|
||||
rotateCamera(-value, initialUpVec);
|
||||
} else if (name.equals(MAPPING_PLAYER_UP)) {
|
||||
rotateCamera(-value, spatial.getLocalRotation().getRotationColumn(0));
|
||||
} else if (name.equals(MAPPING_PLAYER_DOWN)) {
|
||||
rotateCamera(value, spatial.getLocalRotation().getRotationColumn(0));
|
||||
}
|
||||
}
|
||||
|
||||
private void initMappings() {
|
||||
inputManager.addMapping(MAPPING_PLAYER_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true),
|
||||
new KeyTrigger(KeyInput.KEY_LEFT));
|
||||
|
||||
inputManager.addMapping(MAPPING_PLAYER_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false),
|
||||
new KeyTrigger(KeyInput.KEY_RIGHT));
|
||||
|
||||
inputManager.addMapping(MAPPING_PLAYER_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false),
|
||||
new KeyTrigger(KeyInput.KEY_UP));
|
||||
|
||||
inputManager.addMapping(MAPPING_PLAYER_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true),
|
||||
new KeyTrigger(KeyInput.KEY_DOWN));
|
||||
inputManager.addListener(this, new String[]{MAPPING_PLAYER_LEFT,
|
||||
MAPPING_PLAYER_RIGHT, MAPPING_PLAYER_UP, MAPPING_PLAYER_DOWN});
|
||||
}
|
||||
|
||||
private void rotateCamera(float value, Vector3f axis) {
|
||||
Matrix3f mat = new Matrix3f();
|
||||
mat.fromAngleNormalAxis(speed * value, axis);
|
||||
|
||||
Vector3f up = spatial.getLocalRotation().getRotationColumn(1);
|
||||
Vector3f left = spatial.getLocalRotation().getRotationColumn(0);
|
||||
Vector3f dir = spatial.getLocalRotation().getRotationColumn(2);
|
||||
|
||||
mat.mult(up, up);
|
||||
mat.mult(left, left);
|
||||
mat.mult(dir, dir);
|
||||
|
||||
Quaternion q = new Quaternion();
|
||||
q.fromAxes(left, up, dir);
|
||||
q.normalizeLocal();
|
||||
|
||||
float[] angles = q.toAngles(null);
|
||||
if (angles[0] < -PITCH_LIMIT) {
|
||||
angles[0] = -PITCH_LIMIT;
|
||||
spatial.setLocalRotation(new Quaternion(angles));
|
||||
} else if (angles[0] > PITCH_LIMIT) {
|
||||
angles[0] = PITCH_LIMIT;
|
||||
spatial.setLocalRotation(new Quaternion(angles));
|
||||
} else {
|
||||
spatial.setLocalRotation(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.helper.MathHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class PlayerMoveControl extends BaseControl {
|
||||
|
||||
private float angle = 0f;
|
||||
|
||||
public PlayerMoveControl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (angle > FastMath.TWO_PI) {
|
||||
angle -= FastMath.TWO_PI;
|
||||
}
|
||||
spatial.setLocalTranslation(MathHelper.calcPointOnCircle(angle, 0f)); //TODO set y-Position
|
||||
//angle += speed //TODO implement
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
final PlayerMoveControl control = new PlayerMoveControl();
|
||||
control.setSpatial(spatial);
|
||||
return control;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.input.InputManager;
|
||||
import com.jme3.input.KeyInput;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
|
||||
private static final String MAPPING_PLAYER_MOUSE_LEFT_CLICK = "PLAYER_Mouse_Left_Click";
|
||||
private static final float maxTimeToOverheat = 3f;
|
||||
/**/
|
||||
private InputManager inputManager;
|
||||
private float timeToOverheat = maxTimeToOverheat;
|
||||
private boolean isShooting = false;
|
||||
|
||||
public PlayerShootControl(InputManager inputmanager) {
|
||||
this.inputManager = inputmanager;
|
||||
initMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (isShooting) {
|
||||
timeToOverheat -= tpf;
|
||||
if (timeToOverheat <= 0) {
|
||||
setShooting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setShooting(boolean isShooting) {
|
||||
this.isShooting = isShooting;
|
||||
spatial.setUserData(UserDataKeys.SHOOTING, isShooting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpatial(Spatial spatial) {
|
||||
super.setSpatial(spatial);
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
PlayerShootControl control = new PlayerShootControl(inputManager);
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if (name.equals(MAPPING_PLAYER_MOUSE_LEFT_CLICK)) {
|
||||
if (isPressed) {
|
||||
setShooting(true);
|
||||
} else {
|
||||
setShooting(false);
|
||||
timeToOverheat = maxTimeToOverheat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initMappings() {
|
||||
inputManager.addMapping(MAPPING_PLAYER_MOUSE_LEFT_CLICK, new MouseButtonTrigger(MouseInput.BUTTON_LEFT),
|
||||
new KeyTrigger(KeyInput.KEY_DOWN));
|
||||
inputManager.addListener(this, new String[]{MAPPING_PLAYER_MOUSE_LEFT_CLICK});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class StarDeathControl extends BaseControl {
|
||||
|
||||
private Node starNode;
|
||||
|
||||
public StarDeathControl(Node starNode) {
|
||||
this.starNode = starNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (spatial.getUserData(UserDataKeys.HITTED)) {
|
||||
//TODO DIE!
|
||||
starNode.detachChild(spatial);
|
||||
}
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
StarDeathControl control = new StarDeathControl(starNode);
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class StarPointControl extends BaseControl {
|
||||
|
||||
private int points = 100; //Todo Change StartPoint at Spawn
|
||||
|
||||
public StarPointControl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (spatial.getUserData(UserDataKeys.HITTED)) {
|
||||
//Todo Check life time and set points
|
||||
}
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
StarPointControl control = new StarPointControl();
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return this.points;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.bounding.BoundingVolume;
|
||||
import com.jme3.collision.CollisionResults;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class WeaponProjectileCollisionControl extends BaseControl {
|
||||
|
||||
private Node starNode;
|
||||
private BoundingVolume boundingVolume;
|
||||
private CollisionResults results;
|
||||
|
||||
public WeaponProjectileCollisionControl(Node starNode) {
|
||||
this.starNode = starNode;
|
||||
this.results = new CollisionResults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpatial(Spatial spatial) {
|
||||
super.setSpatial(spatial);
|
||||
boundingVolume = spatial.getWorldBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
for (Spatial s : starNode.getChildren()) {
|
||||
results.clear();
|
||||
s.collideWith(boundingVolume, results);
|
||||
if (results.size() > 0) {
|
||||
s.setUserData(UserDataKeys.HITTED, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
WeaponProjectileCollisionControl control = new WeaponProjectileCollisionControl(starNode);
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.controls;
|
||||
|
||||
import com.jme3.asset.AssetManager;
|
||||
import com.jme3.input.InputManager;
|
||||
import com.jme3.input.KeyInput;
|
||||
import com.jme3.input.MouseInput;
|
||||
import com.jme3.input.controls.ActionListener;
|
||||
import com.jme3.input.controls.KeyTrigger;
|
||||
import com.jme3.input.controls.MouseButtonTrigger;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Node;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.control.Control;
|
||||
import org.wyrez.shootingstars.helper.UserDataKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Snowsun
|
||||
*/
|
||||
public class WeaponProjectileControl extends BaseControl implements ActionListener {
|
||||
|
||||
private AssetManager assetManager;
|
||||
private Node rootNode;
|
||||
private InputManager inputManager;
|
||||
private Spatial player;
|
||||
|
||||
public WeaponProjectileControl(AssetManager assetManager, Node rootNode, InputManager inputManager) {
|
||||
this.assetManager = assetManager;
|
||||
this.rootNode = rootNode;
|
||||
this.inputManager = inputManager;
|
||||
initMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpatial(Spatial spatial) {
|
||||
super.setSpatial(spatial);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void controlUpdate(float tpf) {
|
||||
if (player.getUserData(UserDataKeys.SHOOTING)) {
|
||||
shoot();
|
||||
} else {
|
||||
rootNode.detachChild(spatial);
|
||||
}
|
||||
}
|
||||
|
||||
public Control cloneForSpatial(Spatial spatial) {
|
||||
WeaponProjectileControl control = new WeaponProjectileControl(assetManager, rootNode, inputManager);
|
||||
spatial.addControl(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if (name.equals("PLAYER_Mouse_Left_Click") && isPressed) {
|
||||
rootNode.attachChild(spatial);
|
||||
} else if (name.equals("PLAYER_Mouse_Left_Click") && !isPressed) {
|
||||
rootNode.detachChild(spatial);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayer(Spatial player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Spatial getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
private void initMappings() {
|
||||
inputManager.addMapping("PLAYER_Mouse_Left_Click", new MouseButtonTrigger(MouseInput.BUTTON_LEFT),
|
||||
new KeyTrigger(KeyInput.KEY_DOWN));
|
||||
inputManager.addListener(this, new String[]{"PLAYER_Mouse_Left_Click"});
|
||||
}
|
||||
|
||||
/*
|
||||
* Fires a projectile
|
||||
*/
|
||||
private void shoot() {
|
||||
spatial.setLocalTranslation(player.getLocalTranslation().add(0, 0, -4));
|
||||
|
||||
Vector3f vectorDifference = new Vector3f(player.getLocalTranslation().subtract(player.getWorldTranslation()));
|
||||
spatial.setLocalTranslation(vectorDifference.addLocal(player.getLocalTranslation()));
|
||||
|
||||
Quaternion worldDiff = new Quaternion(player.getLocalRotation().subtract(player.getWorldRotation()));
|
||||
spatial.setLocalRotation(worldDiff.addLocal(player.getLocalRotation()));
|
||||
|
||||
spatial.move(player.getLocalRotation().getRotationColumn(2).mult(-3.5f));
|
||||
// spatial.move(player.getLocalRotation().getRotationColumn(1).mult(0f));
|
||||
// spatial.move(player.getLocalRotation().getRotationColumn(0).mult(0));
|
||||
// spatial.rotate(0f, FastMath.PI, 0);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.helper;
|
||||
|
||||
import com.jme3.math.FastMath;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class MathHelper {
|
||||
|
||||
public static Vector3f calcPointOnCircle(float radian, float y) {
|
||||
return new Vector3f(FastMath.cos(radian), y, FastMath.sin(radian));
|
||||
}
|
||||
|
||||
public static Vector2f calcPointOnCircle(float radian) {
|
||||
return new Vector2f(FastMath.cos(radian), FastMath.sin(radian));
|
||||
}
|
||||
|
||||
public static float radianToDegree(float radian) {
|
||||
return radian * FastMath.RAD_TO_DEG;
|
||||
}
|
||||
|
||||
public static float degreeToRadian(float degree) {
|
||||
return degree * FastMath.DEG_TO_RAD;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <http://wyrez.org> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.wyrez.shootingstars.helper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class UserDataKeys {
|
||||
|
||||
public static final String HITTED = "isHitted";
|
||||
public static final String SHOOTING = "isShooting";
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user