@@ -46,6 +46,7 @@ public class mario_gv1 extends View {
46
46
private int [] blocksx ;
47
47
private int [] blocksy ;
48
48
private int spikesize ;
49
+
49
50
private int [] gombasx ;
50
51
private int [] gombasy ;
51
52
private int [] gombasd ;
@@ -54,10 +55,21 @@ public class mario_gv1 extends View {
54
55
private int gomba_width ;
55
56
private int gombaspeedx =3 ;
56
57
private float [] gombaspeedy ;
58
+
59
+ private int [] vogelx ;
60
+ private int [] vogely ;
61
+ private int vogel_height_hit ;
62
+ private int vogel_height_jump ;
63
+ private int vogel_width ;
64
+ private int vogelspeedx =3 ;
65
+ private int vogelspeedy =2 ;
66
+ private boolean vogel_rechts =true ;
67
+ private int vogel_durchlauf =0 ;
68
+
57
69
private int [] spikesx ;
58
70
private int [] spikesy ;
59
71
private int tolleranz , tolleranz_block_stehen , tolleranz_block_fallen ;
60
- private Bitmap mario , mario2 , block , spike , gomba , gomba2 ;
72
+ private Bitmap mario , mario2 , block , spike , gomba , gomba2 , vogel1 , vogel2 ;
61
73
private boolean once , once2 , once3 , once4 ;
62
74
private float oldspeed , newspeed ;
63
75
private boolean init_cameratransition =false ;
@@ -89,11 +101,15 @@ public mario_gv1(Context context) {
89
101
gomba_width = blocksize ;
90
102
gomba_height_jump =blocksize /5 ;
91
103
gomba_height_hit =blocksize -gomba_height_jump ;
104
+ vogel_width = blocksize ;
105
+ vogel_height_jump =gomba_height_jump ;
106
+ vogel_height_hit =gomba_height_hit ;
92
107
mariox =0 ;
93
108
94
109
init_level_blocks ();
95
110
init_level_spikes ();
96
111
init_level_gombas ();
112
+ init_level_vogel ();
97
113
98
114
mario = BitmapFactory .decodeResource (getResources (), R .drawable .mario );
99
115
mario = Bitmap .createScaledBitmap (mario , width /25 , width /25 , false );
@@ -107,6 +123,10 @@ public mario_gv1(Context context) {
107
123
gomba = Bitmap .createScaledBitmap (gomba , gomba_width , gomba_height_hit +gomba_height_jump , false );
108
124
gomba2 = BitmapFactory .decodeResource (getResources (), R .drawable .bild2 );
109
125
gomba2 = Bitmap .createScaledBitmap (gomba2 , gomba_width , gomba_height_hit +gomba_height_jump , false );
126
+ vogel1 = BitmapFactory .decodeResource (getResources (), R .drawable .bild1 );
127
+ vogel1 = Bitmap .createScaledBitmap (vogel1 , vogel_width , vogel_height_jump +vogel_height_hit , false );
128
+ vogel2 = BitmapFactory .decodeResource (getResources (), R .drawable .bild2 );
129
+ vogel2 = Bitmap .createScaledBitmap (vogel2 , vogel_width , vogel_height_jump +vogel_height_hit , false );
110
130
111
131
background_img = BitmapFactory .decodeResource (getResources (), R .drawable .mario_back );
112
132
background_img = Bitmap .createScaledBitmap (background_img , width , height , false );
@@ -117,10 +137,8 @@ public mario_gv1(Context context) {
117
137
score_paint .setTypeface (Typeface .DEFAULT_BOLD );
118
138
score_paint .setAntiAlias (true );
119
139
live [0 ] = BitmapFactory .decodeResource (getResources (), R .drawable .heart );
120
- //live[0] = BitmapFactory.decodeResource(getResources(), R.drawable.heart);
121
140
live [0 ] = Bitmap .createScaledBitmap (live [0 ], width /10 , height /10 , false );
122
141
live [1 ] = BitmapFactory .decodeResource (getResources (), R .drawable .heart_broken );
123
- //live[1] = BitmapFactory.decodeResource(getResources(), R.drawable.heart_broken);
124
142
live [1 ] = Bitmap .createScaledBitmap (live [1 ], width /10 , height /10 , false );
125
143
tolleranz =blocksize /5 ;
126
144
tolleranz_block_stehen =mario .getWidth ()/2 ;
@@ -158,9 +176,11 @@ protected void onDraw(Canvas canvas) {
158
176
once4 =false ;
159
177
mario_move ();
160
178
gomba_move ();
179
+ vogel_move ();
161
180
mario_floorcheck ();
162
181
mario_hitcheck ();
163
182
mario_events ();
183
+ /*
164
184
if (!init_cameratransition) {
165
185
oldspeed = newspeed;
166
186
newspeed = speedx;
@@ -170,7 +190,7 @@ protected void onDraw(Canvas canvas) {
170
190
init_cameratransition = true;
171
191
current_frame = 1;
172
192
}
173
-
193
+ */
174
194
175
195
176
196
camerax = mariox -width /7 ;
@@ -200,6 +220,15 @@ protected void onDraw(Canvas canvas) {
200
220
}
201
221
j ++;
202
222
}
223
+ j =0 ;
224
+ while (j <vogelx .length ){
225
+ if (vogel_rechts ){
226
+ canvas .drawBitmap (vogel1 , (camerax -vogelx [j ]+width /2 ), vogely [j ], null );
227
+ } else {
228
+ canvas .drawBitmap (vogel2 , (camerax -vogelx [j ]+width /2 ), vogely [j ], null );
229
+ }
230
+ j ++;
231
+ }
203
232
canvas .drawText ("Score: " + score + ' ' + gombasx [0 ] + ' ' + gombasy [0 ]+' ' , 20 , 60 , score_paint );
204
233
framecounter ++;
205
234
@@ -277,6 +306,32 @@ public void gomba_move(){
277
306
278
307
}
279
308
309
+ private void vogel_move (){
310
+ if (framecounter ==1 ){
311
+ vogel_durchlauf ++;
312
+ if (vogel_durchlauf <3 ){
313
+ vogel_rechts =true ;
314
+ } else {
315
+ vogel_rechts =false ;
316
+ }
317
+ vogel_durchlauf =vogel_durchlauf %6 ;
318
+ }
319
+ int i =0 ;
320
+ while (i <vogelx .length ){
321
+ if (vogel_rechts ){
322
+ vogelx [i ]=vogelx [i ]-vogelspeedx ;
323
+ } else {
324
+ vogelx [i ]=vogelx [i ]+vogelspeedx ;
325
+ }
326
+ if (framecounter <33 ){
327
+ vogely [i ]=vogely [i ]-vogelspeedy ;
328
+ } else {
329
+ vogely [i ]=vogely [i ]+vogelspeedy ;
330
+ }
331
+ i ++;
332
+ }
333
+ }
334
+
280
335
private boolean gomba_floorcheck (int i ) {
281
336
int temp = 0 ;
282
337
while (temp < blocksx .length ) {
@@ -353,6 +408,20 @@ public void mario_hitcheck(){
353
408
}
354
409
temp ++;
355
410
}
411
+ temp = 0 ;
412
+ while (temp <vogelx .length ){
413
+ if (vogelx [temp ] >= mariox -mario .getWidth () && vogelx [temp ] <= mariox +vogel_width ){
414
+ if (vogely [temp ]+vogel_height_hit >= marioy +vogel_height_jump && vogely [temp ]+vogel_height_hit <= marioy +mario .getHeight ()){
415
+ hit_spike ();
416
+ return ;
417
+ }
418
+ if (vogely [temp ] >= marioy -vogel_height_jump && vogely [temp ]<= marioy +mario .getHeight ()){
419
+ kill_vogel (temp );
420
+ return ;
421
+ }
422
+ }
423
+ temp ++;
424
+ }
356
425
357
426
}
358
427
@@ -375,6 +444,13 @@ private void kill_gomba(int temp){
375
444
score = score + 100 ;
376
445
}
377
446
447
+ private void kill_vogel (int temp ){
448
+ speedy =-sprungkraft /3 ;
449
+ doppelsprung =false ;
450
+ vogely [temp ]=2 * height ;
451
+ score = score + 100 ;
452
+ }
453
+
378
454
public void mario_blockcheck (){
379
455
int temp = 0 ;
380
456
while (temp <blocksx .length ){
@@ -628,4 +704,16 @@ private void init_level_gombas(){
628
704
}
629
705
}
630
706
707
+ private void init_level_vogel (){
708
+ ArrayList xwerte = new ArrayList <Integer >();
709
+ ArrayList ywerte = new ArrayList <Integer >();
710
+
711
+ xwerte .add (-50 *blocksize );
712
+ ywerte .add (height -9 *blocksize );
713
+ xwerte .add (-3 *blocksize );
714
+ ywerte .add (height -10 *blocksize );
715
+
716
+ vogelx =convertIntegers (xwerte );
717
+ vogely =convertIntegers (ywerte );
718
+ }
631
719
}
0 commit comments