-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathokno.java
More file actions
46 lines (32 loc) · 896 Bytes
/
okno.java
File metadata and controls
46 lines (32 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class okno extends JFrame {
private pole gameP;
private class myKey implements KeyListener {
public void keyPressed(KeyEvent e) {
int key_ = e.getKeyCode();
if (key_==27) System.exit(0);
else if(key_==37) {
if (gameP.x - 30 > -48) gameP.x -= 30;
else gameP.x = 752;
}
else if (key_==39) {
if (gameP.x + 30 < 752) gameP.x += 30;
else gameP.x = -48;
}
}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
}
public okno (int slogn) {
addKeyListener(new myKey());
setFocusable(true);
setBounds(0, 0, 800, 600);
setTitle("Èãðà: äîãîíè_ìåíÿ_êèðïè÷");
gameP = new pole(slogn);
Container con = getContentPane();
con.add(gameP);
setVisible(true);
}
}