Viki:Sandbox

From Viki
Revision as of 20:50, 27 July 2020 by Fußmatte (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

1 def quick_sort(arr):
2 	less = []
3 	pivot_list = []
4 	more = []
5 	if len(arr) <= 1:
6 		return arr
7 	else:
8 		pass

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.

Conditions

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:

		if(key.toggleFullscreen)
		{
			if(!gameScreen.isWindowed)
			{
				//SDL_WM_GrabInput(SDL_GRAB_ON);
				SDL_ShowCursor(SDL_DISABLE);
				SDL_ShowCursor(SDL_ENABLE);
			}
			else
			{
				SDL_ShowCursor(SDL_ENABLE);
			}


			if(game.gamestate == EDITORMODE)
			{
				SDL_ShowCursor(SDL_ENABLE);
			}

			gameScreen.toggleFullScreen();
			game.fullscreen = !game.fullscreen;
			key.toggleFullscreen = false;

				key.keymap.clear(); //we lost the input due to a new window.
				game.press_left = false;
				game.press_right = false;
				game.press_action = true;
				game.press_map = false;
			printf("Error: failed: %s\n", SDL_GetError());




		}

These four lines cause the glitch:

				game.press_left = false;
				game.press_right = false;
				game.press_action = true;
				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.