Advertisement
JackHoughton00

Code that might not work in game

Jun 5th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. Scene theScene = new Scene ( root );
  2. stage.setScene ( theScene );
  3.  
  4. Canvas canvas = new Canvas( 550,700);
  5. root.getChildren().add(canvas);
  6.  
  7. GraphicsContext gc = canvas.getGraphicsContext2D();
  8.  
  9.  
  10. gc.setFill( Color.AQUA);
  11. gc.setStroke(Color.BLACK);
  12. gc.setLineWidth(2);
  13. Font theFont = Font.font("Arial", FontWeight.BOLD,48);
  14. gc.setFont( theFont);
  15. gc.fillText( "Welcome to the game!", 60,50);
  16. gc.strokeText("Welcome to the game!", 60, 50);
  17.  
  18. Image triangle1 = new Image("triangle1.png");
  19. gc.drawImage(triangle1, 250, 250);
  20. Image triangle2 = new Image("triangle2.png");
  21. gc.drawImage(triangle2, 290, 250);
  22. Image triangle3 = new Image("triangle3.png");
  23. gc.drawImage(triangle3, 215, 250);
  24. Image cursor1 = new Image("cursor1.png");
  25. gc.drawImage(cursor1, 400, 250);
  26.  
  27.  
  28. final long startNanoTime = System.nanoTime();
  29.  
  30. new AnimationTimer() {
  31. public void handle(long currentNanoTime) {
  32. double t = (currentNanoTime - startNanoTime) / 1000000000.0;
  33.  
  34. double x = 232 + 128 * Math.cos(t);
  35. double y = 232 + 128 * Math.sin(t);
  36.  
  37. Image cursor2 = new Image("cursor2.png");
  38. gc.drawImage(cursor2, 150, 250);
  39.  
  40.  
  41. }
  42. }.start();
  43.  
  44.  
  45.  
  46.  
  47. stage.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement