예제 #1
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0.39f, 0.58f, 0.92f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Update deltaTime & animationTime
    deltaTime = Gdx.graphics.getDeltaTime();
    animationTime += Gdx.graphics.getDeltaTime();

    // Store Spritesheet to sprite
    sprite = new Sprite(animation.getKeyFrame(animationTime, true));
    sprite.setPosition(xPosition, 0);
    sprite.setScale(1.8f);

    // Set camera to batch and undate camera
    batch.setProjectionMatrix(camera.combined);
    camera.update();

    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render(background);
    tiledMapRenderer.render(foreground);

    // Display on Screen
    batch.begin();
    sprite.draw(batch);
    batch.end();

    // update xPosition
    xPosition = xPosition + (speed * deltaTime);

    HUDBatch.begin();
    font1.draw(HUDBatch, "SCORE:100", 100, 450);
    HUDBatch.end();
  }
예제 #2
0
 @Override
 public void render() {
   // wall and door tests
   if (nWy[0] > 0) {
     if (nPx > nWx[0] && nPx + 11 < nWx[0] + 35 && nPy == nWy[0]) {
       if (nKn[1] == 0) {
         nDy = 0;
         nHy--;
         nPy = nWy[0] - 1;
         camera.translate(0, -1);
         System.out.println("hit door");
       } else if (nKn[1] > 0) {
         nKn[1]--;
         for (int w = 0; w < 2; w++) {
           if (nKn[1] == w) {
             imgNum[0] = new Texture("Num " + nKn[w] + ".png");
           }
           nWy[0] = -10000;
         }
       }
     }
   }
   // camera and tiled
   camera.translate(nDx, nDy);
   nPx = nPx + nDx;
   nPy = nPy + nDy;
   nHx = nHx + nDx;
   nHy = nHy + nDy;
   for (int i = 0; i < 2; i++) {
     nNx[i] = nNx[i] + nDx;
     nNy[i] = nNy[i] + nDy;
   }
   camera.update();
   tiledMapRenderer.setView(camera);
   tiledMapRenderer.render();
   batch.setProjectionMatrix(camera.combined);
   batch.begin();
   batch.draw(imgBaseWall[0], nWx[0], nWy[0]);
   batch.draw(imgEnemy, nEx, nEy);
   batch.draw(imgPlayer, nPx, nPy);
   batch.draw(imgHud, nHx, nHy);
   batch.draw(imgNum[0], nHx + 24, nHy);
   batch.draw(imgNum[1], nHx + 48, nHy);
   batch.draw(imgNum[2], nHx + 71, nHy);
   batch.draw(imgBaseKey[0], nKx[0], nKy[0]);
   spMenu.draw(batch);
   batch.end();
 }
  @Override
  public void render() {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glClearColor(1, 1, 1, 1);
    // Show the map
    TiledMapRenderer mapRender = MapManager.getMap("zelda");
    mapRender.setView(m_camera);
    myAnimator.setMap(mapRender, m_camera);

    m_batch.begin();
    /*Sprite sprite = SpriteManager.getSprite("mogloo") ;
    sprite.setPosition(50.f, 50.f) ;
    sprite.draw(m_batch) ;*/
    myAnimator.render();
    m_batch.end();
  }
예제 #4
0
  @Override
  public void render(SpriteBatch batch) {
    batch.end();
    mapRenderer.setView(camera);
    mapRenderer.render();
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    shapeRenderer.setColor(Color.BLUE);
    for (Rectangle rect : collisions) {
      shapeRenderer.rect(rect.x, rect.y, rect.getWidth(), rect.getHeight());
    }

    shapeRenderer.end();
    batch.begin();
    drawDebugInformation(batch);
    for (Entity entity : entities) {
      entity.render(batch);
    }
  }
  @Override
  public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    camera.position.set(circleBody.getPosition().x, circleBody.getPosition().y, 0);
    camera.update();
    renderer.render(world, camera.combined);
    System.out.println(
        "player.getPosition().x = "
            + player.getPosition().x
            + "\nplayer.getPosition().y = "
            + player.getPosition().y
            + "\ncamera.position = "
            + camera.position);
    Sprite sprite;
    sprite = (Sprite) circleBody.getUserData();
    // set position and width and height and makes sure it is in the center
    sprite.setBounds(
        convertToWorld(circleBody.getPosition().x) - sprite.getWidth() / 2,
        convertToWorld(circleBody.getPosition().y) - sprite.getHeight() / 2,
        convertToWorld(circleShape.getRadius() * 2),
        convertToWorld(circleShape.getRadius() * 2));

    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render();

    System.out.println(
        "Bouncing circle: " + circleBody.getMass() + "\n" + "Player: " + player.getMass());

    // world.step(1/45f, 6, 2);
    world.step(Gdx.graphics.getDeltaTime(), 4, 4);
    player.setAwake(true);
    // camera.project(point.set(player.getPosition().x, player.getPosition().y, 0));

    // logger.log();
    batch.begin();
    // Circle.draw(batch);
    sprite.draw(batch);
    batch.end();
  }
예제 #6
0
  @Override
  public void render() {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.graphics.setTitle(String.format(GAME_TITLE, Gdx.graphics.getFramesPerSecond()));
    world.step(TIME_STEP, 8, 3);

    viewport.getCamera().position.x =
        ninjaRabbit.getBody() == null
            ? 0.0f
            : ninjaRabbit.getBody().getPosition().x + viewport.getWorldWidth() / 4.0f;
    viewport.getCamera().update();
    batch.setProjectionMatrix(viewport.getCamera().combined);

    tileMapRenderer.setView((OrthographicCamera) viewport.getCamera());
    tileMapRenderer.render();

    batch.begin();
    ninjaRabbit.update(batch);
    batch.end();

    b2dRenderer.render(world, viewport.getCamera().combined);
  }
예제 #7
0
  @Override
  public void render(float delta) {

    camera.update();
    Vector2 clickLocation = ZombieAttack.getClickLocation();

    // refreshing open gl screen
    Gdx.gl20.glClearColor(0, 102 / 255f, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // rendering map
    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render();

    ZombieAttack.money = buttons.setSharpTurret(ZombieAttack.money, camera, towerList);
    ZombieAttack.money = buttons.setMissileTurret(ZombieAttack.money, camera, towerList);
    ZombieAttack.money = buttons.setIceTurret(ZombieAttack.money, camera, towerList);
    ZombieAttack.money = buttons.setFlameTurret(ZombieAttack.money, camera, towerList);
    money = "Money: $" + ZombieAttack.money;

    // spawning zombies
    if (!zombieList1.waveBreak() && !zombieList.waveBreak()) {
      zombieList.spawnZombie(-20, 168, Direction.RIGHT);
      zombieList1.spawnZombie(-20, 424, Direction.RIGHT);
    }
    if (zombieList.isLevelFinished() && zombieList1.isLevelFinished()) {
      musicManager.stop();
      optionsPreferences.setCurrentLevel(6);
      if (optionsPreferences.getLevel() <= optionsPreferences.getCurrentLevel())
        optionsPreferences.setLevel(7);
      ((Game) Gdx.app.getApplicationListener()).setScreen(new NextLevel(new sand1()));
    }
    towerList.drawFOV(camera);

    batch.begin();
    {
      batch.draw(ui, 0, 0);
      batch.draw(ui, 0, 543, 800, 58);

      waveString = "Wave  " + zombieList.getCurrentWave();
      zombieString = "Zombies  " + (zombieList.getZombiesLeft() + zombieList1.getZombiesLeft());
      playerLifeString = "Lives " + playerLife;

      // Display labels
      fontLabel.setColor(0.0f, 0.7f, 0.05f, 1.0f);
      fontLabel.draw(batch, money, 620, 570);
      fontLabel.setColor(1.0f, 1.0f, 1.0f, 1.0f);
      fontLabel.draw(batch, waveString, 0, 598);
      fontLabel.draw(batch, zombieString, 0, 570);
      fontLabel.setColor(1.0f, 0.0f, 0.0f, 1.0f);
      fontLabel.draw(batch, playerLifeString, 620, 600);

      // updating the projectiles and turrets
      towerList.updateProjectiles(delta, zombieList);
      towerList.updateProjectiles(delta, zombieList1);

      if (rand.nextInt(2) == 0) {
        towerList.updateTurrets(clickLocation, batch, delta, zombieList1);
        towerList.updateTurrets(clickLocation, batch, delta, zombieList);
      } else {
        towerList.updateTurrets(clickLocation, batch, delta, zombieList);
        towerList.updateTurrets(clickLocation, batch, delta, zombieList1);
      }
      towerList.drawTowers(batch, delta);

      //	rendering zombie
      Iterator<Zombie> iter = zombieList.iterator();
      while (iter.hasNext()) {
        RegZombie z = (RegZombie) iter.next();
        // zombieList.spawnZombie(-20, 168, Direction.RIGHT);
        z.changeToY(226, 168, Direction.UP);
        z.changeToX(226, 240, Direction.RIGHT);
        z.changeToY(546, 240, Direction.DOWN);
        z.changeToX(546, 168, Direction.RIGHT);
        z.move(batch, delta);
        if (z.health <= 0) {
          dyingSound.play(ZombieEffects.ZOMBIEDYING);
          iter.remove();
          ZombieAttack.money += 5;
          money = "Money: $ " + ZombieAttack.money;
          ++zombieList.zombiesKilled;
        }
        if (z.dx > 805) {
          iter.remove();
          --playerLife;
          if (playerLife <= 0)
            ((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver(new water3()));
        }
      }

      Iterator<Zombie> iter1 = zombieList1.iterator();
      while (iter1.hasNext()) {
        RegZombie z1 = (RegZombie) iter1.next();
        z1.changeToY(226, 424, Direction.DOWN);
        z1.changeToX(226, 368, Direction.RIGHT);
        z1.changeToY(546, 368, Direction.UP);
        z1.changeToX(546, 424, Direction.RIGHT);
        z1.move(batch, delta);
        if (z1.health <= 0) {
          iter1.remove();
          ZombieAttack.money += 10;
          money = "Money: $ " + ZombieAttack.money;
          ++zombieList1.zombiesKilled;
        }
        if (z1.dx > 805) {
          iter1.remove();
          --playerLife;
          if (playerLife <= 0)
            ((Game) Gdx.app.getApplicationListener()).setScreen(new GameOver(new water3()));
        }
      }
      infoText.draw(batch, 0);
      if (zombieList.waveBreak() && zombieList1.waveBreak())
        if (zombieList.getWaveBreakTimeLeft() > zombieList1.getWaveBreakTimeLeft())
          infoText.draw(batch, zombieList.getWaveBreakTimeLeft());
        else infoText.draw(batch, zombieList1.getWaveBreakTimeLeft());
    }
    batch.end(); // end drawing level

    zombieList.drawHealth(camera);
    zombieList1.drawHealth(camera);

    // tower buttons
    stage.act();
    stage.draw();

    ZombieAttack.moneyCheat();
  }
예제 #8
0
  public void Update(float delta) {
    if (m_FadeIn < 1) {
      m_FadeIn += delta / 10;
      m_BackgroundMusic.setVolume(m_GameScreen.m_Settings.m_BackgroundMusicVolume * m_FadeIn);
    }
    // update and render the tilemap
    m_TiledMapRenderer.setView(m_GameScreen.m_Camera);
    m_TiledMapRenderer.render();

    // update physics system
    m_PhysicsWorld.step(1f / 60f, 6, 2);

    // update and render the artemis entity system
    m_ArtemisWorld.setDelta(delta);
    m_ArtemisWorld.process();

    m_SpineRenderSystem.process();

    m_GameScreen.m_Camera.update();
    m_GameScreen.GetSpriteBatch().setProjectionMatrix(m_GameScreen.m_Camera.combined);

    // update the player's light distance from watch
    float distance = 225;

    if (!m_WatchSpine.m_State.getAnimation().getName().contentEquals("tick")) {
      m_ClockTicking = false;
    }

    if (m_WatchSpine.m_State.getAnimation().getName().contentEquals("tick")) {
      if (!m_ClockTicking) {
        m_ClockTick.play(m_GameScreen.m_Settings.m_GameSoundVolume / 2);
        m_ClockTicking = true;
      }
      float time = m_WatchSpine.m_State.getTime();
      if (time < 10.0f) {
        float timePercentageComplete = (10 - time) / 10.0f;
        distance += (timePercentageComplete * 300);
        m_LightPowerDistance = timePercentageComplete * 300;
      }
    } else if (m_WatchSpine.m_State.getAnimation().getName().contentEquals("wind")) {
      float time = m_WatchSpine.m_State.getTime();
      float timePercentageComplete = time / m_WatchSpine.m_State.getAnimation().getDuration();
      distance += (timePercentageComplete * 300);
      m_LightPowerDistance = timePercentageComplete * 300;
    }

    // update the players light distance sensor
    m_PlayerEntity
        .m_LightDistanceSensor
        .getShape()
        .setRadius((m_LightPowerDistance * WORLD_TO_BOX) / 2);

    if (m_PlayerEntity.m_Entity != null) {
      BodyComponent bodyComponent = m_PlayerEntity.m_Entity.getComponent(BodyComponent.class);
      if (bodyComponent != null) {
        bodyComponent.m_Light.setDistance(distance * WORLD_TO_BOX);
      }
    }

    // render the lighting
    m_RayHandler.setCombinedMatrix(m_GameScreen.m_Camera.combined.scl(BOX_TO_WORLD));
    m_RayHandler.updateAndRender();

    // draw border
    m_BorderSprite.setColor(1, 1, 1, m_FadeIn * 0.5f);
    m_BorderSprite.setPosition(
        m_GameScreen.m_Camera.position.x - 400, m_GameScreen.m_Camera.position.y - 300);
    m_GameScreen.GetSpriteBatch().begin();
    m_BorderSprite.draw(m_GameScreen.GetSpriteBatch());
    m_GameScreen.GetSpriteBatch().end();

    // draw the vials
    m_VialOne.m_Skeleton.getColor().set(1, 1, 1, m_FadeIn * 0.75f);
    m_VialOne.m_Skeleton.setX(m_GameScreen.m_Camera.position.x - 375);
    m_VialOne.m_Skeleton.setY(m_GameScreen.m_Camera.position.y - 275);
    m_VialOne.m_Skeleton.getRootBone().setRotation(m_VialOne.m_Rotation);
    m_VialOne.m_State.update(Gdx.graphics.getDeltaTime());
    m_VialOne.m_State.apply(m_VialOne.m_Skeleton);
    m_VialOne.m_Skeleton.updateWorldTransform();

    m_VialTwo.m_Skeleton.getColor().set(1, 1, 1, m_FadeIn * 0.75f);
    m_VialTwo.m_Skeleton.setX(m_GameScreen.m_Camera.position.x - 305);
    m_VialTwo.m_Skeleton.setY(m_GameScreen.m_Camera.position.y - 275);
    m_VialTwo.m_Skeleton.getRootBone().setRotation(m_VialTwo.m_Rotation);
    m_VialTwo.m_State.update(Gdx.graphics.getDeltaTime());
    m_VialTwo.m_State.apply(m_VialTwo.m_Skeleton);
    m_VialTwo.m_Skeleton.updateWorldTransform();

    m_VialThree.m_Skeleton.getColor().set(1, 1, 1, m_FadeIn * 0.75f);
    m_VialThree.m_Skeleton.setX(m_GameScreen.m_Camera.position.x - 390);
    m_VialThree.m_Skeleton.setY(m_GameScreen.m_Camera.position.y - 205);
    m_VialThree.m_Skeleton.getRootBone().setRotation(m_VialThree.m_Rotation);
    m_VialThree.m_State.update(Gdx.graphics.getDeltaTime());
    m_VialThree.m_State.apply(m_VialThree.m_Skeleton);
    m_VialThree.m_Skeleton.updateWorldTransform();

    // draw watch last
    m_WatchSpine.m_Skeleton.setX(m_GameScreen.m_Camera.position.x + 300);
    m_WatchSpine.m_Skeleton.setY(m_GameScreen.m_Camera.position.y + 200);
    m_WatchSpine.m_State.update(Gdx.graphics.getDeltaTime());
    m_WatchSpine.m_State.apply(m_WatchSpine.m_Skeleton);
    m_WatchSpine.m_Skeleton.updateWorldTransform();
    m_GameScreen.GetSpriteBatch().begin();
    m_SpineRenderSystem.m_Renderer.draw(m_GameScreen.GetSpriteBatch(), m_VialOne.m_Skeleton);
    m_SpineRenderSystem.m_Renderer.draw(m_GameScreen.GetSpriteBatch(), m_VialTwo.m_Skeleton);
    m_SpineRenderSystem.m_Renderer.draw(m_GameScreen.GetSpriteBatch(), m_VialThree.m_Skeleton);
    m_SpineRenderSystem.m_Renderer.draw(m_GameScreen.GetSpriteBatch(), m_WatchSpine.m_Skeleton);
    m_GameScreen.GetSpriteBatch().end();
  }