Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.jme3.app.SimpleApplication;
- import com.jme3.font.BitmapText;
- import com.jme3.material.Material;
- import com.jme3.math.*;
- import com.jme3.scene.Geometry;
- import com.jme3.scene.Spatial;
- import com.jme3.scene.shape.Box;
- import com.jme3.system.AppSettings;
- public class ShootBulletRun extends SimpleApplication {
- public static void main(String[] args) {
- ShootBulletRun app = new ShootBulletRun();
- //set vSinc on to get stable 60 fps
- AppSettings aps = new AppSettings(true);
- aps.setVSync(true);
- app.setSettings(aps);
- app.start();
- }
- ShootBullet shb;
- //ShootBulletControl sbc;
- Spatial charShoot;
- Material mat_box;
- Box box_char = new Box(Vector3f.ZERO, 1, 1, 1);
- float timer;
- public void shootObj() {
- // Create a blue box Geometry
- charShoot = new Geometry("Box", box_char);
- charShoot.scale(1,1,2);
- mat_box = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
- mat_box.setColor("Color", ColorRGBA.Blue);
- charShoot.setMaterial(mat_box);
- rootNode.attachChild(charShoot);
- }
- @Override
- public void simpleInitApp() {
- shootObj();
- starting();
- shb = new ShootBullet(this);
- }
- @Override
- public void simpleUpdate(float tpf)
- {
- timer += tpf*4f;
- if (timer>0.2f){
- Geometry gm = shb.bullet.clone(false);
- gm.addControl(new ShootBulletControl(gm, charShoot, this));
- // gm.getControl(0).setEnabled(true);
- timer = 0;
- }
- charShoot.rotate(0,2f*tpf,0);
- System.out.println(timer);
- }
- public void starting () {
- guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
- BitmapText ch = new BitmapText(guiFont, false);
- ch.setSize(guiFont.getCharSet().getRenderedSize());
- ch.setText("Shooting Cube!"); // crosshairs
- ch.setColor(new ColorRGBA(1f,0.8f,0.1f,1f));
- ch.setLocalTranslation(settings.getWidth()*0.3f,settings.getHeight()*0.1f,0);
- guiNode.attachChild(ch);
- viewPort.setBackgroundColor(ColorRGBA.Gray);
- flyCam.setMoveSpeed(30);
- cam.setLocation(new Vector3f(0f,3f,30f));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement