Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFramework.java
More file actions
Latest commit
64 lines (44 loc) · 1.44 KB
/
Copy pathFramework.java
File metadata and controls
64 lines (44 loc) · 1.44 KB
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
packageapplication;
importjavafx.animation.AnimationTimer;
importjavafx.application.Application;
importjavafx.geometry.Point2D;
importjavafx.stage.Stage;
importjavafx.scene.Group;
importjavafx.scene.Scene;
importjavafx.scene.control.Label;
importjavafx.scene.paint.Color;
publicclassFrameworkextendsApplication {
// Size of scene
Point2Dsize = newPoint2D(1000, 800);
/* Called automatically when application is setup */
publicvoidstart(Stagestage) {
Grouproot = newGroup(); // Add to root's children to make objects visible
Scenescene = newScene(root, size.getX(), size.getY());
stage.setScene(scene);
stage.setTitle("My Game");
scene.setFill(Color.BLACK);
LabelfpsLabel = newLabel();
fpsLabel.setTranslateX(2);
fpsLabel.setTextFill(Color.WHITE);
root.getChildren().add(fpsLabel);
/*** INITIALIZE THINGS HERE ***/
AnimationTimerloop = newAnimationTimer() {
doubleold = -1;
doubleelapsedTime = 0;
publicvoidhandle(longnano) {
if (old < 0) old = nano;
doubledelta = (nano - old) / 1e9;
old = nano;
elapsedTime += delta;
fpsLabel.setText(String.format("%.2f %.2f", 1/delta, elapsedTime));
/*** GAME LOOP GOES HERE ***/
}
};
loop.start();
stage.show();
}
/* Main method sets up application */
publicstaticvoidmain(String[] args) {
launch(args);
}
}