コード例 #1
0
  public void computeBoundaries() {
    min.set(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
    max.set(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);

    for (CubeVertex vert : verts) {

      // x coord
      if (vert.getPosition()[0] < min.x) {
        min.x = vert.getPosition()[0];
      } else if (vert.getPosition()[0] > max.x) {
        max.x = vert.getPosition()[0];
      }

      // y coord
      if (vert.getPosition()[1] < min.y) {
        min.y = vert.getPosition()[1];
      } else if (vert.getPosition()[1] > max.y) {
        max.y = vert.getPosition()[1];
      }

      // z coord
      if (vert.getPosition()[2] < min.z) {
        min.z = vert.getPosition()[2];
      } else if (vert.getPosition()[2] > max.z) {
        max.z = vert.getPosition()[2];
      }
    }

    mean.set((max.x + min.x) / 2f, (max.y + min.y) / 2f, (max.z + min.z) / 2f);
    center.set(min.x + mean.x, min.y + mean.y, min.z + mean.z);
  }
コード例 #2
0
  @Override
  public void getAabb(Transform t, Vector3 aabbMin, Vector3 aabbMax) {
    Stack stack = Stack.enter();
    Vector3 tmp = stack.allocVector3();

    Vector3 halfExtents = stack.allocVector3();
    halfExtents.set(getRadius(), getRadius(), getRadius());
    VectorUtil.setCoord(halfExtents, upAxis, getRadius() + getHalfHeight());

    halfExtents.x += getMargin();
    halfExtents.y += getMargin();
    halfExtents.z += getMargin();

    Matrix3 abs_b = stack.allocMatrix3();
    abs_b.set(t.basis);
    MatrixUtil.absolute(abs_b);

    Vector3 center = t.origin;
    Vector3 extent = stack.allocVector3();

    MatrixUtil.getRow(abs_b, 0, tmp);
    extent.x = tmp.dot(halfExtents);
    MatrixUtil.getRow(abs_b, 1, tmp);
    extent.y = tmp.dot(halfExtents);
    MatrixUtil.getRow(abs_b, 2, tmp);
    extent.z = tmp.dot(halfExtents);

    aabbMin.set(center).sub(extent);
    aabbMax.set(center).add(extent);
    stack.leave();
  }
コード例 #3
0
ファイル: PlayDetector.java プロジェクト: nstolpe/ghoststory
 /**
  * Handles mouse button input.
  *
  * @param deltaX
  * @param deltaY
  * @param button
  * @return
  */
 protected boolean process(float deltaX, float deltaY, int button) {
   if (button == rotateButton) {
     tmpV1.set(screen.active().direction).crs(screen.active().up).y = 0f;
     screen.active().rotateAround(target, tmpV1.nor(), deltaY * rotateAngle);
     screen.active().rotateAround(target, Vector3.Y, deltaX * -rotateAngle);
   } else if (button == translateButton) {
     screen
         .active()
         .translate(
             tmpV1
                 .set(screen.active().direction)
                 .crs(screen.active().up)
                 .nor()
                 .scl(-deltaX * translateUnits));
     screen.active().translate(tmpV2.set(screen.active().up).scl(-deltaY * translateUnits));
     if (translateTarget) target.add(tmpV1).add(tmpV2);
   } else if (button == interactButton) {
     /**
      * @TODO Make the interact button interact here. No zooming. zoom code.
      * screen.active().translate(tmpV1.set(screen.active().direction).scl(deltaY *
      * translateUnits));
      */
   }
   if (autoUpdate) screen.active().update();
   return true;
 }
コード例 #4
0
  private void setStaticProjectionAndCamera(Graphics graphics, Application app, GL10 gl) {
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    // x=left-right, y=up-down, z=back-forward
    camera.far = 1000000;
    camera.position.set(0, 7f + 0, 9f + 0);
    // camera.direction.set(0, 0, -4f).sub(camera.position).nor();
    camera.fieldOfView = 67;
    float orbitRadius = (new Vector3(0, 0, 0).dst(camera.position));
    camera.position.set(new Vector3(0, 0, 0));

    camera.rotate(Splash.cameraHorizAngle, 0, 1, 0);
    Vector3 orbitReturnVector = new Vector3(0, 0, 0);
    orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius));
    camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z);
    camera.update();
    camera.apply(gl);

    orbitRadius = (new Vector3(0, 0, 0)).dst(camera.position);
    camera.position.set(new Vector3(0, 0, 0));
    camera.rotate(Splash.cameraVertAngle, 1, 0, 0);
    orbitReturnVector = new Vector3(0, 0, 0);
    orbitReturnVector.set(camera.direction.tmp().mul(-orbitRadius));
    camera.translate(orbitReturnVector.x, orbitReturnVector.y, orbitReturnVector.z);
    camera.update();
    camera.apply(gl);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    Splash.cameraHorizAngle = 0;
    Splash.cameraVertAngle = 0;
  }
