Enigma Mouse Click

Tıklanın yer bilgisini sol üst köşeye yazar.

public enigma.console.Console cn = Enigma.getConsole("Mouse and Keyboard");
	public TextMouseListener tmlis;
	public KeyListener klis;

	public int mousepr;
	public int mousex, mousey;

	Game() throws Exception {

		tmlis = new TextMouseListener() {
			public void mouseClicked(TextMouseEvent arg0) {
			}

			public void mousePressed(TextMouseEvent arg0) {
				if (mousepr == 0) {
					mousepr = 1;
					mousex = arg0.getX();
					mousey = arg0.getY();
				}
			}

			public void mouseReleased(TextMouseEvent arg0) {
			}
		};
		cn.getTextWindow().addTextMouseListener(tmlis);

		int px = 5, py = 5;
		cn.getTextWindow().output(px, py, 'P');
		while (true) {
			if (mousepr == 1) {
				cn.getTextWindow().setCursorPosition(mousex, mousey);
				System.out.println("You Click Here");
				cn.getTextWindow().setCursorPosition(0, 0);
				System.out.print(mousex + "," + mousey + "      ");
				px = mousex;
				py = mousey;

				mousepr = 0; // last action
			}

			Thread.sleep(20);
		}
	}

 

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *