JScratch
Loading...
Searching...
No Matches
DnDiablo.java
Go to the documentation of this file.
1package com.burrbox.dndiablo;
2
3import com.jscratch.Costume;
4import com.jscratch.Sprite;
5import com.jscratch.Stage;
6
7public class DnDiablo {
8 private static int gamestate = 0;
9 public static final int MENU = 0;
10 public static final int PLAYERSELECTION = 0;
11 public static final int GAME = 0;
12
13
14 public static void main(String[] args) {
15 Stage.run(() -> {
16 Stage stage = Stage.getInstance();
17 createTitle(stage);
18 createPlayButton(stage);
20 });
21 }
22
23 private static void createTitle(Stage stage) {
24 stage.addSprite(new Sprite("title") {
25 public Sprite init() {
26 addCostume(new Costume("title", "dndiablo/title.png", 0, 0)); // no rotation so I do not care
27 this.nextCostume();
28 this.setSize(200);
29 this.goTo(-220, 160);
30 this.whenIReceive("menuoff", () -> {
31 this.hide();
32 });
33 this.whenScaleChanged((old, newscale) -> {
34 double scfa = newscale / (old+0.0);
35 this.goTo(this.getX() * scfa, this.getY() * scfa);
36 this.setScaleX(this.getScaleX() * scfa);
37 this.setScaleY(this.getScaleY() * scfa);
38
39 });
40 return this;
41 }
42 }.init());
43 }
44
45 private static void createPlayButton(Stage stage) {
46 stage.addSprite(new Sprite("play") {
47 public Sprite init() {
48 addCostume(new Costume("play", "dndiablo/play.png", 0, 0)); // no rotation so I do not care
49 this.nextCostume();
50 this.setSize(200);
51 this.goTo(-160, 80);
52 this.whenIReceive("menuoff", () -> {
53 this.hide();
54 });
55 this.whenClicked(() -> {
56 if (isVisible()) {
57 stage.broadcast("begin");
58 stage.broadcast("menuoff");
59 }
60 });
61 this.whenScaleChanged((old, newscale) -> {
62 double scfa = newscale / (old+0.0);
63 this.goTo(this.getX() * scfa, this.getY() * scfa);
64 this.setScaleX(this.getScaleX() * scfa);
65 this.setScaleY(this.getScaleY() * scfa);
66
67 });
68 return this;
69 }
70 }.init());
71 }
72
73 private static void createCharacterCreationButton(Stage stage) {
74 stage.addSprite(new Sprite("characterCreation") {
75 public Sprite init() {
76 addCostume(new Costume("play", "dndiablo/charactercreation.png", 0, 0)); // no rotation so I do not care
77 this.nextCostume();
78 this.setSize(200);
79 this.goTo(-160, 40);
80 this.whenIReceive("menuoff", () -> {
81
82 this.hide();
83 });
84 this.whenClicked(() -> {
85 if (isVisible()) {
86 stage.broadcast("makecharacter");
87 stage.broadcast("menuoff");
88 }
89 });
90 this.whenScaleChanged((old, newscale) -> {
91 double scfa = newscale / (old+0.0);
92 this.goTo(this.getX() * scfa, this.getY() * scfa);
93 this.setScaleX(this.getScaleX() * scfa);
94 this.setScaleY(this.getScaleY() * scfa);
95
96 });
97 return this;
98 }
99 }.init());
100 }
101}
static void createPlayButton(Stage stage)
Definition DnDiablo.java:45
static final int PLAYERSELECTION
Definition DnDiablo.java:10
static void main(String[] args)
Definition DnDiablo.java:14
static void createCharacterCreationButton(Stage stage)
Definition DnDiablo.java:73
static void createTitle(Stage stage)
Definition DnDiablo.java:23
void addSprite(Sprite s)
Definition Stage.java:145
void broadcast(String message)
Definition Stage.java:96
static void run(Runnable setup)
Definition Stage.java:270
static Stage getInstance()
Definition Stage.java:325