[Tutorial] Insaniquarium Deluxe Rapid Clicker

Insaniquarium Deluxe is a 2D arcade game released by Flying Bear Entertainment and PopCap Games in 2004. It received huge critical acclaim and positive reviews across the board. It was one of the defining games which rocketed PopCap games to fame before Plants vs Zombies. The player uses the mouse to feed fishes, collect coins and fight aliens. The game revolves around mashing your left mouse button for hours on end until you beat the level. And then you repeat the same process for the next level. This seems like something which can easily be helped.

jnativehook, a java library which acts as a global mouse and keyboard listener could easily reduce the number of clicks we need.

jnativehook allows us to detect keyboard key presses and java’s Robot class allows us to easily simulate mouse clicks. That’s all we need to make Insaniquarium less insane.

Lets code an application which will issue a mouse click at the position of the cursor whenever it detects a specific key being pressed, lets say “S”. If we hold down “S” our program should keep issuing left mouse clicks at the cursor. This rate of clicking will invariably be much faster than physically possible. Thereby making feeding fishes, collecting coins and fighting aliens much easier on us.
We’ll also add the “P” key as a way to exit the program.

Pre requisite :
Include jnativehook in the build path.

GUI :
The GUI is built using the Window Builder plugin for eclipse.

Once a keyboard hook is added, all thats left to do is to override the nativeKeyPressed method:

public void nativeKeyPressed(NativeKeyEvent e) {
if (NativeKeyEvent.getKeyText(e.getKeyCode()).equals("S")) {
try {
Robot r = new Robot();

for (int t = 0; t < 1; t++) {
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
}

} catch (Exception e1) {
System.out.println(e1.toString());
}
}

if (NativeKeyEvent.getKeyText(e.getKeyCode()).equals(“P”)) {
try {
GlobalScreen.unregisterNativeHook();
System.exit(1);
} catch (Exception ex) {

}
}
}

When the “S” key is pressed down, it rapidly issues mouse click commands at the position of the cursor. Making it much easier to collect coins and feed fishes in Insaniquarium.

Source Code :
https://github.com/Vetox/RapidClicker

Karthi

Karthikeyan M : Geek, Gamer, Coder, Blogger - he shares his love of Technology in the form of tutorials, reviews, and how-to’s. An avid reader, he is a student at SRM university pursuing his B.Tech. in Information Technology.

Leave a Reply