Initial commit
This commit is contained in:
3
Java/Platformer/.idea/.gitignore
generated
vendored
Normal file
3
Java/Platformer/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
Java/Platformer/.idea/discord.xml
generated
Normal file
6
Java/Platformer/.idea/discord.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
</component>
|
||||
</project>
|
||||
6
Java/Platformer/.idea/misc.xml
generated
Normal file
6
Java/Platformer/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
Java/Platformer/.idea/modules.xml
generated
Normal file
8
Java/Platformer/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Platformer.iml" filepath="$PROJECT_DIR$/Platformer.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
11
Java/Platformer/Platformer.iml
Normal file
11
Java/Platformer/Platformer.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
BIN
Java/Platformer/out/production/Platformer/Frame.class
Normal file
BIN
Java/Platformer/out/production/Platformer/Frame.class
Normal file
Binary file not shown.
BIN
Java/Platformer/out/production/Platformer/Gui.class
Normal file
BIN
Java/Platformer/out/production/Platformer/Gui.class
Normal file
Binary file not shown.
BIN
Java/Platformer/rsc/background.jpg
Normal file
BIN
Java/Platformer/rsc/background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
78
Java/Platformer/src/Frame.java
Normal file
78
Java/Platformer/src/Frame.java
Normal file
@@ -0,0 +1,78 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class Frame extends JFrame implements ActionListener {
|
||||
public static Frame frame;
|
||||
|
||||
private JButton close;
|
||||
private JButton settings;
|
||||
private JButton info;
|
||||
private JButton end;
|
||||
|
||||
public static void main(String[] args) {
|
||||
frame = new Frame("Menü");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setSize(400, 400);
|
||||
frame.setResizable(false);
|
||||
frame.setLayout(null);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public Frame(String title) {
|
||||
super(title);
|
||||
|
||||
close = new JButton("Spiel starten");
|
||||
close.setBounds(120, 40, 160, 40);
|
||||
close.addActionListener(this);
|
||||
add(close);
|
||||
|
||||
settings = new JButton("Einstellungen");
|
||||
settings.setBounds(120, 120, 160, 40);
|
||||
settings.addActionListener(this);
|
||||
add(settings);
|
||||
|
||||
info = new JButton("Credits");
|
||||
info.setBounds(120, 200, 160, 40);
|
||||
info.addActionListener(this);
|
||||
add(info);
|
||||
|
||||
end = new JButton("Spiel beenden");
|
||||
end.setBounds(120, 280, 160, 40);
|
||||
end.addActionListener(this);
|
||||
add(end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource().equals(close)) {
|
||||
game();
|
||||
}
|
||||
if (e.getSource().equals(settings)) {
|
||||
selection();
|
||||
}
|
||||
if (e.getSource().equals(info)) {
|
||||
Object[] options = { "OK" };
|
||||
JOptionPane.showOptionDialog(null, "Programmiert von deiner Mum", "Information", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
|
||||
}
|
||||
if (e.getSource().equals(end)) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void game() {
|
||||
frame.setVisible(false);
|
||||
JFrame game = new JFrame();
|
||||
game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
game.setSize(650, 350);
|
||||
game.setLocationRelativeTo(null);
|
||||
game.setResizable(false);
|
||||
game.setVisible(true);
|
||||
game.add(new Gui());
|
||||
}
|
||||
|
||||
public static void selection() {
|
||||
|
||||
}
|
||||
}
|
||||
47
Java/Platformer/src/Gui.java
Normal file
47
Java/Platformer/src/Gui.java
Normal file
@@ -0,0 +1,47 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class Gui extends JPanel implements ActionListener {
|
||||
|
||||
Image img;
|
||||
int key = 0;
|
||||
int move = 0;
|
||||
|
||||
public Gui() {
|
||||
setFocusable(true);
|
||||
ImageIcon u = new ImageIcon("rsc/background.jpg");
|
||||
img = u.getImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.drawImage(img, 0, 0, null);
|
||||
}
|
||||
|
||||
private class AL extends KeyAdapter {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
key = e.getKeyCode();
|
||||
if (key == KeyEvent.VK_A) move = +1;
|
||||
if (key == KeyEvent.VK_D) move = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if (key != KeyEvent.VK_A && key != KeyEvent.VK_D) return;
|
||||
move = 0;
|
||||
key = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
requestFocus();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user