Skip to content

Commit cef1fa0

Browse files
authored
Merge pull request #46 from sebuech02/dev
Super Wiecklaß erste überlegungen,
2 parents 893664f + db85576 commit cef1fa0

File tree

2 files changed

+93
-4
lines changed

2 files changed

+93
-4
lines changed

app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="com.example.inet_test">
44
<uses-permission android:name="android.permission.INTERNET" />
55
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
6+
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/>
67
<application
78
android:allowBackup="true"
89
android:icon="@mipmap/ic_launcher"

app/src/main/java/com/example/inet_test/mario_gv1.java

+92-4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class mario_gv1 extends View {
4646
private int[] blocksx;
4747
private int[] blocksy;
4848
private int spikesize;
49+
4950
private int[] gombasx;
5051
private int[] gombasy;
5152
private int[] gombasd;
@@ -54,10 +55,21 @@ public class mario_gv1 extends View {
5455
private int gomba_width;
5556
private int gombaspeedx=3;
5657
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+
5769
private int[] spikesx;
5870
private int[] spikesy;
5971
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;
6173
private boolean once, once2, once3, once4;
6274
private float oldspeed, newspeed;
6375
private boolean init_cameratransition=false;
@@ -89,11 +101,15 @@ public mario_gv1(Context context) {
89101
gomba_width = blocksize;
90102
gomba_height_jump=blocksize/5;
91103
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;
92107
mariox=0;
93108

94109
init_level_blocks();
95110
init_level_spikes();
96111
init_level_gombas();
112+
init_level_vogel();
97113

98114
mario = BitmapFactory.decodeResource(getResources(), R.drawable.mario);
99115
mario = Bitmap.createScaledBitmap(mario, width/25, width/25, false);
@@ -107,6 +123,10 @@ public mario_gv1(Context context) {
107123
gomba = Bitmap.createScaledBitmap(gomba, gomba_width, gomba_height_hit+gomba_height_jump, false);
108124
gomba2 = BitmapFactory.decodeResource(getResources(), R.drawable.bild2);
109125
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);
110130

111131
background_img = BitmapFactory.decodeResource(getResources(), R.drawable.mario_back);
112132
background_img = Bitmap.createScaledBitmap(background_img, width, height, false);
@@ -117,10 +137,8 @@ public mario_gv1(Context context) {
117137
score_paint.setTypeface(Typeface.DEFAULT_BOLD);
118138
score_paint.setAntiAlias(true);
119139
live[0] = BitmapFactory.decodeResource(getResources(), R.drawable.heart);
120-
//live[0] = BitmapFactory.decodeResource(getResources(), R.drawable.heart);
121140
live[0] = Bitmap.createScaledBitmap(live[0], width/10, height/10, false);
122141
live[1] = BitmapFactory.decodeResource(getResources(), R.drawable.heart_broken);
123-
//live[1] = BitmapFactory.decodeResource(getResources(), R.drawable.heart_broken);
124142
live[1] = Bitmap.createScaledBitmap(live[1], width/10, height/10, false);
125143
tolleranz=blocksize/5;
126144
tolleranz_block_stehen=mario.getWidth()/2;
@@ -158,9 +176,11 @@ protected void onDraw(Canvas canvas) {
158176
once4=false;
159177
mario_move();
160178
gomba_move();
179+
vogel_move();
161180
mario_floorcheck();
162181
mario_hitcheck();
163182
mario_events();
183+
/*
164184
if (!init_cameratransition) {
165185
oldspeed = newspeed;
166186
newspeed = speedx;
@@ -170,7 +190,7 @@ protected void onDraw(Canvas canvas) {
170190
init_cameratransition = true;
171191
current_frame = 1;
172192
}
173-
193+
*/
174194

175195

176196
camerax = mariox-width/7;
@@ -200,6 +220,15 @@ protected void onDraw(Canvas canvas) {
200220
}
201221
j++;
202222
}
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+
}
203232
canvas.drawText("Score: " + score + ' ' + gombasx[0] + ' ' + gombasy[0]+' ', 20, 60, score_paint);
204233
framecounter ++;
205234

@@ -277,6 +306,32 @@ public void gomba_move(){
277306

278307
}
279308

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+
280335
private boolean gomba_floorcheck(int i) {
281336
int temp = 0;
282337
while (temp < blocksx.length) {
@@ -353,6 +408,20 @@ public void mario_hitcheck(){
353408
}
354409
temp++;
355410
}
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+
}
356425

357426
}
358427

@@ -375,6 +444,13 @@ private void kill_gomba(int temp){
375444
score = score + 100;
376445
}
377446

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+
378454
public void mario_blockcheck(){
379455
int temp = 0;
380456
while (temp<blocksx.length){
@@ -628,4 +704,16 @@ private void init_level_gombas(){
628704
}
629705
}
630706

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+
}
631719
}

0 commit comments

Comments
 (0)