forked from Java-Game-Maker/JavaGameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
144 lines (124 loc) · 4.32 KB
/
Copy pathMain.java
File metadata and controls
144 lines (124 loc) · 4.32 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
136
137
138
139
140
141
142
143
144
package Testing;
import javagameengine.backend.GameWorld;
import javagameengine.backend.Scene;
import javagameengine.backend.UpdateThread;
import javagameengine.backend.input.Input;
import javagameengine.backend.input.Keys;
import javagameengine.components.Component;
import javagameengine.components.colliders.SquareCollider;
import javagameengine.components.GameObject;
import javagameengine.components.physics.PhysicsWorld;
import javagameengine.JavaGameEngine;
import javagameengine.msc.Debug;
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();
setSelectedScene(new Level4());
m.start();
//Debug.showWhere = true;
}
@Override
public void update() {
super.update();
if(!UpdateThread.running){
setSelectedScene(new Start());
UpdateThread.running = true;
}
}
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 Level4());
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(0,-100));
components.add(s);
components.add(new Goal(new Vector2(100,-100)));
components.add(new Ground(new Vector2(0,0)));
// components.add(new Goal());
}
}
static class Level2 extends Scene{
public Level2(){
id=1;
Main.level = 2;
Player s = new Player(new Vector2(0,100));
components.add(s);
components.add(new Goal(new Vector2(400,-100)));
components.add(new Ground(new Vector2(400,0)));
components.add(new Ground(new Vector2(120,200)));
}
}
static class Level3 extends Scene{
public Level3(){
Player s = new Player(new Vector2(0,-100));
id=2;
Main.level = 3;
components.add(s);
components.add(new Ground(new Vector2(0,0)));
components.add(new Ground(new Vector2(400,-200)));
components.add(new Ground(new Vector2(0,-400)));
components.add(new Goal(new Vector2(-100,-500)));
}
}
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);
}
}
}