Core S2 Software Solutions

Automating the Z-Type Game

Z-Type is a simple shooter / typing game where the user must type out full words or letters to destroy enemy ships. If any ship gets past the user, you loose the game.

Though the game is interesting, it’s not the focus of this video. Instead of playing it directly, I wrote a little Java code using the Swing Java Robot library to automate user input and simulate user-keyboard events. My application basically goes through all the letters ‘a’ – ‘z’ over and over again, where each keyboard-press event only lasts 10 milliseconds (enough time for the OS to handle but not too fast to overflow internal input buffers).

Apologies for lack of sound; some sort of audio encoding failed – normally I always explain things aloud. Check out the source code below:

 * Z-Type typing game
package typerrobot;
import java.awt.Robot;
import java.awt.event.*;
 * @author jbridon
public class Main {
     * @param args the command line arguments
    public static void main(String[] args) {
        // TODO code application logic here
        // Try everything...
        try {
            // Create an instance of a robot
            Robot KeyboardRobot = new Robot();
            System.out.println("Starting robot...");
            System.out.println("Robot started!");
            // Main loop for letter...
                // Keep looping the robot through the english
                // alphabet which is from 'a' - 'z'
                for(int letter = 'a'; letter <= 'z'; letter++)
                    // Find the initial offset
                    int OffsetStart = KeyEvent.VK_A;
                    // Press key
                    KeyboardRobot.keyPress(OffsetStart + letter - 'a');
                    KeyboardRobot.keyRelease(OffsetStart + letter - 'a');
            // End of cycle
            //System.out.println("Cycled through all letters...");
        } catch (Exception e) {
            System.out.println("Error: " + e.toString());
This entry was posted in News & Updates. Bookmark the permalink.

2 Responses to Automating the Z-Type Game

Leave a Reply

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


Sites map