private void init() { try { Window.createWindow(width, height, title); } catch (Exception e) { e.printStackTrace(); } this.renderingEngine = new RenderingEngine(); game.init(); }
/** * Main method * * @param args Execution arguments */ public static void main(String[] args) { /** Stream Input/Output configuration */ streamIn = System.in; streamOut = System.out; Game game = new Game(); if (game.init(streamIn, streamOut)) game.runGame(); else { PrintStream ps = new PrintStream(streamOut); ps.println("Intitialization Error"); } }
@Override public void start(Stage s) { myGame = new Game(); s.setTitle(myGame.getTitle()); Scene scene = myGame.init(WIDTH, HEIGHT); s.setScene(scene); s.show(); KeyFrame frame = new KeyFrame(Duration.millis(MILLISECOND_DELAY), e -> myGame.step(SECOND_DELAY)); Timeline animation = new Timeline(); animation.setCycleCount(Timeline.INDEFINITE); animation.getKeyFrames().add(frame); animation.play(); s.setResizable(false); }
public void run() { init(); long lastTime = System.nanoTime(); final double amountOfTicks = 60D; double ns = 1_000_000_000 / amountOfTicks; double delta = 0; while (running) { long now = System.nanoTime(); delta += (now - lastTime) / ns; lastTime = now; // only update 60 times per second if (delta >= 1) { tick(); delta--; } // draw all objects onto screen render(); } }
public static void main(String[] args) { Game game = new Game(500, 500); game.init(); }
public void loading(int pos) { if (pos == 0) { camera = new RTSCamera(getCamera()); camera.registerWithInput(inputManager); loadingScreen.setProgress(0.1f, "Making Light"); } else if (pos == 1) { loadShadow(); loadLight(); loadingScreen.setProgress(0.2f, "Loading Terrain"); } else if (pos == 2) { reflectNode = new Node("reflect"); rootNode.attachChild(reflectNode); nonreflectNode = new Node("non reflect"); rootNode.attachChild(nonreflectNode); clickableNode = new Node("clickable"); reflectNode.attachChild(clickableNode); // clickableNode.attachChild(createTerrain()); loadTerrain(); loadWater(); camera.addTerrain(terrain); camera.addWater(water); loadingScreen.setProgress(0.6f, "Loading Doodads"); } else if (pos == 3) { loadDoodads(); loadingScreen.setProgress(0.8f, "Init Game"); } else if (pos == 4) { game.init(); // gui=new GUI(game); game.getMyGame().init(game); if (game.isMultiplayer()) { client.finishedLoading(); } loadingScreen.setProgress(1f, "Finished Loading"); } else if (pos == 5) { loadingScreen.clear(); camera.enable(); gui = new GUI(game); gui.init(); playerInput = new PlayerInput(game); // important input after nifty next_game_tick = System.currentTimeMillis(); Timer.init(); loading = false; } }
private void reset() { display.getFrame().dispose(); // player = new Player(this); score1 = score2 = 0; init(); }
/** @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; recalculateScale(); held.init(container); }