public void render() { Gdx.gl.glClearColor(.2f, .2f, .2f, 1); // 0->1 = 0->255 Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); rayHandler.updateAndRender(); if (this.started) { float deltaTime = Gdx.app.getGraphics().getDeltaTime(); if (deltaTime > .1f) deltaTime = .1f; world.step(deltaTime, 10, 10); // Increase the score score.addValue((int) this.joe.getSpeed() * 10 * Gdx.app.getGraphics().getDeltaTime()); joe.render(); if (joe.isOutOfScreen()) { this.Pause(); RunningJoe.getInstance().setScreen(new GameOverScreen()); } this.camera.translate(RunningJoe.PixToMeter(this.joe.getSpeed()), 0); } camera.update(); if (RunningJoe.DEV_MODE) RunningJoe.debugRenderer.render(world, camera.combined); // Draw bodies textures spriteBatch.begin(); for (Background bg : this.vecBg) { bg.DrawTexture(spriteBatch); } // Draw Joe in the World joe.draw(spriteBatch); // Generate ground and draw it in the World this.listBlock.render(); this.listBlock.draw(spriteBatch); this.obstacleFactory.generateRjObstacles(this, spriteBatch); fire.draw(spriteBatch); foreground.DrawTexture(spriteBatch); spriteBatch.end(); }
// fires public void checkFireCrush(ArrayList<Fire> fires, int i) { Fire fire = fires.get(i); if (fire.isReverse()) { if (x - width / 2 < fire.getX() - fire.getWidth() / 2 && x + width / 2 >= fire.getX() - fire.getWidth() / 2 && y + height / 2 > fire.getY() + fire.getHeight() / 2 && y - height / 2 < fire.getY() + fire.getHeight() / 2 - height / 2) { x = startX; y = startY; reverse = false; falling = false; hit(); } else { if (x + width / 2 > fire.getX() + fire.getWidth() / 2 && x - width / 2 <= fire.getX() + fire.getWidth() / 2 && y + height / 2 > fire.getY() + fire.getHeight() / 2 && y - height / 2 < fire.getY() + fire.getHeight() / 2 - height / 2) { x = startX; y = startY; reverse = false; falling = false; hit(); } else { if (x + width / 2 > fire.getX() - fire.getWidth() / 2 && x - width / 2 < fire.getX() + fire.getWidth() / 2 && y + height / 2 > fire.getY() + fire.getHeight() / 2 && y - height / 2 <= fire.getY() + fire.getHeight() / 2) { x = startX; y = startY; reverse = false; falling = false; hit(); } } } } else { if (x - width / 2 < fire.getX() - fire.getWidth() / 2 && x + width / 2 >= fire.getX() - fire.getWidth() / 2 && y - height / 2 < fire.getY() - fire.getHeight() / 2 && y + height / 2 > fire.getY() - fire.getHeight() / 2 + height / 2) { x = startX; y = startY; reverse = false; falling = false; hit(); } else { if (x + width / 2 > fire.getX() + fire.getWidth() / 2 && x - width / 2 <= fire.getX() + fire.getWidth() / 2 && y - height / 2 < fire.getY() - fire.getHeight() / 2 && y + height / 2 > fire.getY() - fire.getHeight() / 2 + height / 2) { x = startX; y = startY; reverse = false; falling = false; hit(); } else { if (x - width / 2 < fire.getX() + fire.getWidth() / 2 && x + width / 2 > fire.getX() - fire.getWidth() / 2 && y - height / 2 < fire.getY() - fire.getHeight() / 2 && y + height / 2 >= fire.getY() - fire.getHeight() / 2) { x = startX; y = startY; reverse = false; falling = false; hit(); } } } } }