I wish to make a game in which the user can change the hotkeys within the game itself.
I have gotten to the part where it can read the key's press but it doesn't exactly work correctly.
What I want it to do is I click on the text and it start a count down timer and will set time to 0 when I press a button. It will then change the string variable in the Config class to correspond to the new hotkey. If I don't press anything then the timer will just count down and once it reaches 0, it will do nothing, no changes to the Config class.
double time = 50000; // Time allow to change while (time > 0.0) { // Minus the time allow to time and resigter the key pressed if (Greenfoot.getKey() != null && !Greenfoot.isKeyDown(Hkey)) { // If a key was press change the Config HotKey if (type == 51) Config.x1 = Hkey; else if(type == 52) Config.x2 = Hkey; else if(type == 53) Config.x3 = Hkey; else if(type == 54) Config.x4 = Hkey; else if(type == 55) Config.x5 = Hkey; else if(type == 56) Config.x6 = Hkey; else if(type == 61) Config.y1 = Hkey; else if(type == 62) Config.y2 = Hkey; else if(type == 63) Config.y3 = Hkey; else if(type == 64) Config.y4 = Hkey; else if(type == 65) Config.y5 = Hkey; else if(type == 66) Config.y6 = Hkey; getWorld().addObject(new Text(type, 0), getX(), getY()); getWorld().removeObject(this); time = 0; // Quit While Loop } else time -= 1; // Minus time if no key was press } }