Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.WritableRenderedImage;
- import java.util.ArrayList;
- import java.util.ConcurrentModificationException;
- import java.util.List;
- public class Dong implements ActionListener
- {
- private final List<Window> windows = new ArrayList<>();
- boolean allClosed = false;
- Dong dong = this;
- boolean cracked = false;
- static final String code = "yesdaddy";
- static int progress = -1;
- Dong() throws InterruptedException
- {
- new Window();
- while (true)
- {
- if (!cracked)
- {
- Point mousePos = MouseInfo.getPointerInfo().getLocation();
- int mx = mousePos.x;
- int my = mousePos.y;
- try
- {
- for (Window window : windows)
- {
- int w = window.getWidth();
- int h = window.getHeight();
- int x = window.getX() + w / 2;
- int y = window.getY() + h / 2;
- if (x == mx && y == my)
- ++x;
- double dx = x - mx;
- double dy = y - my;
- double mag = Math.sqrt(dx * dx + dy * dy);
- double vx = dx / mag;
- double vy = dy / mag;
- double t = Double.POSITIVE_INFINITY;
- double tt = 0;
- if ((tt = -w / 2.0 / vx) > 0)
- {
- if (tt < t)
- t = tt;
- }
- if ((tt = w / 2.0 / vx) > 0)
- {
- if (tt < t)
- t = tt;
- }
- if ((tt = -h / 2.0 / vy) > 0)
- {
- if (tt < t)
- t = tt;
- }
- if ((tt = h / 2.0 / vy) > 0)
- {
- if (tt < t)
- t = tt;
- }
- t += 20;
- if (mag > t)
- continue;
- double distanceFromEdge = mag - t;
- double displaceX = -vx * distanceFromEdge;
- double displaceY = -vy * distanceFromEdge;
- window.setLocation((int) (window.getX() + displaceX), (int) (window.getY() + displaceY));
- }
- } catch (ConcurrentModificationException ignored)
- {
- }
- }
- Thread.sleep(10);
- }
- }
- @Override public void actionPerformed(ActionEvent e)
- {
- new Window();
- cracked = false;
- progress = -1;
- }
- class Window extends JFrame
- {
- static final int w = 250, h = 150;
- Window()
- {
- Window relative = windows.isEmpty() ? null : windows.get(windows.size() - 1);
- setTitle("Expand Dong");
- JPanel panel = new JPanel();
- panel.setPreferredSize(new Dimension(w, h));
- setContentPane(panel);
- setResizable(false);
- pack();
- setLocationRelativeTo(relative);
- setLocation(getX() + 20, getY() + 20);
- if (getX() + getWidth() > Toolkit.getDefaultToolkit().getScreenSize().width)
- setLocation(0, getY());
- if (getY() + getHeight() > Toolkit.getDefaultToolkit().getScreenSize().height)
- setLocation(getX(), 0);
- windows.add(this);
- Window pointer = this;
- addWindowListener(new WindowAdapter()
- {
- @Override public void windowClosing(WindowEvent e)
- {
- windows.remove(pointer);
- if (!cracked)
- {
- new Window();
- new Window();
- }
- if (windows.isEmpty())
- System.exit(0);
- }
- });
- KeyAdapter ka = new KeyAdapter()
- {
- @Override public void keyTyped(KeyEvent e)
- {
- if (cracked)
- return;
- char c = e.getKeyChar();
- if (code.toLowerCase().charAt(++progress) != c)
- progress = -1;
- if (progress == code.length() - 1)
- cracked = true;
- }
- };
- addKeyListener(ka);
- setLayout(null);
- JButton button = new JButton("OK");
- add(button);
- button.addActionListener(dong);
- button.setBounds(w / 2 - 50, h - 50, 100, 30);
- button.setFocusable(true);
- button.setFocusPainted(true);
- button.requestFocus();
- button.addKeyListener(ka);
- JLabel label = new JLabel("coconut creampies");
- add(label);
- label.setHorizontalAlignment(JLabel.CENTER);
- label.setBounds(w / 2 - 100, 30, 200, 30);
- //setIconImage(new ImageIcon(getClass().getResource("./icon.png")).getImage());
- setVisible(true);
- }
- }
- public static void main(String[] args) throws InterruptedException
- {
- Dong dong = new Dong();
- int i = 0;
- while (!dong.allClosed)
- Thread.sleep(10000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement