-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainCharacter.java
More file actions
204 lines (188 loc) · 6.24 KB
/
MainCharacter.java
File metadata and controls
204 lines (188 loc) · 6.24 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
public class MainCharacter {
//The character you'll be playing as :)
//He's a very dangerous child and capable of things beyond belief
//A young never aging young boy was raised in rural Japan
//Ness is courageous and the envy of many children
//He posseses strong psychic abilities
//In the past he was known for his abilities to use Slingshots as weapons
//but as time passed and technology improved, he found that guns were much more convenient
//Along with power comes great responsibility.
//Ness was not capable of that and ended up becoming evil and a big bully to young children
//The Zombies and Devils depicted in the game are the children he bullied after
//Having experienced the effects of the apocalypse.
// -Leo Feng
public final int full_health=1000;
private int health=full_health, ANGLE,sx = 37, sy = 43, sp=10;
private int cweapon = 1;
public double posx, posy;
private final int NUMOFWEAPONS = 8;
private final int PISTOL=1,UZI = 2,SHOTGUN =3, BARREL=4,GRENADE=5,BARRICADE=6, SENTRY=7; // weapon numbers
private int[] ORIGINALmaxAmmo = new int[NUMOFWEAPONS]; //this stores the original max ammo values
private int[] maxAmmo = new int[NUMOFWEAPONS]; //this stores all the max ammo values but it changes as the character receives upgrades
//this stores all the current weapon ammo available to the character
private int[] cweaponAmmo = new int[NUMOFWEAPONS];
//weapon speed
private int[] ORIGINALweaponsp = new int[NUMOFWEAPONS];
private int[] weaponsp = new int[NUMOFWEAPONS];
//weapon damage
private int[] ORIGINALweapondmg = new int[NUMOFWEAPONS];
private int[] weapondmg = new int[NUMOFWEAPONS];
//weapon distance
private int[] ORIGINALweapondist= new int[NUMOFWEAPONS];
private int[] weapondist = new int[NUMOFWEAPONS];
//shotgun width
private int shotgunWide = 0;
//Upgrade, consecutive shots
private boolean[] consecutiveShoot = new boolean[NUMOFWEAPONS];
public MainCharacter(int px, int py){
posx = px;
posy = py;
loadORMaxAmmo();//done
loadORWeaponSpeed();//done
loadORdist();//done
loadORdmg(); //done
loadConsecutiveShoot();
}
/////////////DAMAGE//////////////////
public void loadORdmg(){
ORIGINALweapondmg[PISTOL]=5;
ORIGINALweapondmg[UZI]=15;
ORIGINALweapondmg[SHOTGUN]=8;
//barrel,grenade has its damage saved in its class
ORIGINALweapondmg[SENTRY]=5;
loaddmg();
}
public void loaddmg(){
for (int i=0;i<NUMOFWEAPONS;i++){
weapondmg[i] = ORIGINALweapondmg[i];
}
}
public void setDmg(int weapon,int dmg){
weapondmg[weapon]=dmg;
}
public int getdmg(int type){
return weapondmg[type];
}
////////////////////////
/////////////DISTANCE//////////////////
public void loadORdist(){
for (int i=0; i<NUMOFWEAPONS; ++i){
ORIGINALweapondist[i] = 250;
}
ORIGINALweapondist[2] = 350;
ORIGINALweapondist[3]=200;
loaddist();
}
public void loaddist(){
for (int i=0;i<NUMOFWEAPONS;i++){
weapondist[i] = ORIGINALweapondist[i];
}
}
public void setDist(int weapon,int dist){
weapondist[weapon]=dist;
}
public int getMaxDist(int a){
return weapondist[a];
}
////////////////////////
/////////////////SPEED/////////////////
public void loadORWeaponSpeed(){
ORIGINALweaponsp[1]=20; //pistol
ORIGINALweaponsp[2]=30; //uzi
ORIGINALweaponsp[3]=30;//shotgun
loadWeaponSpeed();
}
public void loadWeaponSpeed(){
for (int i=0;i<ORIGINALweaponsp.length;i++){
weaponsp[i]=ORIGINALweaponsp[i];
}
}
public int getAtWeaponSpeed(int weapon){
return weaponsp[weapon];
}
public void setWeaponSpeed(int weapon,int speed){
weaponsp[weapon]=speed;
}
////////////////////////
/////////MAX ammo//////////////
public void loadORMaxAmmo(){
ORIGINALmaxAmmo[UZI]=50;
ORIGINALmaxAmmo[SHOTGUN]=20;
ORIGINALmaxAmmo[BARREL]=10;
ORIGINALmaxAmmo[BARRICADE]=5;
ORIGINALmaxAmmo[GRENADE]=5;
ORIGINALmaxAmmo[BARRICADE]=5;
ORIGINALmaxAmmo[SENTRY]=5;
loadMaxAmmo();
}
public void loadMaxAmmo(){
for (int i=0;i<ORIGINALmaxAmmo.length;i++){
maxAmmo[i]=ORIGINALmaxAmmo[i];
}
}
public void setMaxAmmo(int weapon,int max){maxAmmo[weapon]=max;}
public int getMaxAmmo(int weapon){return ORIGINALmaxAmmo[weapon];}
////////////////////////
//////////AMMO//////////
public void addAmmo(int n){
cweaponAmmo[n]=getMaxAmmo(n);
}
public int getAmmo(int n){return cweaponAmmo[n];}
public void useAmmo(int n){
cweaponAmmo[n]-=1;
if (cweaponAmmo[n]==0){
cweapon=1;
}
}
public void unloadCAmmo(){ //restart, no ammo :(
for (int i=0;i<NUMOFWEAPONS;i++){
cweaponAmmo[i]=0;
}
}
////////////////////////////////////////////
/////////CONSECUTIVE SHOOT////////////
public void loadConsecutiveShoot(){
for (int i=0;i<NUMOFWEAPONS;i++){
consecutiveShoot[i]=false;
}
}
////////////////////////////////////////////
/////////////////getter/setters////////////////
//consecutive shoot
public void setConsecutiveShoot(int weapon){consecutiveShoot[weapon]=true;} //the weapon has been upgraded to shoot consecutively
public boolean getConsecutiveShoot(int weapon){return consecutiveShoot[weapon];}
//position of character (int)
public int getX(){return (int)posx;}
public int getY(){return (int)posy;}
//position of character (double)
public double getDX(){return posx;}
public double getDY(){return posy;}
public void setX(double x){posx = x;}
public void setY(double y){posy = y;}
//health
public void setHealth(int h){health=h;}
public int getHealth(){return health;}
//other properties of MC
public int getspeed(){return sp;}
public int getLength(){return sx;}
public int getWidth(){return sy;}
public int getANGLE(){return ANGLE;}
public void setAngle(int ang){ANGLE = ang;}
public int getWeapon(){return cweapon;}
public void setWeapon(int w){cweapon=w;}
//size of MC
public int getsx(){return sx;}
public int getsy(){return sy;}
//centre position of MC (int)
public int getcx(){return (int)(posx + sx/2);}
public int getcy(){return (int)(posy + sy/2);}
//centre position of MC (double)
public double getcdx(){return (posx + sx/2);}
public double getcdy(){return (posy + sy/2);}
//how wide the shotgun shot is
public int getSGW(){return shotgunWide;}
//Sets the width of shotgun
public void setSGW(int n){shotgunWide = n;}
//calculate health for the health bar
public int calculateHealth(){return (int)(health*30/1000.0);}
}