annotate kopieckreta/src/Actions.java @ 18:b5e2aba31fdb

lamertetris-0.230821-3 package for arch
author Przemyslaw <prymula76@outlook.com>
date Sun, 31 Mar 2024 15:35:26 +0200
parents 2787f5e749ae
children 489244127359
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1
prymula <prymula76@outlook.com>
parents:
diff changeset
2 package src;
prymula <prymula76@outlook.com>
parents:
diff changeset
3
prymula <prymula76@outlook.com>
parents:
diff changeset
4 import java.awt.event.KeyEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
5 import java.awt.event.KeyListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
6
prymula <prymula76@outlook.com>
parents:
diff changeset
7 class Actions implements KeyListener {
prymula <prymula76@outlook.com>
parents:
diff changeset
8 String cheat="";
prymula <prymula76@outlook.com>
parents:
diff changeset
9 char pressKey =' ';
prymula <prymula76@outlook.com>
parents:
diff changeset
10
prymula <prymula76@outlook.com>
parents:
diff changeset
11 public void Actions(){}
prymula <prymula76@outlook.com>
parents:
diff changeset
12 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
13 public void keyTyped(KeyEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
14 }
prymula <prymula76@outlook.com>
parents:
diff changeset
15
prymula <prymula76@outlook.com>
parents:
diff changeset
16 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
17 public void keyReleased(KeyEvent event) {
prymula <prymula76@outlook.com>
parents:
diff changeset
18 }
prymula <prymula76@outlook.com>
parents:
diff changeset
19
prymula <prymula76@outlook.com>
parents:
diff changeset
20 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
21 public void keyPressed(KeyEvent event) {
prymula <prymula76@outlook.com>
parents:
diff changeset
22
prymula <prymula76@outlook.com>
parents:
diff changeset
23 if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('a')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
24 isThere('a');
prymula <prymula76@outlook.com>
parents:
diff changeset
25 }
prymula <prymula76@outlook.com>
parents:
diff changeset
26 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ą')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
27 isThere('ą');
prymula <prymula76@outlook.com>
parents:
diff changeset
28 }
prymula <prymula76@outlook.com>
parents:
diff changeset
29 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('w')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
30 isThere('w');
prymula <prymula76@outlook.com>
parents:
diff changeset
31 }
prymula <prymula76@outlook.com>
parents:
diff changeset
32 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('e')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
33 isThere('e');
prymula <prymula76@outlook.com>
parents:
diff changeset
34 }
prymula <prymula76@outlook.com>
parents:
diff changeset
35 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ę')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
36 isThere('ę');
prymula <prymula76@outlook.com>
parents:
diff changeset
37 }
prymula <prymula76@outlook.com>
parents:
diff changeset
38 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('r')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
39 isThere('r');
prymula <prymula76@outlook.com>
parents:
diff changeset
40 }
prymula <prymula76@outlook.com>
parents:
diff changeset
41 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('t')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
42 isThere('t');
prymula <prymula76@outlook.com>
parents:
diff changeset
43 }
prymula <prymula76@outlook.com>
parents:
diff changeset
44 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('y')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
45 isThere('y');
prymula <prymula76@outlook.com>
parents:
diff changeset
46 }
prymula <prymula76@outlook.com>
parents:
diff changeset
47 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('u')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
48 isThere('u');
prymula <prymula76@outlook.com>
parents:
diff changeset
49 }
prymula <prymula76@outlook.com>
parents:
diff changeset
50 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('i')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
51 isThere('i');
prymula <prymula76@outlook.com>
parents:
diff changeset
52 }
prymula <prymula76@outlook.com>
parents:
diff changeset
53 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('o')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
54 isThere('o');
prymula <prymula76@outlook.com>
parents:
diff changeset
55 }
prymula <prymula76@outlook.com>
parents:
diff changeset
56 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ó')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
57 isThere('ó');
prymula <prymula76@outlook.com>
parents:
diff changeset
58 }
prymula <prymula76@outlook.com>
parents:
diff changeset
59 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('p')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
60 isThere('p');
prymula <prymula76@outlook.com>
parents:
diff changeset
61 }
prymula <prymula76@outlook.com>
parents:
diff changeset
62 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('s')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
63 isThere('s');
prymula <prymula76@outlook.com>
parents:
diff changeset
64 }
prymula <prymula76@outlook.com>
parents:
diff changeset
65 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ś')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
66 isThere('ś');
prymula <prymula76@outlook.com>
parents:
diff changeset
67 }
prymula <prymula76@outlook.com>
parents:
diff changeset
68 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('d')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
69 isThere('d');
prymula <prymula76@outlook.com>
parents:
diff changeset
70 }
prymula <prymula76@outlook.com>
parents:
diff changeset
71 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('f')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
72 isThere('f');
prymula <prymula76@outlook.com>
parents:
diff changeset
73 }
prymula <prymula76@outlook.com>
parents:
diff changeset
74 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('g')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
75 isThere('g');
prymula <prymula76@outlook.com>
parents:
diff changeset
76 }
prymula <prymula76@outlook.com>
parents:
diff changeset
77 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('h')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
78 isThere('h');
prymula <prymula76@outlook.com>
parents:
diff changeset
79 }
prymula <prymula76@outlook.com>
parents:
diff changeset
80 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('j')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
81 isThere('j');
prymula <prymula76@outlook.com>
parents:
diff changeset
82 }
prymula <prymula76@outlook.com>
parents:
diff changeset
83 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('k')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
84 isThere('k');
prymula <prymula76@outlook.com>
parents:
diff changeset
85 }
prymula <prymula76@outlook.com>
parents:
diff changeset
86 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('l')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
87 isThere('l');
prymula <prymula76@outlook.com>
parents:
diff changeset
88 }
prymula <prymula76@outlook.com>
parents:
diff changeset
89 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ł')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
90 isThere('ł');
prymula <prymula76@outlook.com>
parents:
diff changeset
91 }
prymula <prymula76@outlook.com>
parents:
diff changeset
92 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('z')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
93 isThere('z');
prymula <prymula76@outlook.com>
parents:
diff changeset
94 }
prymula <prymula76@outlook.com>
parents:
diff changeset
95 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ż')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
96 isThere('ż');
prymula <prymula76@outlook.com>
parents:
diff changeset
97 }
prymula <prymula76@outlook.com>
parents:
diff changeset
98 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ź')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
99 isThere('ź');
prymula <prymula76@outlook.com>
parents:
diff changeset
100 }
prymula <prymula76@outlook.com>
parents:
diff changeset
101 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('c')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
102 isThere('c');
prymula <prymula76@outlook.com>
parents:
diff changeset
103 }
prymula <prymula76@outlook.com>
parents:
diff changeset
104 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ć')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
105 isThere('ć');
prymula <prymula76@outlook.com>
parents:
diff changeset
106 }
prymula <prymula76@outlook.com>
parents:
diff changeset
107 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('b')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
108 isThere('b');
prymula <prymula76@outlook.com>
parents:
diff changeset
109 }
prymula <prymula76@outlook.com>
parents:
diff changeset
110 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('n')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
111 isThere('n');
prymula <prymula76@outlook.com>
parents:
diff changeset
112 }
prymula <prymula76@outlook.com>
parents:
diff changeset
113 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('ń')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
114 isThere('ń');
prymula <prymula76@outlook.com>
parents:
diff changeset
115 }
prymula <prymula76@outlook.com>
parents:
diff changeset
116 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('m')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
117 isThere('m');
prymula <prymula76@outlook.com>
parents:
diff changeset
118 }
prymula <prymula76@outlook.com>
parents:
diff changeset
119 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('1')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
120 hungryCheat('1');
prymula <prymula76@outlook.com>
parents:
diff changeset
121 }
prymula <prymula76@outlook.com>
parents:
diff changeset
122 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('2')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
123 hungryCheat('2');
prymula <prymula76@outlook.com>
parents:
diff changeset
124 }
prymula <prymula76@outlook.com>
parents:
diff changeset
125 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('3')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
126 hungryCheat('3');
prymula <prymula76@outlook.com>
parents:
diff changeset
127 }
prymula <prymula76@outlook.com>
parents:
diff changeset
128 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('4')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
129 hungryCheat('4');
prymula <prymula76@outlook.com>
parents:
diff changeset
130 }
prymula <prymula76@outlook.com>
parents:
diff changeset
131 else if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar(' ')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
132 resetCheat();
prymula <prymula76@outlook.com>
parents:
diff changeset
133 }
prymula <prymula76@outlook.com>
parents:
diff changeset
134
prymula <prymula76@outlook.com>
parents:
diff changeset
135 }
prymula <prymula76@outlook.com>
parents:
diff changeset
136 public char getKey () {
prymula <prymula76@outlook.com>
parents:
diff changeset
137 return pressKey;
prymula <prymula76@outlook.com>
parents:
diff changeset
138 }
prymula <prymula76@outlook.com>
parents:
diff changeset
139 public String getCheat(){
prymula <prymula76@outlook.com>
parents:
diff changeset
140 return cheat;
prymula <prymula76@outlook.com>
parents:
diff changeset
141 }
prymula <prymula76@outlook.com>
parents:
diff changeset
142
prymula <prymula76@outlook.com>
parents:
diff changeset
143 private void isThere(char c){
prymula <prymula76@outlook.com>
parents:
diff changeset
144 // Nie wiem czemu od razu nie przekazałem dużej litery...
prymula <prymula76@outlook.com>
parents:
diff changeset
145 pressKey=Character.toUpperCase(c);
prymula <prymula76@outlook.com>
parents:
diff changeset
146 resetCheat();
prymula <prymula76@outlook.com>
parents:
diff changeset
147 }
prymula <prymula76@outlook.com>
parents:
diff changeset
148 private void hungryCheat(char c){
prymula <prymula76@outlook.com>
parents:
diff changeset
149 String s =Character.toString(c);
prymula <prymula76@outlook.com>
parents:
diff changeset
150 cheat += s;
prymula <prymula76@outlook.com>
parents:
diff changeset
151 }
prymula <prymula76@outlook.com>
parents:
diff changeset
152 public void resetCheat(){
prymula <prymula76@outlook.com>
parents:
diff changeset
153 cheat="";
prymula <prymula76@outlook.com>
parents:
diff changeset
154 }
prymula <prymula76@outlook.com>
parents:
diff changeset
155 }