-
Notifications
You must be signed in to change notification settings - Fork 0
/
strartpage.java
116 lines (105 loc) · 3.72 KB
/
strartpage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//<ANVIT SACHDEV 2017333><RAMESHWAR MISHRA 2017180>
import java.io.FileInputStream;
import java.io.IOException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
/**
*
* @author anvit
*/
public class strartpage extends Application {
@Override
public void start(final Stage stage) throws IOException {
Image image = new Image(new FileInputStream("C:\\Users\\anvit\\Documents\\NetBeansProjects\\snakeblockgame\\src\\game.jpg"));
ImageView imageView = new ImageView(image);
imageView.setX(0);
imageView.setY(0);
final game g=new game();
final leaderboard lb=new leaderboard();
final Instructions it=new Instructions();
//setting the fit height and width of the image view
imageView.setFitHeight(1000);
imageView.setFitWidth(2000);
final Pane canvas = new Pane();
Scene scene = new Scene(canvas, 2000, 900, Color.ALICEBLUE);
Button btn = new Button();
Button btn2 = new Button();
Button btn3= new Button();
Button btn4= new Button();
btn.setText("Start Game");
btn2.setText("Resume Game");
btn3.setText("Leaderboard");
btn4.setText("Instructions");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// System.out.println("Hello World!");
g.start(stage);
}
});
btn2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// System.out.println("Hello World!");
System.exit(0);
// g.start(stage);
}
});
btn3.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// System.out.println("Hello World!");
try{
lb.start(stage);
}
catch(Exception e){
}
}
});
btn4.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// System.out.println("Hello World!");
try{
it.start(stage);
}
catch(Exception e){
}
}
});
StackPane root = new StackPane();
btn.relocate(1000,300);
btn2.relocate(1000,400);
btn3.relocate(1000,500);
btn4.relocate(1000,600);
canvas.getChildren().add(imageView);
canvas.getChildren().add(btn);
canvas.getChildren().add(btn2);
canvas.getChildren().add(btn3);
canvas.getChildren().add(btn4);
// Scene scene = new Scene(canvas, 300, 250);
stage.setTitle("Start Page");
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}