Bug 626 - Fail to select mode on laptops with no individual F1 and F2
Summary: Fail to select mode on laptops with no individual F1 and F2
Status: RESOLVED FIXED
Alias: None
Product: CS3343 2021/22 Group16 Greedy Snake
Classification: Unclassified
Component: Action Package (show other bugs)
Version: Ver 3.0
Hardware: PC Windows
: Normal normal
Assignee: Baron Qu
URL:
: 624 625 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-11-29 17:00 HKT by LI Ruoxin
Modified: 2021-12-05 18:27 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LI Ruoxin 2021-11-29 17:00:20 HKT
Steps to reproduce:
1. Run Main.java on laptops with no individual F1 and F2 keys (i.e. these two keys are functional keys as well)
2. Press fn+F1 or fn+F2 to select mode

Actual Results: Game does not switch to the selected mode

Expected Results: Game switches to the selected mode
Comment 1 Baron Qu 2021-12-05 11:28:29 HKT
Suspect the F1 key and F2 key are multiple function keys. Therefore, sometimes the computer does not take the F1 or F2 as input, but the computer shortcut command.
May just change the F1 key and F2 key to 1 key or 2 key. Or we change change the key to 'P' key or 'A' key.
Comment 2 Baron Qu 2021-12-05 11:29:17 HKT
*** Bug 624 has been marked as a duplicate of this bug. ***
Comment 3 Baron Qu 2021-12-05 11:29:29 HKT
*** Bug 625 has been marked as a duplicate of this bug. ***
Comment 4 LI Ruoxin 2021-12-05 18:27:20 HKT
Changed key F1 & F2 to key 1 & 2.
Code impletment:
public void keyPressed(KeyEvent e) {
		if (SConstant.SC_GAME_MODE_DEFAULT.equals(game.getMode())
				|| SConstant.SC_GAME_MODE_PlAYER.equals(game.getMode())) {
			keyLock = SConstant.SC_DEFAULT_KEYBOARD_LOCK;
		} else {
			keyLock = SConstant.SC_UPDATED_KEYBOARD_LOCK;
		}
		if (SConstant.SC_DEFAULT_KEYBOARD_LOCK.equals(keyLock)) {
			switch (e.getKeyCode()) {
			case KeyEvent.VK_1:
				Press1KeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_2:
				Press2KeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_DOWN:
				PressDownKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_LEFT:
				PressLeftKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_RIGHT:
				PressRightKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_UP:
				PressUpKeyCommand.getInstance().execute(game);
				break;
			case KeyEvent.VK_SPACE:
				timer.start();
				break;
			}
		}
			
	}