Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Game {
- private int corePoolSize=2;
- private static ScheduledThreadPoolExecutor stpe;
- protected static Hashtable<Integer, Rock> rocksList;
- protected static Hashtable<Integer, Shot> shotsList;
- protected static Enumeration<Rock> enumAst;
- protected static Enumeration<Shot> enumShot;
- protected static Rock tempRock;
- protected static Ship ship;
- protected static Shot shots;
- public void methodeEnCaca() {
- Game.stpe = new ScheduledThreadPoolExecutor(this.corePoolSize);
- Game.stpe.scheduleAtFixedRate(new GameThread(), 1, 20, TimeUnit.MILLISECONDS);
- }
- }
- public class GameThread extends Game implements Runnable {
- public GameThread(){}
- public void run() {
- detectCollision();
- /*
- * boucle demandant à tous les éléments de la liste de mettre leur vue à jour
- */
- Game.enumAst = Game.rocksList.elements();
- while(enumAst.hasMoreElements()) {
- Game.tempRock=enumAst.nextElement();
- Game.tempRock.updatePosition();
- }
- Game.enumShot = Game.shotsList.elements();
- while(enumShot.hasMoreElements()) {
- Game.shots=enumShot.nextElement();
- Game.shots.updatePosition();
- }
- if(Game.ship!=null) {
- Game.ship.updatePosition();
- }
- refreshView(); //méthode demandant à la vue de faire un repaint()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment