Guest User

Untitled

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package spaceinvaders;
  2.  
  3. import java.util.Scanner;
  4. import javafx.application.Application;
  5. import javafx.scene.Group;
  6. import javafx.scene.Scene;
  7. import javafx.scene.canvas.Canvas;
  8. import javafx.scene.canvas.GraphicsContext;
  9. import javafx.scene.text.Font;
  10. import javafx.stage.Stage;
  11.  
  12. /**
  13. *
  14. * @author Twissted
  15. */
  16.  
  17. public class SpaceInvaders extends Application {
  18. @Override
  19. public void start ( Stage stage ) throws Exception {
  20. Scanner scan = new Scanner ( System.in );
  21. System.out.println ( "Whats the score? " );
  22. String score = scan.nextLine();
  23.  
  24.  
  25. stage.setTitle ( "Space Invaders" ); //Window Title
  26. Canvas canvas = new Canvas ( 500, 500 ); //Canvas size
  27. Group root = new Group ();
  28. Scene scene = new Scene ( root );
  29. root.getChildren().add ( canvas );
  30. stage.setScene ( scene );
  31. stage.show ();
  32. GraphicsContext gc = canvas.getGraphicsContext2D();
  33.  
  34.  
  35.  
  36. gc.setFont(Font.font("System", 12));
  37. gc.setLineWidth(1);
  38. gc.setStroke(javafx.scene.paint.Color.rgb(128, 0, 0));
  39. gc.strokeText("Score: ", 10, 10);
  40.  
  41. gc.setFont(Font.font ( "System", 12 ) );
  42. gc.setLineWidth(1);
  43. gc.setStroke(javafx.scene.paint.Color.rgb(128, 0, 0));
  44. gc.strokeText(score, 25, 25);
  45.  
  46.  
  47. }
  48.  
  49.  
  50.  
  51.  
  52. public static void main(String[] args) {
  53. launch(args);
  54. }
  55.  
  56. }
Add Comment
Please, Sign In to add comment