コード例 #1
0
 private void updateMap(GL10 gl, PKImage map, float x, float y) {
   gl.glMatrixMode(GL10.GL_MODELVIEW);
   gl.glLoadIdentity();
   gl.glPushMatrix();
   gl.glScalef(0.25f, 0.25f, 1.0f);
   gl.glTranslatef(x, y, 0.0f);
   gl.glMatrixMode(GL10.GL_TEXTURE);
   gl.glLoadIdentity();
   gl.glTranslatef(0.0f, 0.0f, 0.0f);
   map.draw(gl);
   gl.glPopMatrix();
   gl.glLoadIdentity();
 }
コード例 #2
0
 private void drawGrid(GL10 gl) {
   gl.glMatrixMode(GL10.GL_MODELVIEW);
   gl.glLoadIdentity();
   gl.glPushMatrix();
   gl.glScalef(0.75f, 0.75f, 1.0f);
   gl.glTranslatef(0.165f, 0.085f, 0.0f);
   gl.glMatrixMode(GL10.GL_TEXTURE);
   gl.glLoadIdentity();
   gl.glTranslatef(0.0f, 0.0f, 0.0f);
   grid.draw(gl);
   gl.glPopMatrix();
   gl.glLoadIdentity();
 }
コード例 #3
0
  @Override
  public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glClearDepthf(1.0f);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDepthFunc(GL10.GL_LEQUAL);
    /*gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE);*/

    // TODO Add textures loading for background images

    for (int i = 0; i < gridMap.length; i++) {
      for (int j = 0; j < gridMap[i].length; j++) {
        System.out.println("Adding.." + "[" + i + "][" + j + "]");
        gridMap[i][j] = new PKImage();
        gridMap[i][j].loadTexture(gl, PKEngine.map[i][j], PKEngine.context);
      }
    }

    // Loads fonts
    font = new TexFont(PKEngine.context, gl);
    try {
      font.LoadFontAlt("visitor.bff", gl);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    quiz = new PKMiniGameQuiz();

    noMap.loadTexture(gl, PKEngine.NO_MAP, PKEngine.context);
    grid.loadTexture(gl, PKEngine.GRID, PKEngine.context);
    chest.loadTexture(gl, PKEngine.CHEST, PKEngine.context);
    pIndicator.loadTexture(gl, PKEngine.PLAYER_INDICATOR, PKEngine.context);
    quizQns.loadTexture(gl, PKEngine.QUIZ_QUESTION, PKEngine.context);
  }
コード例 #4
0
  private void drawMiniMap(GL10 gl) {
    float posX = 8.5f;
    float posY = 11.0f;

    for (int i = 0; i < gridMap.length; i++) {
      for (int j = 0; j < gridMap[i].length; j++) {
        if (currentX == i && currentY == j) {
          gl.glMatrixMode(GL10.GL_MODELVIEW);
          gl.glLoadIdentity();
          gl.glPushMatrix();
          gl.glScalef(0.08f, 0.08f, 1.0f);
          gl.glTranslatef(posX, posY, 0.0f);
          gl.glMatrixMode(GL10.GL_TEXTURE);
          gl.glLoadIdentity();
          gl.glTranslatef(0.0f, 0.0f, 0.0f);
          gridMap[i][j].draw(gl);
          pIndicator.draw(gl);
          gl.glPopMatrix();
          gl.glLoadIdentity();
          posX += 1.0f;
        } else {
          gl.glMatrixMode(GL10.GL_MODELVIEW);
          gl.glLoadIdentity();
          gl.glPushMatrix();
          gl.glScalef(0.08f, 0.08f, 1.0f);
          gl.glTranslatef(posX, posY, 0.0f);
          gl.glMatrixMode(GL10.GL_TEXTURE);
          gl.glLoadIdentity();
          gl.glTranslatef(0.0f, 0.0f, 0.0f);
          gridMap[i][j].draw(gl);
          gl.glPopMatrix();
          gl.glLoadIdentity();
          posX += 1.0f;
        }
      }
      posX = 8.5f;
      posY -= 1.0f;
    }
  }
