-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMain.java
More file actions
135 lines (115 loc) · 4.06 KB
/
Copy pathMain.java
File metadata and controls
135 lines (115 loc) · 4.06 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package Testing;
import JavaGameEngine.Backend.Scene;
import JavaGameEngine.Backend.UpdateThread;
import JavaGameEngine.Components.Collider.SquareCollider;
import JavaGameEngine.Components.GameObject;
import JavaGameEngine.Components.Physics.PhysicsWorld;
import JavaGameEngine.Components.Ui.Label;
import JavaGameEngine.JavaGameEngine;
import JavaGameEngine.UI.Button;
import JavaGameEngine.msc.Vector2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main extends JavaGameEngine{
public static int level = 0;
public static void main(String[] args){
Main m = new Main();
PhysicsWorld.setGravityAcceleration(new Vector2(0,9.92f/1000));
setSelectedScene(new Level1());
m.start();
}
static class Start extends Scene{
public Start(){
Main.level = 0;
JButton b = new JButton("Level1");
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Main.setSelectedScene(new Level1());
System.out.println(1);
}
});
add(b);
b.setBounds(200,200,100,50);
JButton b1 = new JButton("Level2");
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Main.setSelectedScene(new Level2());
System.out.println(2);
}
});
add(b1);
b1.setBounds(400,200,100,50);
JButton b2 = new JButton("Level3");
b2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Main.setSelectedScene(new Level3());
System.out.println(3);
}
});
add(b2);
b2.setBounds(600,200,100,50);
}
}
static class Level1 extends Scene{
public Level1(){
id=0;
Main.level = 1;
Player s = new Player(new Vector2(100,300));
components.add(s);
components.add(new Label("1"));
components.add(new Coin(new Vector2(500,400)));
components.add(new Ground());
}
}
static class Level2 extends Scene{
public Level2(){
Player s = new Player(new Vector2(200,300));
id=1;
Main.level = 2;
components.add(s);
components.add(new Label("2"));
components.add(new Coin(new Vector2(500,200)));
components.add(new Ground());
components.add(new Ground(new Vector2(600,300)));
}
}
static class Level3 extends Scene{
public Level3(){
Player s = new Player(new Vector2(200,300));
id=2;
Main.level = 3;
components.add(s);
components.add(new Label("3"));
components.add(new Coin(new Vector2(200,0)));
components.add(new Ground());
components.add(new Ground(new Vector2(600,300)));
components.add(new Ground(new Vector2(200,100)));
}
}
static class End extends Scene{
public End(){
JButton b = new JButton("Restart");
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Main.setSelectedScene(new Start());
level = 0;
}
});
add(b);
b.setBounds(400,200,100,50);
Main.level = 4;
}
}
static class T extends GameObject{
public T(){
SquareCollider s = new SquareCollider();
addChild(s);
}
}
}