@Override public void onGraphicRender(GdxGraphics g) { /* Update the world physics */ PhysicsWorld.updatePhysics(); /* Sync signal emulation using system time */ boolean sync_signal = new TimeFloat().second % 60.0 == 0.0; /* * Second hand logic * * Stop when vertical, start when sync_sygnal */ if (sync_signal) { motor_seconds.setMotorSpeed(MOTOR_SPEED_SECOND); } else { double angle = -hand_second.getBody().getAngle() % (2 * Math.PI); if (angle > 2 * Math.PI * 0.995 && motor_seconds.getSpeed() != 0.0) { motor_seconds.setMotorSpeed(0.0f); } } /* * Minute hand logic * * Move from 1 minute when sync_signal */ if (sync_signal) { motor_minutes.setMotorSpeed(MOTOR_SPEED_MINUTE); } else { motor_minutes.setMotorSpeed(0.0f); } /* Get the size of the window */ final int w = getWindowWidth(); final int h = getWindowHeight(); /* Clear the graphic to draw the new image */ g.clear(); if (debug_rendering) { debugRenderer.render(world, g.getCamera().combined); g.setColor(Color.WHITE); } else { /* Create a nice grey gradient for the background */ for (int i = 0; i <= h; i++) { float c = 255 - i * 0.3f; g.setColor(new Color(c / 255, c / 255, c / 255, 1.0f)); g.drawLine(0, h - i, w, h - i); } /* Draw the clock frame */ g.drawPicture(CLOCK_CENTER.x, CLOCK_CENTER.y, bitmapClock); /* Draw the hands */ g.drawTransformedPicture( CLOCK_CENTER.x, CLOCK_CENTER.y, (float) (Math.toDegrees(hand_hour.getBody().getAngle())), 1.0f, bitmapHour); g.drawTransformedPicture( CLOCK_CENTER.x, CLOCK_CENTER.y, (float) (Math.toDegrees(hand_minute.getBody().getAngle())), 1.0f, bitmapMinute); g.drawTransformedPicture( CLOCK_CENTER.x, CLOCK_CENTER.y, (float) (Math.toDegrees(hand_second.getBody().getAngle())), 1.0f, bitmapSecond); g.setColor(Color.BLACK); } /* Display time in text */ g.drawString(w - 200, h - 10, "Famous clock from\r\n" + "the Swiss Railways."); g.drawString(w - 200, h - 80, displayTime()); g.drawSchoolLogo(); }