コード例 #5
0
 private void endGame(GL10 gl) {
   // TODO Auto-generated method stub
   gl.glMatrixMode(GL10.GL_MODELVIEW);
   gl.glLoadIdentity();
   gl.glPushMatrix();
   gl.glScalef(0.75f, 0.75f, 1.0f);
   gl.glTranslatef(0.165f, 0.085f, 0.0f);
   gl.glMatrixMode(GL10.GL_TEXTURE);
   gl.glLoadIdentity();
   gl.glTranslatef(0.0f, 0.0f, 0.0f);
   quizQns.draw(gl);
   gl.glPopMatrix();
   gl.glLoadIdentity();
   if (PKEngine.client.getPlayerRanking(PKEngine.PLAYER_ID) == 1) {
     font.SetScale(1.5f);
     font.PrintAt(gl, "YOU WIN!", 150, 300);
     font.PrintAt(gl, "YOU EARNED $" + PKEngine.PLAYER_SCORE + "!", 90, 275);
   } else {
     font.SetScale(1.5f);
     font.PrintAt(gl, "YOU LOSE!", 150, 300);
     font.PrintAt(gl, "YOU EARNED $" + PKEngine.PLAYER_SCORE + "!", 90, 275);
   }
 }
コード例 #6
0
  private void miniGameStart(final GL10 gl, int gameNo) {
    System.out.println("Game Started");
    /*currentTime = Calendar.getInstance();
    int gameEnd = currentTime.SECOND + PKEngine.TIME_LIMIT;*/
    long currentTime = System.currentTimeMillis() / 1000;
    int timeElapsed = (int) currentTime - (int) startQuizTime;

    font.PrintAt(gl, "" + (timeLeft - timeElapsed), 100, 450);

    if (!PKEngine.GET_QUESTION) {
      int qns = rn.nextInt(11);
      currentQns = qns;
      PKEngine.GET_QUESTION = true;
    }
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glPushMatrix();
    gl.glScalef(0.75f, 0.75f, 1.0f);
    gl.glTranslatef(0.165f, 0.085f, 0.0f);
    gl.glMatrixMode(GL10.GL_TEXTURE);
    gl.glLoadIdentity();
    gl.glTranslatef(0.0f, 0.0f, 0.0f);
    quizQns.draw(gl);
    gl.glPopMatrix();
    gl.glLoadIdentity();

    String[] outputWords = quiz.getQuestion(currentQns).split(" ");
    quizAns = quiz.getAnswer(currentQns);

    int x = 90;
    int y = 330;
    font.SetScale(0.9f);
    if (outputWords.length == 1) {
      font.PrintAt(gl, outputWords[0], x, 300);
    } else if (outputWords.length == 2) {
      font.PrintAt(gl, outputWords[0] + " " + outputWords[1], x, 300);
    } else if (outputWords.length == 3) {
      font.PrintAt(gl, outputWords[0] + " " + outputWords[1] + " " + outputWords[2], x, 300);
    } else if (outputWords.length == 4) {
      font.PrintAt(
          gl,
          outputWords[0] + " " + outputWords[1] + " " + outputWords[2] + " " + outputWords[3],
          x,
          300);
    } else {
      for (int i = 0; i < outputWords.length - 4; i += 4) {
        font.PrintAt(
            gl,
            outputWords[i]
                + " "
                + outputWords[i + 1]
                + " "
                + outputWords[i + 2]
                + " "
                + outputWords[i + 3],
            x,
            y);
        y -= 15;
        if (i + 8 > outputWords.length) {
          if (outputWords.length - (i + 4) == 1) {
            font.PrintAt(gl, outputWords[i + 4], x, y);
            break;
          } else if (outputWords.length - (i + 4) == 2) {
            font.PrintAt(gl, outputWords[i + 4] + " " + outputWords[i + 5], x, y);
            break;
          } else if (outputWords.length - (i + 4) == 3) {
            font.PrintAt(
                gl, outputWords[i + 4] + " " + outputWords[i + 5] + " " + outputWords[i + 6], x, y);
            break;
          } else if (outputWords.length - (i + 4) == 4) {
            font.PrintAt(
                gl,
                outputWords[i + 4]
                    + " "
                    + outputWords[i + 5]
                    + " "
                    + outputWords[i + 6]
                    + " "
                    + outputWords[i + 7],
                x,
                y);
            break;
          }
        }
      }
    }
    // font.PrintAt(gl, quiz.getQuestion(currentQns), 80, 300);

    font.SetScale(1.5f);
    font.PrintAt(gl, "TRUE", 100, 170);
    font.PrintAt(gl, "FALSE", 270, 170);
  }