-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyModel.java
executable file
·85 lines (73 loc) · 1.38 KB
/
MyModel.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.awt.*;
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Dimension;
import java.net.*;
public class MyModel {
private boolean kleft; //keyLeft
private boolean kright;
private boolean ERight; //EnemyRight
private boolean ELeft;
private boolean enemykill;
private Image playerimage;
private Image enemyimage;
private Image bullet;
private Image explosion;
private Image title;
private Image apple_logo;
private Image linux_logo;
private Image windows_logo;
public MyModel(){
ELeft = false;
ERight = true;
enemykill = false;
}
public int getLeftPmove(boolean kleft, int px){
if (kleft && px > 0){
px -= 10;
}
return px;
}
public int getRightPmove(boolean kright, int px){
if (kright && px < 1280 -79){
px += 10;
}
return px;
}
public int getUpPmove(boolean kright, int py){
if (kright && py > 360){
py -= 10;
}
return py;
}
public int getDownPmove(boolean kright, int py){
if (kright && py < 720 - 100){
py += 10;
}
return py;
}
public int getEmove(boolean enemykill, int ex){
if (!enemykill && ex < 1280 -79 && ERight){
ELeft = false;
ex += 10;
}
else {
ELeft = true;
}
if (!enemykill && ex > 0 && ELeft){
ERight = false;
ex -= 10;
}
else {
ERight = true;
}
if (enemykill) {
ex = 20;
}
return ex;
}
public int getPoint(int point){
point += 1;
return point;
}
}