Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.Cursor;
- import java.awt.event.*;
- import java.util.*;
- class Harald extends Thread implements ActionListener
- {
- JFrame harald;
- JLabel Spiel;
- Cursor c;
- JButton butter;
- JButton butt;
- ActionEvent e;
- Windowlauscher amfenster;
- int s = 0;
- JFrame ingame;
- JLabel Lars;
- JButton Boris;
- JButton Ben;
- JButton Bernd;
- JButton Bruno;
- JLabel Louis;
- Random randA;
- Random randB;
- Random randC;
- Random randD;
- ImageIcon icon2 = new ImageIcon("WoodWallpaper.jpg");
- public Harald()
- {
- harald = new JFrame("Schießbude");
- harald.setLayout(null);
- harald.setBounds(500, 350,500, 250);
- Spiel = new JLabel("Hallo, Ich möchte ein Spiel mit dir Spielen. Spielst du mit mir ?") ;
- Spiel.setBounds(80, 40, 450, 20);
- harald.add(Spiel);
- amfenster = new Windowlauscher();
- harald.addWindowListener(amfenster);
- butter = new JButton ("JOO");
- butter.setBounds(150, 80, 80, 80);
- butter.addActionListener(this);
- harald.add(butter);
- butt = new JButton ("NÄH");
- butt.setBounds(290, 80, 80, 80);
- butt.addActionListener(this);
- harald.add(butt);
- harald.setResizable(false);
- harald.setVisible(true);
- ingame = new JFrame ("Schießbude");
- ingame.setLayout(null);
- ingame.setBounds(0,0,1280,995);
- Lars = new JLabel("Score :"+s);
- Lars.setFont(new Font("Serif", Font.PLAIN, 30));
- Lars.setBackground(new Color(0,255,255));
- Lars.setForeground(new Color(255,0,0));
- Lars.setBounds(100,60,240,30);
- ingame.add(Lars);
- Louis = new JLabel (icon2);
- Louis.setBounds(0,0,1280,995);
- ingame.add(Louis);
- c = new Cursor(Cursor.CROSSHAIR_CURSOR);
- ImageIcon icon1 = new ImageIcon("Gloockler.jpg");
- Boris = new JButton(icon1);
- Ben = new JButton(icon1);
- Bernd = new JButton(icon1);
- Bruno = new JButton(icon1);
- InitBoris();
- InitBen();
- InitBernd();
- InitBruno();
- ingame.add(Boris);
- ingame.add(Ben);
- ingame.add(Bernd);
- ingame.add(Bruno);
- Boris.addActionListener(this);
- Ben.addActionListener(this);
- Bernd.addActionListener(this);
- Bruno.addActionListener(this);
- }
- public void InitBoris(){
- randA = new Random();
- int x = randA.nextInt(1184);
- int y = randA.nextInt(899);
- Boris.setBounds(x, y, 96, 96);
- }
- public void InitBen(){
- randB = new Random();
- int xx = randB.nextInt(1184);
- int yy = randB.nextInt(899);
- Ben.setBounds(xx,yy,96,96);
- }
- public void InitBernd(){
- randB = new Random();
- int xxx = randC.nextInt(1184);
- int yyy = randC.nextInt(899);
- Bernd.setBounds(xxx,yyy,96,96);
- }
- public void InitBruno(){
- randB = new Random();
- int xxxx = randD.nextInt(1184);
- int yyyy = randD.nextInt(899);
- Bruno.setBounds(xxxx,yyyy,96,96);
- }
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource()==butter)
- {
- ingame.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
- harald.setVisible(false);
- ingame.setResizable(false);
- ingame.setVisible(true);
- }
- if(e.getSource()==butt)
- {
- System.exit(0);
- }
- if(e.getSource()==Boris)
- {
- s++;
- Lars.setText("Score :"+s);
- InitBoris();
- ingame.add(Boris);
- }
- if(e.getSource()==Ben)
- {
- s++;
- Lars.setText("Score :"+s);
- InitBen();
- ingame.add(Ben);
- }
- if(e.getSource()==Bernd)
- {
- s++;
- Lars.setText("Score :"+s);
- InitBernd();
- ingame.add(Bernd);
- }
- if(e.getSource()==Bruno)
- {
- s++;
- Lars.setText("Score :"+s);
- InitBruno();
- ingame.add(Bruno);
- }
- }
- public void run()
- {
- for(int i = 0; i < 10; i++)
- {
- try
- {
- sleep(5000);
- }
- catch(InterruptedException e)
- {
- }
- }
- }
- public static void main(String[] args)
- {
- Harald blub = new Harald();
- blub.run();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement