Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package spaceinvaders;
- import java.util.Scanner;
- import javafx.application.Application;
- import javafx.scene.Group;
- import javafx.scene.Scene;
- import javafx.scene.canvas.Canvas;
- import javafx.scene.canvas.GraphicsContext;
- import javafx.scene.text.Font;
- import javafx.stage.Stage;
- /**
- *
- * @author Twissted
- */
- public class SpaceInvaders extends Application {
- @Override
- public void start ( Stage stage ) throws Exception {
- Scanner scan = new Scanner ( System.in );
- System.out.println ( "Whats the score? " );
- String score = scan.nextLine();
- stage.setTitle ( "Space Invaders" ); //Window Title
- Canvas canvas = new Canvas ( 500, 500 ); //Canvas size
- Group root = new Group ();
- Scene scene = new Scene ( root );
- root.getChildren().add ( canvas );
- stage.setScene ( scene );
- stage.show ();
- GraphicsContext gc = canvas.getGraphicsContext2D();
- gc.setFont(Font.font("System", 12));
- gc.setLineWidth(1);
- gc.setStroke(javafx.scene.paint.Color.rgb(128, 0, 0));
- gc.strokeText("Score: ", 10, 10);
- gc.setFont(Font.font ( "System", 12 ) );
- gc.setLineWidth(1);
- gc.setStroke(javafx.scene.paint.Color.rgb(128, 0, 0));
- gc.strokeText(score, 25, 25);
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
Add Comment
Please, Sign In to add comment