コード例 #5
0
ファイル: OptionsScreen.java プロジェクト: agmcleod/ld25
 @Override
 public boolean touchDown(int x, int y, int arg2, int arg3) {
   camera.unproject(mousePos.set(x, y, 0));
   if (backButton.contains(mousePos.x, mousePos.y)) {
     goBack();
   }
   ObjectMap.Entries<String, Rectangle> entries = bindingButtons.entries();
   boolean focusedAnOption = false;
   while (entries.hasNext()) {
     ObjectMap.Entry<String, Rectangle> entry = entries.next();
     Rectangle bounds = entry.value;
     camera.unproject(mousePos.set(x, y, 0));
     if (bounds.contains(mousePos.x, mousePos.y)) {
       this.focused = true;
       focusedAnOption = true;
       this.focusedBox.setY(bounds.y);
       this.focusedBox.setX(bounds.x);
       BitmapFont.TextBounds b = font.getBounds(entry.key);
       this.focusedBox.setHeight(b.height);
       this.focusedBox.setWidth(b.width);
       this.focusedAction = entry.key;
     }
   }
   if (!focusedAnOption) {
     this.focused = false;
   }
   return false;
 }
コード例 #6
0
  @Override
  public Vector3 localGetSupportingVertexWithoutMargin(Vector3 vec0, Vector3 out) {
    Stack stack = Stack.enter();
    Vector3 supVec = out;
    supVec.set(0f, 0f, 0f);

    float maxDot = -1e30f;

    Vector3 vec = stack.alloc(vec0);
    float lenSqr = vec.len2();
    if (lenSqr < 0.0001f) {
      vec.set(1f, 0f, 0f);
    } else {
      float rlen = 1f / (float) Math.sqrt(lenSqr);
      vec.scl(rlen);
    }

    Vector3 vtx = stack.allocVector3();
    float newDot;

    float radius = getRadius();

    Vector3 tmp1 = stack.allocVector3();
    Vector3 tmp2 = stack.allocVector3();
    Vector3 pos = stack.allocVector3();

    {
      pos.set(0f, 0f, 0f);
      VectorUtil.setCoord(pos, getUpAxis(), getHalfHeight());

      VectorUtil.mul(tmp1, vec, localScaling);
      tmp1.scl(radius);
      tmp2.set(vec).scl(getMargin());
      vtx.set(pos).add(tmp1);
      vtx.sub(tmp2);
      newDot = vec.dot(vtx);
      if (newDot > maxDot) {
        maxDot = newDot;
        supVec.set(vtx);
      }
    }
    {
      pos.set(0f, 0f, 0f);
      VectorUtil.setCoord(pos, getUpAxis(), -getHalfHeight());

      VectorUtil.mul(tmp1, vec, localScaling);
      tmp1.scl(radius);
      tmp2.set(vec).scl(getMargin());
      vtx.set(pos).add(tmp1);
      vtx.sub(tmp2);
      newDot = vec.dot(vtx);
      if (newDot > maxDot) {
        maxDot = newDot;
        supVec.set(vtx);
      }
    }
    stack.leave();
    return out;
  }
コード例 #7
0
ファイル: Zombies.java プロジェクト: manakeri/Zombicalypse
 public Zombie(City _city) {
   position = new Vector3();
   direction = new Vector3();
   direction.set(TGame.rand.nextFloat(), 0, TGame.rand.nextFloat());
   do {
     position.set(TGame.rand.nextFloat(), 0, TGame.rand.nextFloat());
   } while (!_city.isRoad(position.x, position.z));
   state = 0;
 }
コード例 #8
0
ファイル: SwarmSystem.java プロジェクト: davebaol/ld34
 private void updateCamZoom(float newZoom) {
   OrthographicCamera c = cam.camera;
   c.unproject(zTmp1.set(cs.xy.x, cs.xy.y, 0));
   c.zoom = newZoom;
   c.update();
   c.unproject(zTmp2.set(cs.xy.x, cs.xy.y, 0));
   c.translate(zTmp1.sub(zTmp2));
   c.update();
 }
コード例 #9
0
 @Override
 public boolean touchDragged(int x, int y, int pointer) {
   camera.unproject(curr.set(x, y, 0));
   if (!(last.x == -1 && last.y == -1 && last.z == -1)) {
     camera.unproject(delta.set(last.x, last.y, 0));
     delta.sub(curr);
     camera.position.add(delta.x, delta.y, 0);
   }
   last.set(x, y, 0);
   return false;
 }
コード例 #10
0
    @Override
    public boolean touchDown(int screenX, int screenY, int pointer, int button) {
      touchDown.set(screenX, screenY, 0);
      cam.unproject(touchDown);
      toolLock = true;

      switch (current_Tool) {
        case SELECT:
          boolean selected = false;
          touchDown.set(screenX, screenY, 0);
          cam.unproject(touchDown);

          for (Selectable n : controller.levelObjects) {
            if (n.contains(touchDown.x, touchDown.y)) {
              if (n == controller.selection) {
                current_Tool = E_TOOL.TRANSLATE;
                selected = true;
              } else {
                controller.setSelection(n);
                selected = true;
              }
            }
          }

          if (selected == false) {
            controller.setSelection(null);
            current_Tool = E_TOOL.PAN;
          } else {
            if (controller.isSelectionShape()) {
              shape_Type = ((Shape) controller.selection).type;
            } else if (controller.isSelectionPoint()) {
              point_Type = ((Point) controller.selection).type;
            }
          }
          break;
        case RECTANGLE:
          controller.createBox(
              shape_Type, snapToGrid(touchDown.x), snapToGrid(touchDown.y), 2, 2, 0, 0);
          break;
        case CIRCLE:
          controller.createCircle(
              shape_Type, snapToGrid(touchDown.x), snapToGrid(touchDown.y), 2, 0, 0);
          break;
        case POINT:
          controller.createPoint(
              point_Type, "default", snapToGrid(touchUp.x), snapToGrid(touchUp.y));
          break;
      }

      return false;
    }
コード例 #11
0
ファイル: WorldInitSystem.java プロジェクト: Namek/teddy
  @Override
  protected void initialize() {
    Vector3 vect3 = new Vector3();

    collisionSystem.relations.connectGroups(CollisionGroups.TEDDY, CollisionGroups.TOYS);

    entityFactory.createTeddy(vect3.set(0.5f, 0f, -0.2f));
    entityFactory.createRoom();

    Entity airplane = entityFactory.createToy("airplane", vect3.set(0.5f, 0f, -6.4f), true);
    Entity alien = entityFactory.createToy("alien", vect3.set(8.5f, 0f, -9.4f), true);
    Entity workbench = entityFactory.createToy("workbench", vect3.set(18.5f, 0f, -5.4f), false);

    // TODO create furniture, obstacles, etc.
  }
