sprite cleanup and new sprites added.

code made compatible with not samsung devices again.
added pause menu.
bugfix in startlevel.
This commit is contained in:
Administrator
2014-04-22 13:23:47 +02:00
parent fa997fb77a
commit a7dd68476d
11 changed files with 139 additions and 105 deletions
+5 -4
View File
@@ -244,10 +244,11 @@ containing a value of this type.
public static final int sprite_i4r=0x7f020033; public static final int sprite_i4r=0x7f020033;
public static final int sprite_l1=0x7f020034; public static final int sprite_l1=0x7f020034;
public static final int sprite_l2=0x7f020035; public static final int sprite_l2=0x7f020035;
public static final int sprite_s=0x7f020036; public static final int sprite_pause=0x7f020036;
public static final int sprite_score=0x7f020037; public static final int sprite_s=0x7f020037;
public static final int sprite_t=0x7f020038; public static final int sprite_score=0x7f020038;
public static final int sprite_z=0x7f020039; public static final int sprite_t=0x7f020039;
public static final int sprite_z=0x7f02003a;
} }
public static final class id { public static final class id {
public static final int action_settings=0x7f050005; public static final int action_settings=0x7f050005;
Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

+120 -98
View File
@@ -31,8 +31,13 @@ public class GamePlay extends GameStateInterface
public void onPause() public void onPause()
{ {
mp.pause(); mp.pause();
if (GameState != GS_GAMEOVER)
SetGameState(GS_PAUSED, false);
else
{
SetGameState(GS_PAUSED, false); }
canvasView.postInvalidate();
} }
@Override @Override
@@ -368,6 +373,7 @@ public class GamePlay extends GameStateInterface
bitmapi1r, bitmapi2r, bitmapi3r, bitmapi4r, bitmapblockline, bitmapscore, bitmapcontroller, bitmapgameover; bitmapi1r, bitmapi2r, bitmapi3r, bitmapi4r, bitmapblockline, bitmapscore, bitmapcontroller, bitmapgameover;
Bitmap Font0, Font1, Font2, Font3, Font4, Font5, Font6, Font7, Font8, Font9; Bitmap Font0, Font1, Font2, Font3, Font4, Font5, Font6, Font7, Font8, Font9;
Bitmap bitmappause;
// Audio. // Audio.
MediaPlayer mp; MediaPlayer mp;
@@ -600,6 +606,13 @@ public class GamePlay extends GameStateInterface
bitmapgameover = Bitmap.createScaledBitmap(bitmapgameover, bitmapgameover = Bitmap.createScaledBitmap(bitmapgameover,
(int)GetRealPixelSize(DIP_W, dpWidth, (GameSpaceRight - GameSpaceLeft)), (int)GetRealPixelSize(DIP_W, dpWidth, (GameSpaceRight - GameSpaceLeft)),
(int)GetRealPixelSize(DIP_H, dpHeight, (GameSpaceBottom - GameSpaceTop)), false); (int)GetRealPixelSize(DIP_H, dpHeight, (GameSpaceBottom - GameSpaceTop)), false);
bitmappause = BitmapFactory.decodeResource(r,
R.drawable.sprite_pause);
bitmappause = Bitmap.createScaledBitmap(bitmappause,
(int)GetRealPixelSize(DIP_W, dpWidth, (GameSpaceRight - GameSpaceLeft)),
(int)GetRealPixelSize(DIP_H, dpHeight, (GameSpaceBottom - GameSpaceTop)), false);
} }
private void LoadFont() private void LoadFont()
@@ -688,114 +701,117 @@ public class GamePlay extends GameStateInterface
if (PayedVersion) if (PayedVersion)
{ {
// Scores.
DrawLines(canvas, lines); DrawLines(canvas, lines);
DrawLevel(canvas, startLevel + level); DrawLevel(canvas, level);
DrawScore(canvas, score); DrawScore(canvas, score);
// Next Coming Tetrimino. // Next Coming Tetrimino.
ShowNextComingTetrimino(canvas); ShowNextComingTetrimino(canvas);
} }
for (int x=0; x<10; x++) if(GameState == GS_PLAYING)
{ {
for (int y=0; y<18; y++) for (int x=0; x<10; x++)
{ {
switch (drawArray[y][x] + (blockArray[y][x] >= 0 ? blockArray[y][x] : 0)) for (int y=0; y<18; y++)
{ {
case 0: switch (drawArray[y][x] + (blockArray[y][x] >= 0 ? blockArray[y][x] : 0))
break;
case 1:
{ {
canvas.drawBitmap(bitmapb, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), case 0:
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); break;
break; case 1:
} {
case 2: canvas.drawBitmap(bitmapb, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapt, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 2:
} {
case 3: canvas.drawBitmap(bitmapt, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapz, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 3:
} {
case 5: canvas.drawBitmap(bitmapz, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmaps, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 5:
} {
case 6: canvas.drawBitmap(bitmaps, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapl2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 6:
} {
case 7: canvas.drawBitmap(bitmapl2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapl1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 7:
} {
case 8: canvas.drawBitmap(bitmapl1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 8:
} {
case 9: canvas.drawBitmap(bitmapi1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 9:
} {
case 10: canvas.drawBitmap(bitmapi2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi3, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 10:
} {
case 11: canvas.drawBitmap(bitmapi3, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi4, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 11:
} {
case 12: // Rotated canvas.drawBitmap(bitmapi4, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi1r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 12: // Rotated
} {
case 13: canvas.drawBitmap(bitmapi1r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi2r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 13:
} {
case 14: canvas.drawBitmap(bitmapi2r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi3r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 14:
} {
case 15: canvas.drawBitmap(bitmapi3r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
canvas.drawBitmap(bitmapi4r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)), break;
(int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null); }
break; case 15:
} {
default: canvas.drawBitmap(bitmapi4r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 10, GameSpaceLeft, GameSpaceRight)),
{ (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 18, GameSpaceTop, GameSpaceBottom)), null);
break;
Rect(canvas, map(y, 0, 18, GameSpaceTop, GameSpaceBottom), map(y+1, 0, 18, GameSpaceTop, GameSpaceBottom), }
map(x, 0, 10, GameSpaceLeft, GameSpaceRight), map(x+1, 0, 10, GameSpaceLeft, GameSpaceRight), default:
Color.RED); {
break; // In case of error.
Rect(canvas, map(y, 0, 18, GameSpaceTop, GameSpaceBottom), map(y+1, 0, 18, GameSpaceTop, GameSpaceBottom),
map(x, 0, 10, GameSpaceLeft, GameSpaceRight), map(x+1, 0, 10, GameSpaceLeft, GameSpaceRight),
Color.RED);
break;
}
} }
} }
} }
@@ -806,6 +822,12 @@ public class GamePlay extends GameStateInterface
canvas.drawBitmap(bitmapgameover, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft), canvas.drawBitmap(bitmapgameover, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft),
(int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null); (int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null);
} }
if (GameState == GS_PAUSED)
{
canvas.drawBitmap(bitmappause, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft),
(int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null);
}
} }
private void ShowNextComingTetrimino(Canvas canvas) private void ShowNextComingTetrimino(Canvas canvas)
+14 -3
View File
@@ -27,6 +27,8 @@ public class MainActivity extends Activity
private Sgesture mGesture; private Sgesture mGesture;
private SgestureHand mHand; private SgestureHand mHand;
private boolean SamsungDevice = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -36,15 +38,23 @@ public class MainActivity extends Activity
try { try {
mGesture.initialize(this); mGesture.initialize(this);
SamsungDevice = true;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
//Error Handling //Error Handling
Log.d("MangaValk", "mark1");
SamsungDevice = false;
} catch (SsdkUnsupportedException e2) { } catch (SsdkUnsupportedException e2) {
//Error Handling //Error Handling
Log.d("MangaValk", "mark2");
SamsungDevice = false;
} }
if(mGesture.isFeatureEnabled(Sgesture.TYPE_HAND_PRIMITIVE)){ if (SamsungDevice)
mHand = new SgestureHand(Looper.getMainLooper(), mGesture); {
mHand.start(Sgesture.TYPE_HAND_PRIMITIVE, mChangeListener); if(mGesture.isFeatureEnabled(Sgesture.TYPE_HAND_PRIMITIVE)){
mHand = new SgestureHand(Looper.getMainLooper(), mGesture);
mHand.start(Sgesture.TYPE_HAND_PRIMITIVE, mChangeListener);
}
} }
@@ -102,6 +112,7 @@ public class MainActivity extends Activity
} }
}; };
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB