-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectBlueFireBall.java
More file actions
307 lines (247 loc) · 10.8 KB
/
ObjectBlueFireBall.java
File metadata and controls
307 lines (247 loc) · 10.8 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
package com.vinnstar.myfirstgame;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import java.util.ArrayList;
/**
* Created by Laurent on 6/22/2017.
*/
public class ObjectBlueFireBall extends GameObject {
/*//////////////////////////////////////////
// Arrays //
//////////////////////////////////////////*/
private int[] _collision_Details = new int[10];
//0 collision status
//1 the type of object
//2 the state of the object
//3 Magnitude
//4 Direction
//5 the hit box X
//6 the hit box y
//7 the hit box w
//8 the hit box h
//9 object ID;
///////////////////////////////////////////
// INTEGER DECLARATION //
///////////////////////////////////////////
private int _core_X_Coord_0;
private int _core_Y_Coord_1;
private int _core_Height_2;
private int _core_Width_3;
private int _core_Gravity_Type_4;
private int _core_Object_Type_5;
private int _core_W_Hitbox_6;
private int _core_H_Hitbox_7;
private int _core_Collision_Status_8;
private int _core_Object_Status_9;
private int _core_Object_State_10;
private int _core_Degree_Gravity_11;
private int _core_Magnitude_12;
private int _core_ID_13;
private int _core_Object_Sub_Animation_State_14;
//Special int for the object
///////////////////////////////////////////
// DOUBLE DECLARATION //
///////////////////////////////////////////
private double _core_X_Vel_0;
private double _core_Y_Vel_1;
private double _core_X_Hitbox_2;
private double _core_Y_Hitbox_3;
///////////////////////////////////////////
// BOOLEAN DECLARATION //
///////////////////////////////////////////
private boolean _core_Collided_Bottom_0;
private boolean _core_Collided_Top_1;
private boolean _core_Collided_Left_2;
private boolean _core_Collided_Right_3;
private boolean _core_Object_State_Change_4;
//Special Boolean for the object
private boolean _move_Faster = false;
private Bitmap spriteSheet;
//Testing only
private Paint paint = new Paint();
///////////////
//Constructor//
///////////////
public ObjectBlueFireBall(Bitmap res) {
////////////////////////////
// SPECIAL CLASS DEFINING //
////////////////////////////
spriteSheet = res;
spriteSheet = Bitmap.createScaledBitmap( spriteSheet, GamePanel.WIDTH/(100/15), GamePanel.HEIGHT/(100/22), false);
paint.setColor(Color.WHITE);
////////////////////////////SPECIAL///////////////////////////////
_core_X_Hitbox_2 = GamePanel.WIDTH + GamePanel.WIDTH/(100/10);
_core_Y_Hitbox_3 = GamePanel.HEIGHT + GamePanel.HEIGHT/(100/50);
//////////////////////////////////////////////////////////////////
/////////////////////
//INTEGERS DEFINING//
/////////////////////
_core_W_Hitbox_6 = GamePanel.WIDTH/(100/10);
_core_H_Hitbox_7 = GamePanel.HEIGHT/(100/10);
_core_X_Coord_0 = (int) _core_X_Hitbox_2;
_core_Y_Coord_1 = (int) _core_Y_Hitbox_3;
_core_Height_2 = GamePanel.HEIGHT/(100/8); //Only take up 10% of the screen
_core_Width_3 = GamePanel.WIDTH/(100/3); //Only take up 10% of the screen
_core_Gravity_Type_4 = Static.FIXED_GRAVITY;
_core_Object_Type_5 = Static.BLUEFIREBALL;
_core_Collision_Status_8 = Static.MIDAIR;
_core_Object_Status_9 = Static.OBJECT_STATUS_ACTIVE;
_core_Object_State_10 = Static.GENERAL_OBJECT_STATE_NEUTRAL;
_core_Degree_Gravity_11 = 0; //180 degrees on the unit circle going counter clockwise
_core_Magnitude_12 = 0;
_core_Object_Sub_Animation_State_14 = 0;
/////////////////////
//DOUBLE DEFINING //
/////////////////////
_core_X_Vel_0 = 0;
_core_Y_Vel_1 = 0;
_core_X_Hitbox_2 = GamePanel.WIDTH + GamePanel.WIDTH/(100/10) ;
_core_Y_Hitbox_3 = GamePanel.HEIGHT + GamePanel.HEIGHT/(100/10);
/////////////////////
//BOOLEAN DEFINING //
/////////////////////
_core_Collided_Bottom_0 = false;
_core_Collided_Top_1 = false;
_core_Collided_Left_2 = false;
_core_Collided_Right_3 = false;
_core_Object_State_Change_4 = false;
/////////////////////
// MISC DEFINING //
/////////////////////
paint.setColor(Color.WHITE);
}
public void variableUpdate(long deltatick) {
//Update the collision box cordinates & move the character
if(_move_Faster != true) {
_core_X_Hitbox_2 += _core_X_Vel_0 * (deltatick / 1000.f);
_core_Y_Hitbox_3 += _core_Y_Vel_1 * (deltatick / 1000.f);
}
else{
_core_X_Hitbox_2 += _core_X_Vel_0 * (deltatick / 1000.f);
_core_Y_Hitbox_3 += 1*_core_Y_Vel_1 * (deltatick / 1000.f);
}
//Place the image accordingly
_core_X_Coord_0 = (int)_core_X_Hitbox_2 - _core_Width_3;
_core_Y_Coord_1 = (int)_core_Y_Hitbox_3 - _core_Height_2;
}
//////////////////////////////////
// FLAGS IMPLEMENTATION //
//////////////////////////////////
//Leader method
public void eventFlags() {
applySpecialFlagTrigger();
}
public void applySpecialFlagTrigger() {
switch (_core_Object_State_10)
{
case Static.GENERAL_OBJECT_STATE_ACTIVE:
//1st FLAG///If this object goes above or below the active border
if (_core_Y_Hitbox_3 > GamePanel.HEIGHT + _core_H_Hitbox_7 *2 ) {
//Bottom border
_core_Y_Vel_1 = 0;
_core_X_Vel_0 = 0;
_core_Object_State_10 = Static.GENERAL_OBJECT_STATE_NEUTRAL;
}
else if (_core_Y_Hitbox_3 + _core_H_Hitbox_7 < 0 - _core_H_Hitbox_7 *2) {
//Top border
_core_Y_Vel_1 = 0;
_core_X_Vel_0 = 0;
_core_Object_State_10 = Static.GENERAL_OBJECT_STATE_NEUTRAL;
}
if (_core_X_Hitbox_2 + _core_W_Hitbox_6 < 0 - _core_W_Hitbox_6 *2 ) {
//left border
_core_Y_Vel_1 = 0;
_core_X_Vel_0 = 0;
_core_Object_State_10 = Static.GENERAL_OBJECT_STATE_NEUTRAL;
}
else if (_core_X_Hitbox_2 > GamePanel.WIDTH + _core_W_Hitbox_6 *2 ) {
//Top border
_core_Y_Vel_1 = 0;
_core_X_Vel_0 = 0;
_core_Object_State_10 = Static.GENERAL_OBJECT_STATE_NEUTRAL;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
if (_core_Y_Hitbox_3 > GamePanel.HEIGHT ) {
//Bottom border
_move_Faster = true;
}
else if (_core_Y_Hitbox_3 + _core_H_Hitbox_7 < 0) {
//Top border
_move_Faster = true;
}
if (_core_X_Hitbox_2 + _core_W_Hitbox_6 < 0 ) {
//left border
_move_Faster = true;
}
else if (_core_X_Hitbox_2 > GamePanel.WIDTH ) {
//Top border
_move_Faster = true;
}
/////////////////////////////////////////////////
/////////////////////////////////////////////////
if ((_core_Y_Hitbox_3 < GamePanel.HEIGHT ) && (_core_Y_Hitbox_3 + _core_H_Hitbox_7 > 0)){
if ((_core_X_Hitbox_2 + _core_W_Hitbox_6 > 0 ) && (_core_X_Hitbox_2 < GamePanel.WIDTH )){
_move_Faster = false;
}
}
break;
case Static.GENERAL_OBJECT_STATE_NEUTRAL:
_core_X_Hitbox_2 = GamePanel.WIDTH + _core_W_Hitbox_6 *2;
_core_Y_Hitbox_3 = GamePanel.HEIGHT + _core_H_Hitbox_7 *2;
_core_Magnitude_12 =0;
_core_X_Vel_0 = 0;
_core_Y_Vel_1 = 0;
_move_Faster = false;
break;
}
}
//////////////////////////////////
// SETTER METHODS //
//////////////////////////////////
public void setObjectState(int value)
{
_core_Object_State_10 = value;
}
public void setScreenProjectile(int x, int y, int degree, int magnitude) {
_core_X_Hitbox_2 = x;
_core_Y_Hitbox_3 = y;
//Place the image accordingly
_core_X_Coord_0 = (int)_core_X_Hitbox_2 - _core_Width_3;
_core_Y_Coord_1 = (int)_core_Y_Hitbox_3 - _core_Height_2;
_core_Magnitude_12 = magnitude;
_core_Degree_Gravity_11 = degree;
_core_X_Vel_0 = Math.cos(_core_Degree_Gravity_11 * Math.PI/180) * _core_Magnitude_12;
_core_Y_Vel_1 = -Math.sin(_core_Degree_Gravity_11 * Math.PI/180) * _core_Magnitude_12;
}
public void setID(int value){_core_ID_13 = value;}
//////////////////////////////////
// GETTER METHODS //
//////////////////////////////////
public int[] getCollisionDetailsArray(){
_collision_Details[0] = _core_Collision_Status_8;
_collision_Details[1] = _core_Object_Type_5;
_collision_Details[2] = _core_Object_State_10;
_collision_Details[3] = _core_Magnitude_12;
_collision_Details[4] = _core_Degree_Gravity_11;
_collision_Details[5] = (int)_core_X_Hitbox_2;
_collision_Details[6] = (int)_core_Y_Hitbox_3;
_collision_Details[7] = _core_W_Hitbox_6;
_collision_Details[8] = _core_H_Hitbox_7;
_collision_Details[9] = _core_ID_13;
return _collision_Details;}
public int getGravityType(){return _core_Gravity_Type_4;}
public int getObjectType(){return _core_Object_Type_5;}
public int getObjectStatus(){return _core_Object_Status_9;}
public int getObjectState(){return _core_Object_State_10;}
//////////////////////////////////
// Animation & Drawing //
//////////////////////////////////
//Leader method
public void draw(Canvas canvas) {
canvas.drawBitmap( spriteSheet , _core_X_Coord_0, _core_Y_Coord_1, null);
canvas.drawRect((int)_core_X_Hitbox_2, (int)_core_Y_Hitbox_3,(int)_core_X_Hitbox_2 + _core_W_Hitbox_6,(int)_core_Y_Hitbox_3 + _core_H_Hitbox_7, paint);
}
}