Alt+Enter Glitch

From Viki
Jump to navigation Jump to search
Other languages:
English • ‎Esperanto

The Alt+Enter Glitch is a glitch where using the "fullscreen toggle" keybind would flip the player or interrupt a walk() command during a cutscene. While the glitch is named "Alt+Enter", any key combination that toggles fullscreen, including Alt+F and F11 (in 2.3) will produce the same effect.

More specifically, triggering this glitch will result in the game pressing ACTION for the player, which will be held down until the next delay in the cutscene. Therefore, if they were standing on a surface, or were 3 frames from landing on a surface (Flip Buffering) when the ACTION press occurred, they will be flipped. The walk() command presses left or right for the player and creates its own delay, so if this glitch is triggered during a walk(), the left and right inputs will both be released.


In order for the glitch to take effect, (1) the key combination or keypress must occur during a delay in a script that is more than 1 frame, and (2) the player must have control during the cutscene (game.hascontrol must be set to true).

If the keybind is pressed while not in a cutscene, it will not flip the player, but it will stop the player from moving left or right if those keys were held down while the toggle keybind was pressed.

Condition 1 rules out any delay of a cutscene that arises due to using untilbars() or untilfade() during a cutscene bar or fade animation. This is because those commands actually delay for 1 frame every frame if the animation isn't complete, and thus, instead of being a 15-frame delay, it consists of fifteen 1-frame delays.

Condition 2 rules out being able to do this glitch during "- Press ACTION to advance text -" prompts in a cutscene, because usually when those prompts are activated, the player's control is taken away as well. However, it is possible to obtain the prompt while still having control (Noflip). In case you do so, the player would be unable to flip, but their walk() could still be interrupted.

Code analysis

From the initial commit of the VVVVVV repository, main.cpp line 276:

276 		if(key.toggleFullscreen)
277 		{
278 			if(!gameScreen.isWindowed)
279 			{
280 				//SDL_WM_GrabInput(SDL_GRAB_ON);
281 				SDL_ShowCursor(SDL_DISABLE);
282 				SDL_ShowCursor(SDL_ENABLE);
283 			}
284 			else
285 			{
286 				SDL_ShowCursor(SDL_ENABLE);
287 			}
290 			if(game.gamestate == EDITORMODE)
291 			{
292 				SDL_ShowCursor(SDL_ENABLE);
293 			}
295 			gameScreen.toggleFullScreen();
296 			game.fullscreen = !game.fullscreen;
297 			key.toggleFullscreen = false;
299 				key.keymap.clear(); //we lost the input due to a new window.
300 				game.press_left = false;
301 				game.press_right = false;
302 				game.press_action = true;
303 				game.press_map = false;
304 			printf("Error: failed: %s\n", SDL_GetError());
309 		}

These four lines cause the glitch:

300 				game.press_left = false;
301 				game.press_right = false;
302 				game.press_action = true;
303 				game.press_map = false;

game.press_left and game.press_right are used whenever the player moves left or right, and they are used automatically make the player walk left or right during cutscenes. Thus, setting them to false will interrupt the walk. Setting game.press_action to true will make the player flip during a cutscene when they're not supposed to be able to.

It seems that the original developer thought inputs from the old window would "stick" and be held down if fullscreen was toggled, as indicated by the comment. However, it is sufficient to clear the keymap, and wholly unnecessary to mess with other input variables when toggling fullscreen.

Additionally, "Error: failed: " will always appear in the console, despite there not being an error with the fullscreen toggle. This unnecessary print has been removed in 2.3.