コード例 #12
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(1f, 1f, 1f, 0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camera.combined);
    // menu goes here
    batch.begin();
    batch.setColor(Color.GREEN);
    batch.draw(continueButton, 0, MyGdxGame.hR * 3 / 4, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(newGameButton, 0, MyGdxGame.hR / 2, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(optionsButton, 0, MyGdxGame.hR / 4, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(exitButton, 0, 0, MyGdxGame.wR, MyGdxGame.hR / 4);

    batch.end();

    if (Gdx.input.justTouched()) {
      Vector3 touchPos = new Vector3();
      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      //			camera.unproject(touchPos);
      if (touchPos.y < MyGdxGame.hR / 4) {
        game.setScreen(MyGdxGame.gameScreen);
      }
      if (touchPos.y > MyGdxGame.hR / 4 && touchPos.y < MyGdxGame.hR / 2) {
        MyGdxGame.gameScreen = new GameScreen(game, MyGdxGame.getLandscapeGenerator());
        game.setScreen(MyGdxGame.gameScreen);
      }
      if (touchPos.y < MyGdxGame.hR * 3 / 4 && touchPos.y > MyGdxGame.hR / 2) {
        game.setScreen(MyGdxGame.optionsScreen);
      }
      if (touchPos.y > MyGdxGame.hR * 3 / 4) {
        Gdx.app.exit();
      }
    }
  }
コード例 #13
0
ファイル: Box2DTest.java プロジェクト: WaDelma/libgdx
  @Override
  public boolean touchDown(int x, int y, int pointer, int newParam) {
    // translate the mouse coordinates to world coordinates
    testPoint.set(x, y, 0);
    camera.unproject(testPoint);

    // ask the world which bodies are within the given
    // bounding box around the mouse pointer
    hitBody = null;
    world.QueryAABB(
        callback, testPoint.x - 0.1f, testPoint.y - 0.1f, testPoint.x + 0.1f, testPoint.y + 0.1f);

    // if we hit something we create a new mouse joint
    // and attach it to the hit body.
    if (hitBody != null) {
      MouseJointDef def = new MouseJointDef();
      def.bodyA = groundBody;
      def.bodyB = hitBody;
      def.collideConnected = true;
      def.target.set(testPoint.x, testPoint.y);
      def.maxForce = 1000.0f * hitBody.getMass();

      mouseJoint = (MouseJoint) world.createJoint(def);
      hitBody.setAwake(true);
    } else {
      for (Body box : boxes) world.destroyBody(box);
      boxes.clear();
      createBoxes();
    }

    return false;
  }
コード例 #14
0
ファイル: IngameScreen.java プロジェクト: blevine0001/space
    @Override
    public boolean mouseMoved(int screenX, int screenY) {

      if (controls == ControlScheme.MOUSE_AIM) {
        Vector3 touchPos = new Vector3();
        touchPos.set(screenX, screenY, 0);
        camera.unproject(touchPos);

        player.accSpeed =
            80; // ;(float)Math.sqrt((touchPos.x-camera.position.x-originX)*(touchPos.x-camera.position.x-originX)+(touchPos.y-camera.position.y-originY)*(touchPos.y-camera.position.y-originY))*SENSITIVITY;//-150;
        player.MAX_SPEED =
            player.accSpeed =
                (float)
                        Math.sqrt(
                            (touchPos.x - camera.position.x - originX)
                                    * (touchPos.x - camera.position.x - originX)
                                + (touchPos.y - camera.position.y - originY)
                                    * (touchPos.y - camera.position.y - originY))
                    * SENSITIVITY;
        if (player.MAX_SPEED > 500) {
          player.MAX_SPEED = 500;
        }
        // player.speed=(float)Math.sqrt((touchPos.x-camera.position.x-originX)*(touchPos.x-camera.position.x-originX)+(touchPos.y-camera.position.y-originY)*(touchPos.y-camera.position.y-originY))*SENSITIVITY;
        player.desAngle =
            MathUtils.atan2(
                (touchPos.y - camera.position.y - originY),
                (touchPos.x - camera.position.x - originX));

        // rotate the player acording to his angle
        player.setRotation(MathUtils.radDeg * player.angle - 90);
      }

      return false;
    }
コード例 #15
0
  @Override
  public void render(float delta) {
    // TODO Auto-generated method stub

    if (Gdx.input.justTouched()) {
      guiCam.unproject(touch.set(Gdx.input.getX(), Gdx.input.getY(), 0));
      if (startbutton.contains(touch)) {
        maingame.setScreen(maingame.mainscene);
        return;
      }
    }

    GL10 gl = Gdx.graphics.getGL10();
    gl.glClearColor(0, 0, 0, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    /*
     * Actualiza los parametros de la camara
     * y los enlaza al objeto de renderizado batcher
     * */
    guiCam.update();
    this.batcher.setProjectionMatrix(this.guiCam.combined);
    /*
     * Desactiva las trasnparencias
     * */
    batcher.disableBlending();
    batcher.begin();
    batcher.draw(Assets.background, 0, 0, 10, 15);
    batcher.end();
    batcher.enableBlending();
    batcher.begin();
    batcher.draw(Assets.title, 1, 6, 8, 8);
    batcher.draw(Assets.start, x, 3, 6, 3);
    x += c;
    batcher.end();
  }
コード例 #16
0
  @Override
  public void calculateLocalInertia(float mass, Vector3 inertia) {
    // as an approximation, take the inertia of the box that bounds the spheres

    Stack stack = Stack.enter();
    Transform ident = stack.allocTransform();
    ident.setIdentity();

    float radius = getRadius();

    Vector3 halfExtents = stack.allocVector3();
    halfExtents.set(radius, radius, radius);
    VectorUtil.setCoord(halfExtents, getUpAxis(), radius + getHalfHeight());

    float margin = BulletGlobals.CONVEX_DISTANCE_MARGIN;

    float lx = 2f * (halfExtents.x + margin);
    float ly = 2f * (halfExtents.y + margin);
    float lz = 2f * (halfExtents.z + margin);
    float x2 = lx * lx;
    float y2 = ly * ly;
    float z2 = lz * lz;
    float scaledmass = mass * 0.08333333f;

    inertia.x = scaledmass * (y2 + z2);
    inertia.y = scaledmass * (x2 + z2);
    inertia.z = scaledmass * (x2 + y2);
    stack.leave();
  }
コード例 #17
0
  private void updateRunning(float deltaTime) {
    switch (world.state) {
      case World.WORLD_STATE_RUNNING:
        if (Gdx.input.justTouched()) {
          if (shots > 0) {
            guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));
            Assets.shoot.play();
            shots--;
          }
        }
        break;
      case World.WORLD_STATE_ROUND_PAUSE:
        stateTime = 0;
        shots = 3;
        break;
      case World.WORLD_STATE_COUNTING_DUCKS:
        stateTime = 0;
        break;
      case World.WORLD_STATE_ROUND_START:
        state = GAME_READY;
        break;
      case World.WORLD_STATE_GAME_OVER_1:
        stateTime = 0;
        state = GAME_OVER_1;
        Assets.gameOver1.play();
        break;
    }
    // ApplicationType appType = Gdx.app.getType();

    /*
     * Input code
     */
    updateScore();
  }
コード例 #18
0
  public void update(float deltaTime) {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (OverlapTester.pointInRectangle(playBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new GameScreen(game));
        return;
      }
      if (OverlapTester.pointInRectangle(highscoresBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new HighscoresScreen(game));
        return;
      }
      if (OverlapTester.pointInRectangle(helpBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new HelpScreen(game));
        return;
      }
      if (OverlapTester.pointInRectangle(soundBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        Settings.soundEnabled = !Settings.soundEnabled;
        if (Settings.soundEnabled) Assets.music.play();
        else Assets.music.pause();
      }
    }
  }
コード例 #19
0
  private void updatePath(boolean forceUpdate) {
    getCamera().unproject(tmpUnprojection.set(lastScreenX, lastScreenY, 0));
    int tileX = (int) (tmpUnprojection.x / width);
    int tileY = (int) (tmpUnprojection.y / width);
    if (forceUpdate || tileX != lastEndTileX || tileY != lastEndTileY) {
      worldMap.setLevel(0);
      HierarchicalTiledNode startNode = worldMap.getNode(startTileX, startTileY);
      HierarchicalTiledNode endNode = worldMap.getNode(tileX, tileY);
      if (forceUpdate || endNode.type == TiledNode.TILE_FLOOR) {
        if (endNode.type == TiledNode.TILE_FLOOR) {
          lastEndTileX = tileX;
          lastEndTileY = tileY;
        } else {
          endNode = worldMap.getNode(lastEndTileX, lastEndTileY);
        }

        if (metrics)
          if (PathFinderRequestControl.DEBUG)
            System.out.println(
                "------------ Hierarchical Indexed A* Path Finder Metrics ------------");

        requestNewPathFinding(startNode, endNode, 0);
      }
    }
  }
コード例 #20
0
ファイル: Drop.java プロジェクト: hecao/testgithub
  @Override
  public void render() {
    // clear the screen with a dark blue color. The
    // arguments to glClearColor are the red, green
    // blue and alpha component in the range [0,1]
    // of the color to be used to clear the screen.
    Gdx.gl.glClearColor(0, 0, 0.2f, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    // tell the camera to update its matrices.
    camera.update();

    // tell the SpriteBatch to render in the
    // coordinate system specified by the camera.
    batch.setProjectionMatrix(camera.combined);

    // begin a new batch and draw the bucket and
    // all drops
    batch.begin();
    batch.draw(bucketImage, bucket.x, bucket.y);
    for (Rectangle raindrop : raindrops) {
      batch.draw(dropImage, raindrop.x, raindrop.y);
    }
    batch.end();
    //

    // process user input
    if (Gdx.input.isTouched()) {
      Vector3 touchPos = new Vector3();
      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      camera.unproject(touchPos);
      bucket.x = touchPos.x - 48 / 2;
    }
    if (Gdx.input.isKeyPressed(Keys.LEFT)) bucket.x -= 200 * Gdx.graphics.getDeltaTime();
    if (Gdx.input.isKeyPressed(Keys.RIGHT)) bucket.x += 200 * Gdx.graphics.getDeltaTime();

    // make sure the bucket stays within the screen bounds
    if (bucket.x < 0) bucket.x = 0;
    if (bucket.x > 800 - 48) bucket.x = 800 - 48;

    // commit

    // check if we need to create a new raindrop
    if (TimeUtils.nanoTime() - lastDropTime > 1000000000) spawnRaindrop();

    // move the raindrops, remove any that are beneath the bottom edge of
    // the screen or that hit the bucket. In the later case we play back
    // a sound effect as well.
    Iterator<Rectangle> iter = raindrops.iterator();
    while (iter.hasNext()) {
      Rectangle raindrop = iter.next();
      raindrop.y -= 200 * Gdx.graphics.getDeltaTime();
      if (raindrop.y + 48 < 0) iter.remove();
      if (raindrop.overlaps(bucket)) {
        dropSound.play();
        iter.remove();
      }
    }
  }
コード例 #21
0
 private void transformarCoordenadas(int screenX, int screenY) {
   // Transformar las coordenadas de la pantalla física a la cámara
   coordenadas.set(screenX, screenY, 0);
   camara.unproject(coordenadas); // camaraHUD es para los botones
   // Obtiene las coordenadas relativas a la pantalla virtual
   x = coordenadas.x;
   y = coordenadas.y;
 }
コード例 #22
0
 @Override
 public void transition(
     SceneGO previousScene, SceneGO nextScene, TransitionListener transitionListener) {
   super.transition(previousScene, nextScene, transitionListener);
   this.remainingTime = transition.getTime();
   offset.set(800, 0, 0);
   this.addSceneElement(nextScene);
 }
コード例 #23
0
 @Override
 public boolean touchDragged(int screenX, int screenY, int pointer) {
   mCurrentPos.set(screenX, screenY, 0);
   camera.unproject(mCurrentPos);
   camera.position.sub(mCurrentPos.sub(mCamPos));
   camera.update();
   return true;
 }
コード例 #24
0
 private void create(
     final Model model,
     final float mass,
     final float width,
     final float height,
     final float depth) {
   // Create a simple boxshape
   create(model, mass, new btBoxShape(tmpV.set(width * 0.5f, height * 0.5f, depth * 0.5f)));
 }
コード例 #25
0
ファイル: physics.java プロジェクト: weihanli101/FlickyBall
 // ==============================================================================================
 // NOT BOX 2D STUFF JUST COOL THINGS I ADDED TO MAKE THE PROGRAM MORE "FUN"
 public void HandleTouch() {
   float fSprite_Width = sprite.getWidth();
   float fSprite_Height = sprite.getHeight();
   if (Gdx.input.isTouched()) {
     Vector3 touchPos = new Vector3(); // Using vector 3 as a 2-D vector for touch coordinates
     touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
     body.setTransform(touchPos.x - (fSprite_Width / 2), (touchPos.y - (fSprite_Height / 2)), 0);
   }
 }
コード例 #26
0
  private void _touchButton() {
    Long time = System.currentTimeMillis();
    if (time - lastClickTime > 200) {
      lastClickTime = time;

      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      touchPos = viewport.unproject(touchPos);
      dragonWarsEngine.touch(touchPos.x, touchPos.y);
    }
  }
コード例 #27
0
  public void update() {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (nextBounds.contains(touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new MainMenuScreen(game));
      }
    }
  }
コード例 #28
0
ファイル: MeshBuilder.java プロジェクト: nemo808/libgdx
 @Override
 public void circle(
     float width,
     float height,
     float centerX,
     float centerY,
     float centerZ,
     float normalX,
     float normalY,
     float normalZ,
     float tangentX,
     float tangentY,
     float tangentZ,
     float binormalX,
     float binormalY,
     float binormalZ,
     int divisions,
     float angleFrom,
     float angleTo) {
   final float ao = MathUtils.degreesToRadians * angleFrom;
   final float step = (MathUtils.degreesToRadians * (angleTo - angleFrom)) / divisions;
   final Vector3 sx = tempV1.set(tangentX, tangentY, tangentZ).scl(width * 0.5f);
   final Vector3 sy = tempV2.set(binormalX, binormalY, binormalZ).scl(height * 0.5f);
   VertexInfo curr = vertTmp3.set(null, null, null, null);
   curr.hasUV = curr.hasPosition = curr.hasNormal = true;
   curr.uv.set(.5f, .5f);
   curr.position.set(centerX, centerY, centerZ);
   curr.normal.set(normalX, normalY, normalZ);
   final short center = vertex(curr);
   float angle = 0f;
   for (int i = 0; i <= divisions; i++) {
     angle = ao + step * i;
     final float x = MathUtils.cos(angle);
     final float y = MathUtils.sin(angle);
     curr.uv.set(.5f + .5f * x, .5f + .5f * y);
     curr.position
         .set(centerX, centerY, centerZ)
         .add(sx.x * x + sy.x * y, sx.y * x + sy.y * y, sx.z * x + sy.z * y);
     vertex(curr);
     if (i != 0) triangle((short) (vindex - 1), (short) (vindex - 2), center);
   }
 }
コード例 #29
0
  public void update(float deltaTime) {
    if (Gdx.input.justTouched()) {
      guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));

      if (OverlapTester.pointInRectangle(nextBounds, touchPoint.x, touchPoint.y)) {
        Assets.playSound(Assets.clickSound);
        game.setScreen(new MainMenuScreen(game));
        return;
      }
    }
  }
コード例 #30
0
  public void spawnOrb(int x, int y) {
    Vector3 touchPos = new Vector3();
    touchPos.set(x, y, 0);
    camera.unproject(touchPos);

    Orb orb =
        new Orb(new Vector2(touchPos.x, touchPos.y), 10f, new Color(0.4f, 0.6f, .09f, 1.0f), this);
    orbs.add(orb);

    Gdx.app.log("LOG", "Orb Spawned at: (" + touchPos.x + ", " + touchPos.y + ")!");
  }