diff --git a/src/mangavalk/tetris/CanvasView.java b/src/mangavalk/tetris/CanvasView.java index d0aedd4..cd034fe 100644 --- a/src/mangavalk/tetris/CanvasView.java +++ b/src/mangavalk/tetris/CanvasView.java @@ -12,6 +12,9 @@ public class CanvasView extends View // Variabelen Resources r; + GameStateInterface Foreground = null; + GameStateInterface Background = null; + // Score. public int startLevel = 0; @@ -23,6 +26,8 @@ public class CanvasView extends View super(context); super.setBackgroundColor(Color.BLACK); + + Foreground = new GamePlay(); } public void SetActivity(Activity activity) @@ -31,6 +36,7 @@ public class CanvasView extends View GamePlay.Instance.SetCanvas(this); GamePlay.Instance.SetStartLevel(startLevel); GamePlay.Instance.SetPayedVersion(PayedVersion); + GamePlay.Instance.SetGameState(GamePlay.GS_LOAD); // Start Game. @@ -53,4 +59,21 @@ public class CanvasView extends View { GamePlay.Instance.SendMove(x, y, pointerUp); } + + public void OnGameStateChanged(int gameState) + { + switch(gameState) + { + case GameStateInterface.GS_PAUSED: + { + + break; + } + case GameStateInterface.GS_GAMEOVER: + { + + break; + } + } + } } diff --git a/src/mangavalk/tetris/GameMenu.java b/src/mangavalk/tetris/GameMenu.java new file mode 100644 index 0000000..2add296 --- /dev/null +++ b/src/mangavalk/tetris/GameMenu.java @@ -0,0 +1,73 @@ +package mangavalk.tetris; + +import android.app.Activity; +import android.graphics.Canvas; + +public class GameMenu extends GameStateInterface +{ + // Instance. + public static GameMenu Instance = new GameMenu(); + + // GameState. + protected int GameState = GS_STOPPED; + + // Methods. + @Override + public void DrawFrame(Canvas canvas) { + // TODO Auto-generated method stub + + } + + @Override + public void SendMove(float x, float y, boolean pointerUp) { + // TODO Auto-generated method stub + + } + + @Override + public void SetGameState(int gameState) + { + GameState = gameState; + + switch(GameState) + { + + } + + canvasView.OnGameStateChanged(GameState); + } + + @Override + public void onPause() { + // TODO Auto-generated method stub + + } + + @Override + public void SetActivity(Activity activity) { + // TODO Auto-generated method stub + + } + + @Override + public void SetCanvas(CanvasView _CanvasView) { + // TODO Auto-generated method stub + + } + + @Override + public void SetPayedVersion(boolean payedVersion) { + // TODO Auto-generated method stub + + } + + @Override + public int GetGameState() { + // TODO Auto-generated method stub + return 0; + } + + // Internal. + CanvasView canvasView; + Activity activity = null; +} diff --git a/src/mangavalk/tetris/GamePlay.java b/src/mangavalk/tetris/GamePlay.java index 1c6fd4c..051dde6 100644 --- a/src/mangavalk/tetris/GamePlay.java +++ b/src/mangavalk/tetris/GamePlay.java @@ -1,1939 +1,1941 @@ -package mangavalk.tetris; - -import android.app.Activity; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Paint.Style; -import android.media.MediaPlayer; -import android.os.Handler; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.Display; - -import java.util.ArrayList; -import java.util.TimerTask; - -public class GamePlay implements GameStateInterface -{ - // Instance. - public static GameStateInterface Instance = new GamePlay(); - - // GameState. - protected int GameState = GS_STOPPED; - - // Methods. - @Override - public void DrawFrame(Canvas canvas) { - DrawGameSpace(canvas); - } - - @Override - public void onPause() - { - mp.pause(); - - GameState = GS_PAUSED; - } - - @Override - public void SendMove(float x, float y, boolean pointerUp) { - int moveX = (int)((x / Width) * 90); - int moveY = (int)((y / Height) * 160); - - if (!pointerUp) - { - if (GameState != GS_GAMEOVER) - { - if (moveX >= 28 && moveX <= 55 && moveY >= 143 && moveY <= 155) // Start - { - if (GameState == GS_PLAYING) - onPause(); - else - { - mp.start(); - GameState = GS_PLAYING; - } - } - } - } - - if (GameState == GS_PLAYING) - { - InputsGamePlaying(x, y, pointerUp); - } - - if (GameState == GS_GAMEOVER) - { - StartGame(); - } - } - - @Override - public void SetGameState(int gameState) { - GameState = gameState; - - switch(GameState) - { - case GS_LOAD: - { - Load(); - break; - } - case GS_START: - { - StartGame(); - break; - } - } - } - - // Set - @Override - public void SetCanvas(CanvasView _CanvasView) - { - canvasView = _CanvasView; - } - - @Override - public void SetActivity(Activity _Activity) - { - activity = _Activity; - } - - @Override - public void SetStartLevel(int StartLevel) - { - startLevel = StartLevel; - } - - @Override - public void SetPayedVersion(boolean payedVersion) - { - PayedVersion = payedVersion; - } - - // Get - @Override - public int GetGameState() - { - return GameState; - } - - // Internal. - CanvasView canvasView; - Activity activity = null; - - // Variabelen - Resources r; - - // Sizes - float dpHeight; - float dpWidth; - - float Height; - float Width; - - // Block Array - int[][] blockArray = new int[][]{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - }; - - // Draw Array - int[][] drawArray = new int[][]{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - }; - - int[][][][] drawBlocks = new int[][][][]{ - { - { - {0, 0, 0, 0}, - {8, 9, 10, 11}, - {0, 0, 0, 0}, - {0, 0, 0, 0} - }, - { - {0, 0, 12, 0}, - {0, 0, 13, 0}, - {0, 0, 14, 0}, - {0, 0, 15, 0} - }, - { - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {8, 9, 10, 11}, - {0, 0, 0, 0} - }, - { - {0, 12, 0, 0}, - {0, 13, 0, 0}, - {0, 14, 0, 0}, - {0, 15, 0, 0} - } - }, - { - { - {7, 0, 0, 0}, - {7, 7, 7, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 7, 7, 0}, - {0, 7, 0, 0}, - {0, 7, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 0, 0, 0}, - {7, 7, 7, 0}, - {0, 0, 7, 0}, - {0, 0, 0, -1} - }, - { - {0, 7, 0, 0}, - {0, 7, 0, 0}, - {7, 7, 0, 0}, - {0, 0, 0, -1} - } - }, - { - { - {0, 0, 6, 0}, - {6, 6, 6, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 6, 0, 0}, - {0, 6, 0, 0}, - {0, 6, 6, 0}, - {0, 0, 0, -1} - }, - { - {0, 0, 0, 0}, - {6, 6, 6, 0}, - {6, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {6, 6, 0, 0}, - {0, 6, 0, 0}, - {0, 6, 0, 0}, - {0, 0, 0, -1} - } - }, - { - { - {0, 1, 1, 0}, - {0, 1, 1, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 1, 1, 0}, - {0, 1, 1, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 1, 1, 0}, - {0, 1, 1, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 1, 1, 0}, - {0, 1, 1, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - } - }, - { - { - {0, 3, 3, 0}, - {3, 3, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 3, 0, 0}, - {0, 3, 3, 0}, - {0, 0, 3, 0}, - {0, 0, 0, -1} - }, - { - {0, 0, 0, 0}, - {0, 3, 3, 0}, - {3, 3, 0, 0}, - {0, 0, 0, -1} - }, - { - {3, 0, 0, 0}, - {3, 3, 0, 0}, - {0, 3, 0, 0}, - {0, 0, 0, -1} - } - }, - { - { - {0, 2, 0, 0}, - {2, 2, 2, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 2, 0, 0}, - {0, 2, 2, 0}, - {0, 2, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 0, 0, 0}, - {2, 2, 2, 0}, - {0, 2, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 2, 0, 0}, - {2, 2, 0, 0}, - {0, 2, 0, 0}, - {0, 0, 0, -1} - } - }, - { - { - {5, 5, 0, 0}, - {0, 5, 5, 0}, - {0, 0, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 0, 5, 0}, - {0, 5, 5, 0}, - {0, 5, 0, 0}, - {0, 0, 0, -1} - }, - { - {0, 0, 0, 0}, - {5, 5, 0, 0}, - {0, 5, 5, 0}, - {0, 0, 0, -1} - }, - { - {0, 5, 0, 0}, - {5, 5, 0, 0}, - {5, 0, 0, 0}, - {0, 0, 0, -1} - } - } - }; - - int[] LevelSpeed = { 53, 49, 45, 41, 37, 33, 28, 22, 17, 11, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 3}; - - // Parameters. - int GameSpaceLeft = 4; - int GameSpaceTop = 0; - int GameSpaceRight = 53; - int GameSpaceBottom = 115; - - // Tetrmino. - int CurrentBlock = 0; - int CurrentBlockPossition = 0; - - int NewBlock = 0; - int NewBlockPossition = 0; - - // Sprites. - Bitmap bitmapl1, bitmapl2, bitmapt, bitmapb, bitmaps, bitmapz, bitmapi1, bitmapi2, bitmapi3, bitmapi4, - bitmapi1r, bitmapi2r, bitmapi3r, bitmapi4r, bitmapblockline, bitmapscore, bitmapcontroller, bitmapgameover; - - Bitmap Font0, Font1, Font2, Font3, Font4, Font5, Font6, Font7, Font8, Font9; - - // Audio. - MediaPlayer mp; - - // Score. - int startLevel = 0; - int level = 0; - int lines = 0; - int score = 0; - - // Add Settings. - boolean PayedVersion; - - // Timer. - TimerTask MoveEvent = new TimerTask() { - @Override - public void run() { - GoDown(); - } - }; - - private Handler handler = new Handler(); - private Runnable runnable = new Runnable() { - @Override - public void run() { - level = ( (startLevel + lines)<=200 ? startLevel + (lines / 10) : 20 ); - int newSpeed = (int)((1000 / 59.73) * LevelSpeed[level]); - handler.postDelayed(this, newSpeed); - GoDown(); - } - }; - - - // Methods. - - // Inputs. - int OldInputTime=0; - - // Methods. - private void StartGame() - { - // Clear. - for ( int i=0; i= 0 ? blockArray[y][x] : 0)) - { - case 0: - break; - case 1: - { - 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); - break; - } - case 2: - { - 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); - break; - } - case 3: - { - 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); - break; - } - case 5: - { - 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); - break; - } - case 6: - { - 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); - break; - } - case 7: - { - 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); - break; - } - case 8: - { - 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); - break; - } - case 9: - { - 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); - break; - } - case 10: - { - 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); - break; - } - case 11: - { - 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); - break; - } - case 12: // Rotated - { - 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); - break; - } - case 13: - { - 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); - break; - } - case 14: - { - 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); - break; - } - case 15: - { - 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; - } - default: - { - - 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; - } - } - } - } - - if (GameState == GS_GAMEOVER) - { - canvas.drawBitmap(bitmapgameover, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft), - (int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null); - } - } - - private void ShowNextComingTetrimino(Canvas canvas) - { - int top = 32; - - for (int x=0; x<4; x++) - { - for (int y=0; y<4; y++) - { - switch(drawBlocks[NewBlock][NewBlockPossition][y][x]) - { - case 1: - canvas.drawBitmap(bitmapb, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 2: - canvas.drawBitmap(bitmapt, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 3: - canvas.drawBitmap(bitmapz, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 5: - canvas.drawBitmap(bitmaps, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 6: - canvas.drawBitmap(bitmapl2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 7: - canvas.drawBitmap(bitmapl1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 8: - canvas.drawBitmap(bitmapi1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 9: - canvas.drawBitmap(bitmapi2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 10: - canvas.drawBitmap(bitmapi3, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 11: - canvas.drawBitmap(bitmapi4, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 12: - canvas.drawBitmap(bitmapi1r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 13: - canvas.drawBitmap(bitmapi2r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 14: - canvas.drawBitmap(bitmapi3r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - case 15: - canvas.drawBitmap(bitmapi4r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), - (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); - break; - } - } - } - } - - private void DrawScore(Canvas canvas, int Score) - { - int height = 104-8; - switch ((Score / 100000) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch ((Score / 10000) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch ((Score / 1000) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch ((Score / 100) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch ((Score / 10) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch (Score % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - } - - private void DrawLines(Canvas canvas, int Lines) - { - int height = 55-4; - switch ((Lines / 1000) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch ((Lines / 100) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch ((Lines / 10) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch (Lines % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - } - - private void DrawLevel(Canvas canvas, int Level) - { - int height = 76-6; - switch ((Level / 10) % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - switch (Level % 10) - { - case 0: - canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 1: - canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 2: - canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 3: - canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 4: - canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 5: - canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 6: - canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 7: - canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 8: - canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - case 9: - canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); - break; - } - } - - // Input - public void sendMove(float x, float y, boolean Released) - { - int moveX = (int)((x / Width) * 90); - int moveY = (int)((y / Height) * 160); - - if (!Released) - { - if (GameState != GS_GAMEOVER) - { - if (moveX >= 28 && moveX <= 55 && moveY >= 143 && moveY <= 155) // Start - { - if (GameState == GS_PLAYING) - onPause(); - else - { - mp.start(); - GameState = GS_PLAYING; - } - } - } - } - - if (GameState == GS_PLAYING) - { - InputsGamePlaying(x, y, Released); - } - - if (GameState == GS_GAMEOVER) - { - StartGame(); - } - } - - private void InputsGamePlaying(float x, float y, boolean Released) - { - int moveX = (int)((x / Width) * 90); - int moveY = (int)((y / Height) * 160); - - if (!Released) - { - if (moveX >= 1 && moveX <= 11 && moveY >= 122 && moveY <= 133) // Left - { - if(CanBlockGoLeft()) - { - MoveBlockLeft(); - canvasView.postInvalidate(); - } - } - else if (moveX >= 55 && moveX <= 70 && moveY >= 122 && moveY <= 137) // Rotate Left - { - RotateBlockLeft(); - canvasView.postInvalidate(); - } - else if (moveX >= 74 && moveX <= 88 && moveY >= 115 && moveY <= 137) // Rotate Right - { - RotateBlockRight(); - canvasView.postInvalidate(); - } - else if (moveX >= 21 && moveX <= 33 && moveY >= 122 && moveY <= 133) // Right - { - if(CanBlockGoRight()) - { - MoveBlockRight(); - canvasView.postInvalidate(); - } - } - } - if (moveX >= 11 && moveX <= 21 && moveY >= 133 && moveY <= 144) // Down - { - if (!Released) - { - // Soft Drop - if (CanBlockGoDown()) - { - MoveBlockDown(); - canvasView.postInvalidate(); - } - OldInputTime = (int)System.currentTimeMillis(); - } - else - { - int CurrentTime = (int)System.currentTimeMillis(); - if ((CurrentTime - OldInputTime) >= 250) - { - // Hard Drop - while (CanBlockGoDown()) - { - MoveBlockDown(); - } - canvasView.postInvalidate(); - } - } - } - } - - // Game Logic - private void GoDown() - { - if (GameState == GS_PLAYING) - { - /// Can the Block go down? - if (CanBlockGoDown()) - { - MoveBlockDown(); - canvasView.postInvalidate(); - } - else - { - ParseBlockArrayToDrawArray(); - - CheckForCompletedRows(); - - //spawn new block - if (!SpawnBlock()) - { - GameState = GS_GAMEOVER; - - mp.stop(); - canvasView.postInvalidate(); - } - else - { - canvasView.postInvalidate(); - } - } - } - } - - private boolean CanBlockGoDown() - { - //blockArray - for (int x=0; x<10; x++) - { - for (int y=0; y<18; y++) - { - if (blockArray[y][x] != 0) - { - if (y + 1 == 18) - return false; - else if (drawArray[y+1][x] != 0) - return false; - } - } - } - - return true; - } - - private boolean CanBlockGoLeft() - { - //blockArray - for (int y=0; y<18; y++) - { - for (int x=1; x<10; x++) - { - if (blockArray[y][x] >= 1) - { - if (drawArray[y][x-1] != 0) - return false; - } - if (blockArray[y][0] >= 1) - return false; - } - } - - return true; - } - - private boolean CanBlockGoRight() - { - //blockArray - for (int y=0; y<18; y++) - { - for (int x=0; x<9; x++) - { - if (blockArray[y][x] >= 1) - { - if (drawArray[y][x+1] != 0) - return false; - } - if (blockArray[y][9] >= 1) - return false; - } - } - - return true; - } - - private void MoveBlockDown() - { - for (int x=0; x<10; x++) - { - for (int y=17; y>0; y--) - { - blockArray[y][x] = blockArray[y-1][x]; - blockArray[y-1][x] = 0; - } - } - } - - private void MoveBlockLeft() - { - for (int y=0; y<18; y++) - { - for (int x=1; x<10; x++) - { - blockArray[y][x-1] = blockArray[y][x]; - blockArray[y][x] = 0; - } - } - } - - private void MoveBlockRight() - { - for (int y=0; y<18; y++) - { - for (int x=8; x>=0; x--) - { - blockArray[y][x+1] = blockArray[y][x]; - blockArray[y][x] = 0; - } - } - } - - private void RotateBlockRight() - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][3][3] != -1) - { - for (int y=0; y<18-3; y++) - { - for (int x=0; x<10-3; x++) - { - boolean foundPossition = true; - - for (int i=0; i<4; i++) - { - for (int i2=0; i2<4; i2++) - { - if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) - { - foundPossition = false; - } - } - } - - - if (foundPossition) - { - if (CurrentBlockPossition < 3) - CurrentBlockPossition++; - else - CurrentBlockPossition = 0; - } - - // Test for collision !!! - boolean Collision = false; - - for (int i=0; i<4; i++) - { - for (int i2=0; i2<4; i2++) - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] >= 1) - { - if (drawArray[y+i][x+i2] != 0) - { - Collision = true; - } - } - } - } - - if (!Collision) - { - if (foundPossition) - { - for (int i=0; i<4; i++) - { - for (int i2=0; i2<4; i2++) - { - blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; - } - } - } - } - } - } - } - else - { - for (int y=0; y<18-2; y++) - { - for (int x=0; x<10-2; x++) - { - boolean foundPossition = true; - - for (int i=0; i<3; i++) - { - for (int i2=0; i2<3; i2++) - { - if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) - { - foundPossition = false; - } - } - } - - if (foundPossition) - { - if (CurrentBlockPossition < 3) - CurrentBlockPossition++; - else - CurrentBlockPossition = 0; - } - - // Test for collision !!! - boolean Collision = false; - - for (int i=0; i<3; i++) - { - for (int i2=0; i2<3; i2++) - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] >= 1) - { - if (drawArray[y+i][x+i2] != 0) - { - Collision = true; - } - } - } - } - - if (!Collision) - { - if (foundPossition) - { - for (int i=0; i<3; i++) - { - for (int i2=0; i2<3; i2++) - { - blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; - } - } - } - } - } - } - } - } - - private void RotateBlockLeft() - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][3][3] != -1) - { - for (int y=0; y<18-3; y++) - { - for (int x=0; x<10-3; x++) - { - boolean foundPossition = true; - - for (int i=0; i<4; i++) - { - for (int i2=0; i2<4; i2++) - { - if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) - { - foundPossition = false; - } - } - } - - // Test for collision !!! - boolean Collision = false; - - if (foundPossition) - { - if (CurrentBlockPossition > 0) - CurrentBlockPossition--; - else - CurrentBlockPossition = 3; - } - - for (int i=0; i<4; i++) - { - for (int i2=0; i2<4; i2++) - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] != 0) - { - if (drawArray[y+i][x+i2] != 0) - { - Collision = true; - } - } - } - } - - if (!Collision) - { - if (foundPossition) - { - for (int i=0; i<4; i++) - { - for (int i2=0; i2<4; i2++) - { - blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; - } - } - } - } - } - } - } - else - { - for (int y=0; y<18-2; y++) - { - for (int x=0; x<10-2; x++) - { - boolean foundPossition = true; - - for (int i=0; i<3; i++) - { - for (int i2=0; i2<3; i2++) - { - if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) - { - foundPossition = false; - } - } - } - - // Test for collision !!! - boolean Collision = false; - - if (foundPossition) - { - if (CurrentBlockPossition > 0) - CurrentBlockPossition--; - else - CurrentBlockPossition = 3; - } - - for (int i=0; i<3; i++) - { - for (int i2=0; i2<3; i2++) - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] != 0) - { - if (drawArray[y+i][x+i2] != 0) - { - Collision = true; - } - } - } - } - - if (!Collision) - { - if (foundPossition) - { - for (int i=0; i<3; i++) - { - for (int i2=0; i2<3; i2++) - { - blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; - } - } - } - } - } - } - } - } - - private void ParseBlockArrayToDrawArray() - { - for (int x=0; x<10; x++) - { - for (int y=0; y<18; y++) - { - drawArray[y][x] += blockArray[y][x]; - blockArray[y][x] = 0; - } - } - } - - private void CheckForCompletedRows() - { - int LinesCleared = 0; - //drawArray - for (int y=17; y>1; y--) - { - boolean isComplete = true; - - for (int x=0; x<10; x++) - { - if (drawArray[y][x] == 0) - isComplete = false; - } - - if (isComplete) - { - for (int i=y; i>1; i--) - for (int x=0; x<10; x++) - { - drawArray[i][x] = drawArray[i-1][x]; - } - LinesCleared++; - lines++; - level = ( (startLevel + lines)<=200 ? startLevel + (lines / 10) : 20 ); - y++; - } - } - // Do Score here - switch (LinesCleared) - { - case 1: - score += 40 * ( level + 1 ); - break; - case 2: - score += 100 * ( level + 1 ); - break; - case 3: - score += 300 * ( level + 1 ); - break; - case 4: - score += 1200 * ( level + 1 ); - break; - } - } - - ArrayList Tetrimino; - private void CheckTetriminoSpawnArray() - { - // Pseudo random - if (Tetrimino == null || Tetrimino.size() <= 0) - { - Tetrimino = new ArrayList(); - do{ - int newTetrimino = (int)(Math.random() * (7)); - if (!Tetrimino.contains(newTetrimino)) - Tetrimino.add(newTetrimino); - }while (Tetrimino.size() < 7); - } - } - - - private boolean SpawnBlock() - { - CheckTetriminoSpawnArray(); - - CurrentBlock = NewBlock; - CurrentBlockPossition = NewBlockPossition; - - NewBlock = Tetrimino.get(0); - Tetrimino.remove(0); - NewBlockPossition = 0; - - for (int x=0; x<4; x++) - { - for (int y=0; y<4; y++) - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][y][x] != 0) - if (drawArray[y][x+3] != 0) - return false; - } - } - - for (int x=0; x<4; x++) - { - for (int y=0; y<4; y++) - { - if (drawBlocks[CurrentBlock][CurrentBlockPossition][y][x] >= 0) - blockArray[y][x+3] = drawBlocks[CurrentBlock][CurrentBlockPossition][y][x]; - } - } - - return true; - } - - // other logic - private void Rect(Canvas canvas, float Top, float Bottom, float Left, float Right, int Color) - { - Paint paint = new Paint(); - paint.setAntiAlias(true); - paint.setColor(Color); - paint.setStyle(Style.FILL); - - canvas.drawRect( - GetRealPixelSize(DIP_W, dpWidth, Left), - GetRealPixelSize(DIP_H, dpHeight, Top), - GetRealPixelSize(DIP_W, dpWidth, Right), - GetRealPixelSize(DIP_H, dpHeight, Bottom), paint); - } - - final static int DIP_H = 0; - final static int DIP_W = 1; - - private float GetRealPixelSize(int wH, float dpWH, double DIP) - { - if (wH == DIP_H) - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)(dpWH * ( DIP / 160 )), r.getDisplayMetrics()); - else if (wH == DIP_W) - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)(dpWH * ( DIP / 90 )), r.getDisplayMetrics()); - else - return 0; - } - - float map(float x, float in_min, float in_max, float out_min, float out_max) - { - return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; - } - -} +package mangavalk.tetris; + +import android.app.Activity; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Style; +import android.media.MediaPlayer; +import android.os.Handler; +import android.util.DisplayMetrics; +import android.util.TypedValue; +import android.view.Display; + +import java.util.ArrayList; +import java.util.TimerTask; + +public class GamePlay extends GameStateInterface +{ + // Instance. + public static GamePlay Instance = new GamePlay(); + + // GameState. + protected int GameState = GS_STOPPED; + + // Methods. + @Override + public void DrawFrame(Canvas canvas) { + DrawGameSpace(canvas); + } + + @Override + public void onPause() + { + mp.pause(); + + SetGameState(GS_PAUSED); + } + + @Override + public void SendMove(float x, float y, boolean pointerUp) { + int moveX = (int)((x / Width) * 90); + int moveY = (int)((y / Height) * 160); + + if (!pointerUp) + { + if (GameState != GS_GAMEOVER) + { + if (moveX >= 28 && moveX <= 55 && moveY >= 143 && moveY <= 155) // Start + { + if (GameState == GS_PLAYING) + onPause(); + else + { + mp.start(); + SetGameState(GS_PLAYING); + } + } + } + } + + if (GameState == GS_PLAYING) + { + InputsGamePlaying(x, y, pointerUp); + } + + if (GameState == GS_GAMEOVER) + { + StartGame(); + } + } + + @Override + public void SetGameState(int gameState) + { + GameState = gameState; + + switch(GameState) + { + case GS_LOAD: + { + Load(); + break; + } + case GS_START: + { + StartGame(); + break; + } + } + + canvasView.OnGameStateChanged(GameState); + } + + // Set + @Override + public void SetCanvas(CanvasView _CanvasView) + { + canvasView = _CanvasView; + } + + @Override + public void SetActivity(Activity _Activity) + { + activity = _Activity; + } + + public void SetStartLevel(int StartLevel) + { + startLevel = StartLevel; + } + + @Override + public void SetPayedVersion(boolean payedVersion) + { + PayedVersion = payedVersion; + } + + // Get + @Override + public int GetGameState() + { + return GameState; + } + + // Internal. + CanvasView canvasView; + Activity activity = null; + + // Variabelen + Resources r; + + // Sizes + float dpHeight; + float dpWidth; + + float Height; + float Width; + + // Block Array + int[][] blockArray = new int[][]{ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + }; + + // Draw Array + int[][] drawArray = new int[][]{ + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + }; + + int[][][][] drawBlocks = new int[][][][]{ + { + { + {0, 0, 0, 0}, + {8, 9, 10, 11}, + {0, 0, 0, 0}, + {0, 0, 0, 0} + }, + { + {0, 0, 12, 0}, + {0, 0, 13, 0}, + {0, 0, 14, 0}, + {0, 0, 15, 0} + }, + { + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {8, 9, 10, 11}, + {0, 0, 0, 0} + }, + { + {0, 12, 0, 0}, + {0, 13, 0, 0}, + {0, 14, 0, 0}, + {0, 15, 0, 0} + } + }, + { + { + {7, 0, 0, 0}, + {7, 7, 7, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 7, 7, 0}, + {0, 7, 0, 0}, + {0, 7, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 0, 0, 0}, + {7, 7, 7, 0}, + {0, 0, 7, 0}, + {0, 0, 0, -1} + }, + { + {0, 7, 0, 0}, + {0, 7, 0, 0}, + {7, 7, 0, 0}, + {0, 0, 0, -1} + } + }, + { + { + {0, 0, 6, 0}, + {6, 6, 6, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 6, 0, 0}, + {0, 6, 0, 0}, + {0, 6, 6, 0}, + {0, 0, 0, -1} + }, + { + {0, 0, 0, 0}, + {6, 6, 6, 0}, + {6, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {6, 6, 0, 0}, + {0, 6, 0, 0}, + {0, 6, 0, 0}, + {0, 0, 0, -1} + } + }, + { + { + {0, 1, 1, 0}, + {0, 1, 1, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 1, 1, 0}, + {0, 1, 1, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 1, 1, 0}, + {0, 1, 1, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 1, 1, 0}, + {0, 1, 1, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + } + }, + { + { + {0, 3, 3, 0}, + {3, 3, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 3, 0, 0}, + {0, 3, 3, 0}, + {0, 0, 3, 0}, + {0, 0, 0, -1} + }, + { + {0, 0, 0, 0}, + {0, 3, 3, 0}, + {3, 3, 0, 0}, + {0, 0, 0, -1} + }, + { + {3, 0, 0, 0}, + {3, 3, 0, 0}, + {0, 3, 0, 0}, + {0, 0, 0, -1} + } + }, + { + { + {0, 2, 0, 0}, + {2, 2, 2, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 2, 0, 0}, + {0, 2, 2, 0}, + {0, 2, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 0, 0, 0}, + {2, 2, 2, 0}, + {0, 2, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 2, 0, 0}, + {2, 2, 0, 0}, + {0, 2, 0, 0}, + {0, 0, 0, -1} + } + }, + { + { + {5, 5, 0, 0}, + {0, 5, 5, 0}, + {0, 0, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 0, 5, 0}, + {0, 5, 5, 0}, + {0, 5, 0, 0}, + {0, 0, 0, -1} + }, + { + {0, 0, 0, 0}, + {5, 5, 0, 0}, + {0, 5, 5, 0}, + {0, 0, 0, -1} + }, + { + {0, 5, 0, 0}, + {5, 5, 0, 0}, + {5, 0, 0, 0}, + {0, 0, 0, -1} + } + } + }; + + int[] LevelSpeed = { 53, 49, 45, 41, 37, 33, 28, 22, 17, 11, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 3}; + + // Parameters. + int GameSpaceLeft = 4; + int GameSpaceTop = 0; + int GameSpaceRight = 53; + int GameSpaceBottom = 115; + + // Tetrmino. + int CurrentBlock = 0; + int CurrentBlockPossition = 0; + + int NewBlock = 0; + int NewBlockPossition = 0; + + // Sprites. + Bitmap bitmapl1, bitmapl2, bitmapt, bitmapb, bitmaps, bitmapz, bitmapi1, bitmapi2, bitmapi3, bitmapi4, + bitmapi1r, bitmapi2r, bitmapi3r, bitmapi4r, bitmapblockline, bitmapscore, bitmapcontroller, bitmapgameover; + + Bitmap Font0, Font1, Font2, Font3, Font4, Font5, Font6, Font7, Font8, Font9; + + // Audio. + MediaPlayer mp; + + // Score. + int startLevel = 0; + int level = 0; + int lines = 0; + int score = 0; + + // Add Settings. + boolean PayedVersion; + + // Timer. + TimerTask MoveEvent = new TimerTask() { + @Override + public void run() { + GoDown(); + } + }; + + private Handler handler = new Handler(); + private Runnable runnable = new Runnable() { + @Override + public void run() { + level = ( (startLevel + lines)<=200 ? startLevel + (lines / 10) : 20 ); + int newSpeed = (int)((1000 / 59.73) * LevelSpeed[level]); + handler.postDelayed(this, newSpeed); + GoDown(); + } + }; + + + // Methods. + + // Inputs. + int OldInputTime=0; + + // Methods. + private void StartGame() + { + // Clear. + for ( int i=0; i= 0 ? blockArray[y][x] : 0)) + { + case 0: + break; + case 1: + { + 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); + break; + } + case 2: + { + 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); + break; + } + case 3: + { + 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); + break; + } + case 5: + { + 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); + break; + } + case 6: + { + 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); + break; + } + case 7: + { + 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); + break; + } + case 8: + { + 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); + break; + } + case 9: + { + 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); + break; + } + case 10: + { + 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); + break; + } + case 11: + { + 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); + break; + } + case 12: // Rotated + { + 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); + break; + } + case 13: + { + 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); + break; + } + case 14: + { + 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); + break; + } + case 15: + { + 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; + } + default: + { + + 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; + } + } + } + } + + if (GameState == GS_GAMEOVER) + { + canvas.drawBitmap(bitmapgameover, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft), + (int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null); + } + } + + private void ShowNextComingTetrimino(Canvas canvas) + { + int top = 32; + + for (int x=0; x<4; x++) + { + for (int y=0; y<4; y++) + { + switch(drawBlocks[NewBlock][NewBlockPossition][y][x]) + { + case 1: + canvas.drawBitmap(bitmapb, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 2: + canvas.drawBitmap(bitmapt, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 3: + canvas.drawBitmap(bitmapz, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 5: + canvas.drawBitmap(bitmaps, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 6: + canvas.drawBitmap(bitmapl2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 7: + canvas.drawBitmap(bitmapl1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 8: + canvas.drawBitmap(bitmapi1, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 9: + canvas.drawBitmap(bitmapi2, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 10: + canvas.drawBitmap(bitmapi3, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 11: + canvas.drawBitmap(bitmapi4, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 12: + canvas.drawBitmap(bitmapi1r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 13: + canvas.drawBitmap(bitmapi2r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 14: + canvas.drawBitmap(bitmapi3r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + case 15: + canvas.drawBitmap(bitmapi4r, (int)GetRealPixelSize(DIP_W, dpWidth, map(x, 0, 4, GameSpaceRight + 4 + 9, GameSpaceRight + 4 + 9 + (map(1, 0, 10, GameSpaceLeft, GameSpaceRight) - map(0, 0, 10, GameSpaceLeft, GameSpaceRight)) * 4)), + (int)GetRealPixelSize(DIP_H, dpHeight, map(y, 0, 4, (GameSpaceBottom - top), (GameSpaceBottom - top) + ((map(1, 0, 18, GameSpaceTop, GameSpaceBottom) - map(0, 0, 18, GameSpaceTop, GameSpaceBottom)) * 4))), null); + break; + } + } + } + } + + private void DrawScore(Canvas canvas, int Score) + { + int height = 104-8; + switch ((Score / 100000) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6-5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch ((Score / 10000) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch ((Score / 1000) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch ((Score / 100) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch ((Score / 10) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch (Score % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + } + + private void DrawLines(Canvas canvas, int Lines) + { + int height = 55-4; + switch ((Lines / 1000) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch ((Lines / 100) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch ((Lines / 10) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch (Lines % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + } + + private void DrawLevel(Canvas canvas, int Level) + { + int height = 76-6; + switch ((Level / 10) % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + switch (Level % 10) + { + case 0: + canvas.drawBitmap(Font0, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 1: + canvas.drawBitmap(Font1, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 2: + canvas.drawBitmap(Font2, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 3: + canvas.drawBitmap(Font3, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 4: + canvas.drawBitmap(Font4, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 5: + canvas.drawBitmap(Font5, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 6: + canvas.drawBitmap(Font6, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 7: + canvas.drawBitmap(Font7, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 8: + canvas.drawBitmap(Font8, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + case 9: + canvas.drawBitmap(Font9, GetRealPixelSize(DIP_W, dpWidth, GameSpaceRight+4+6+5+5+5), GetRealPixelSize(DIP_H, dpHeight, GameSpaceBottom - height), null); + break; + } + } + + // Input + public void sendMove(float x, float y, boolean Released) + { + int moveX = (int)((x / Width) * 90); + int moveY = (int)((y / Height) * 160); + + if (!Released) + { + if (GameState != GS_GAMEOVER) + { + if (moveX >= 28 && moveX <= 55 && moveY >= 143 && moveY <= 155) // Start + { + if (GameState == GS_PLAYING) + onPause(); + else + { + mp.start(); + SetGameState(GS_PLAYING); + } + } + } + } + + if (GameState == GS_PLAYING) + { + InputsGamePlaying(x, y, Released); + } + + if (GameState == GS_GAMEOVER) + { + StartGame(); + } + } + + private void InputsGamePlaying(float x, float y, boolean Released) + { + int moveX = (int)((x / Width) * 90); + int moveY = (int)((y / Height) * 160); + + if (!Released) + { + if (moveX >= 1 && moveX <= 11 && moveY >= 122 && moveY <= 133) // Left + { + if(CanBlockGoLeft()) + { + MoveBlockLeft(); + canvasView.postInvalidate(); + } + } + else if (moveX >= 55 && moveX <= 70 && moveY >= 122 && moveY <= 137) // Rotate Left + { + RotateBlockLeft(); + canvasView.postInvalidate(); + } + else if (moveX >= 74 && moveX <= 88 && moveY >= 115 && moveY <= 137) // Rotate Right + { + RotateBlockRight(); + canvasView.postInvalidate(); + } + else if (moveX >= 21 && moveX <= 33 && moveY >= 122 && moveY <= 133) // Right + { + if(CanBlockGoRight()) + { + MoveBlockRight(); + canvasView.postInvalidate(); + } + } + } + if (moveX >= 11 && moveX <= 21 && moveY >= 133 && moveY <= 144) // Down + { + if (!Released) + { + // Soft Drop + if (CanBlockGoDown()) + { + MoveBlockDown(); + canvasView.postInvalidate(); + } + OldInputTime = (int)System.currentTimeMillis(); + } + else + { + int CurrentTime = (int)System.currentTimeMillis(); + if ((CurrentTime - OldInputTime) >= 250) + { + // Hard Drop + while (CanBlockGoDown()) + { + MoveBlockDown(); + } + canvasView.postInvalidate(); + } + } + } + } + + // Game Logic + private void GoDown() + { + if (GameState == GS_PLAYING) + { + /// Can the Block go down? + if (CanBlockGoDown()) + { + MoveBlockDown(); + canvasView.postInvalidate(); + } + else + { + ParseBlockArrayToDrawArray(); + + CheckForCompletedRows(); + + //spawn new block + if (!SpawnBlock()) + { + SetGameState(GS_GAMEOVER); + + mp.stop(); + canvasView.postInvalidate(); + } + else + { + canvasView.postInvalidate(); + } + } + } + } + + private boolean CanBlockGoDown() + { + //blockArray + for (int x=0; x<10; x++) + { + for (int y=0; y<18; y++) + { + if (blockArray[y][x] != 0) + { + if (y + 1 == 18) + return false; + else if (drawArray[y+1][x] != 0) + return false; + } + } + } + + return true; + } + + private boolean CanBlockGoLeft() + { + //blockArray + for (int y=0; y<18; y++) + { + for (int x=1; x<10; x++) + { + if (blockArray[y][x] >= 1) + { + if (drawArray[y][x-1] != 0) + return false; + } + if (blockArray[y][0] >= 1) + return false; + } + } + + return true; + } + + private boolean CanBlockGoRight() + { + //blockArray + for (int y=0; y<18; y++) + { + for (int x=0; x<9; x++) + { + if (blockArray[y][x] >= 1) + { + if (drawArray[y][x+1] != 0) + return false; + } + if (blockArray[y][9] >= 1) + return false; + } + } + + return true; + } + + private void MoveBlockDown() + { + for (int x=0; x<10; x++) + { + for (int y=17; y>0; y--) + { + blockArray[y][x] = blockArray[y-1][x]; + blockArray[y-1][x] = 0; + } + } + } + + private void MoveBlockLeft() + { + for (int y=0; y<18; y++) + { + for (int x=1; x<10; x++) + { + blockArray[y][x-1] = blockArray[y][x]; + blockArray[y][x] = 0; + } + } + } + + private void MoveBlockRight() + { + for (int y=0; y<18; y++) + { + for (int x=8; x>=0; x--) + { + blockArray[y][x+1] = blockArray[y][x]; + blockArray[y][x] = 0; + } + } + } + + private void RotateBlockRight() + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][3][3] != -1) + { + for (int y=0; y<18-3; y++) + { + for (int x=0; x<10-3; x++) + { + boolean foundPossition = true; + + for (int i=0; i<4; i++) + { + for (int i2=0; i2<4; i2++) + { + if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) + { + foundPossition = false; + } + } + } + + + if (foundPossition) + { + if (CurrentBlockPossition < 3) + CurrentBlockPossition++; + else + CurrentBlockPossition = 0; + } + + // Test for collision !!! + boolean Collision = false; + + for (int i=0; i<4; i++) + { + for (int i2=0; i2<4; i2++) + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] >= 1) + { + if (drawArray[y+i][x+i2] != 0) + { + Collision = true; + } + } + } + } + + if (!Collision) + { + if (foundPossition) + { + for (int i=0; i<4; i++) + { + for (int i2=0; i2<4; i2++) + { + blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; + } + } + } + } + } + } + } + else + { + for (int y=0; y<18-2; y++) + { + for (int x=0; x<10-2; x++) + { + boolean foundPossition = true; + + for (int i=0; i<3; i++) + { + for (int i2=0; i2<3; i2++) + { + if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) + { + foundPossition = false; + } + } + } + + if (foundPossition) + { + if (CurrentBlockPossition < 3) + CurrentBlockPossition++; + else + CurrentBlockPossition = 0; + } + + // Test for collision !!! + boolean Collision = false; + + for (int i=0; i<3; i++) + { + for (int i2=0; i2<3; i2++) + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] >= 1) + { + if (drawArray[y+i][x+i2] != 0) + { + Collision = true; + } + } + } + } + + if (!Collision) + { + if (foundPossition) + { + for (int i=0; i<3; i++) + { + for (int i2=0; i2<3; i2++) + { + blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; + } + } + } + } + } + } + } + } + + private void RotateBlockLeft() + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][3][3] != -1) + { + for (int y=0; y<18-3; y++) + { + for (int x=0; x<10-3; x++) + { + boolean foundPossition = true; + + for (int i=0; i<4; i++) + { + for (int i2=0; i2<4; i2++) + { + if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) + { + foundPossition = false; + } + } + } + + // Test for collision !!! + boolean Collision = false; + + if (foundPossition) + { + if (CurrentBlockPossition > 0) + CurrentBlockPossition--; + else + CurrentBlockPossition = 3; + } + + for (int i=0; i<4; i++) + { + for (int i2=0; i2<4; i2++) + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] != 0) + { + if (drawArray[y+i][x+i2] != 0) + { + Collision = true; + } + } + } + } + + if (!Collision) + { + if (foundPossition) + { + for (int i=0; i<4; i++) + { + for (int i2=0; i2<4; i2++) + { + blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; + } + } + } + } + } + } + } + else + { + for (int y=0; y<18-2; y++) + { + for (int x=0; x<10-2; x++) + { + boolean foundPossition = true; + + for (int i=0; i<3; i++) + { + for (int i2=0; i2<3; i2++) + { + if (!(blockArray[y+i][x+i2] == drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2])) + { + foundPossition = false; + } + } + } + + // Test for collision !!! + boolean Collision = false; + + if (foundPossition) + { + if (CurrentBlockPossition > 0) + CurrentBlockPossition--; + else + CurrentBlockPossition = 3; + } + + for (int i=0; i<3; i++) + { + for (int i2=0; i2<3; i2++) + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2] != 0) + { + if (drawArray[y+i][x+i2] != 0) + { + Collision = true; + } + } + } + } + + if (!Collision) + { + if (foundPossition) + { + for (int i=0; i<3; i++) + { + for (int i2=0; i2<3; i2++) + { + blockArray[y+i][x+i2] = drawBlocks[CurrentBlock][CurrentBlockPossition][i][i2]; + } + } + } + } + } + } + } + } + + private void ParseBlockArrayToDrawArray() + { + for (int x=0; x<10; x++) + { + for (int y=0; y<18; y++) + { + drawArray[y][x] += blockArray[y][x]; + blockArray[y][x] = 0; + } + } + } + + private void CheckForCompletedRows() + { + int LinesCleared = 0; + //drawArray + for (int y=17; y>1; y--) + { + boolean isComplete = true; + + for (int x=0; x<10; x++) + { + if (drawArray[y][x] == 0) + isComplete = false; + } + + if (isComplete) + { + for (int i=y; i>1; i--) + for (int x=0; x<10; x++) + { + drawArray[i][x] = drawArray[i-1][x]; + } + LinesCleared++; + lines++; + level = ( (startLevel + lines)<=200 ? startLevel + (lines / 10) : 20 ); + y++; + } + } + // Do Score here + switch (LinesCleared) + { + case 1: + score += 40 * ( level + 1 ); + break; + case 2: + score += 100 * ( level + 1 ); + break; + case 3: + score += 300 * ( level + 1 ); + break; + case 4: + score += 1200 * ( level + 1 ); + break; + } + } + + ArrayList Tetrimino; + private void CheckTetriminoSpawnArray() + { + // Pseudo random + if (Tetrimino == null || Tetrimino.size() <= 0) + { + Tetrimino = new ArrayList(); + do{ + int newTetrimino = (int)(Math.random() * (7)); + if (!Tetrimino.contains(newTetrimino)) + Tetrimino.add(newTetrimino); + }while (Tetrimino.size() < 7); + } + } + + + private boolean SpawnBlock() + { + CheckTetriminoSpawnArray(); + + CurrentBlock = NewBlock; + CurrentBlockPossition = NewBlockPossition; + + NewBlock = Tetrimino.get(0); + Tetrimino.remove(0); + NewBlockPossition = 0; + + for (int x=0; x<4; x++) + { + for (int y=0; y<4; y++) + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][y][x] != 0) + if (drawArray[y][x+3] != 0) + return false; + } + } + + for (int x=0; x<4; x++) + { + for (int y=0; y<4; y++) + { + if (drawBlocks[CurrentBlock][CurrentBlockPossition][y][x] >= 0) + blockArray[y][x+3] = drawBlocks[CurrentBlock][CurrentBlockPossition][y][x]; + } + } + + return true; + } + + // other logic + private void Rect(Canvas canvas, float Top, float Bottom, float Left, float Right, int Color) + { + Paint paint = new Paint(); + paint.setAntiAlias(true); + paint.setColor(Color); + paint.setStyle(Style.FILL); + + canvas.drawRect( + GetRealPixelSize(DIP_W, dpWidth, Left), + GetRealPixelSize(DIP_H, dpHeight, Top), + GetRealPixelSize(DIP_W, dpWidth, Right), + GetRealPixelSize(DIP_H, dpHeight, Bottom), paint); + } + + final static int DIP_H = 0; + final static int DIP_W = 1; + + private float GetRealPixelSize(int wH, float dpWH, double DIP) + { + if (wH == DIP_H) + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)(dpWH * ( DIP / 160 )), r.getDisplayMetrics()); + else if (wH == DIP_W) + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)(dpWH * ( DIP / 90 )), r.getDisplayMetrics()); + else + return 0; + } + + float map(float x, float in_min, float in_max, float out_min, float out_max) + { + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + } + +} diff --git a/src/mangavalk/tetris/GameStateInterface.java b/src/mangavalk/tetris/GameStateInterface.java index 28c8042..1c413a6 100644 --- a/src/mangavalk/tetris/GameStateInterface.java +++ b/src/mangavalk/tetris/GameStateInterface.java @@ -1,38 +1,36 @@ -package mangavalk.tetris; - -import android.app.Activity; -import android.graphics.Canvas; - -public interface GameStateInterface -{ - // GameState Parameters - final int GS_STOPPED = 0; - final int GS_LOADING = 1; - final int GS_PLAYING = 2; - final int GS_GAMEOVER = 3; - final int GS_PAUSED = 4; - final int GS_START = 5; - final int GS_LOAD = 6; - final int GS_READY = 7; - - // Methods. - public void DrawFrame(Canvas canvas); - - public void SendMove(float x,float y, boolean pointerUp); - - public void SetGameState(int gameState); - - public void onPause(); - - // SetParameters. - public void SetActivity(Activity activity); - - public void SetCanvas(CanvasView _CanvasView); - - public void SetStartLevel(int startLevel); - - public void SetPayedVersion(boolean payedVersion); - - // Get - public int GetGameState(); -} +package mangavalk.tetris; + +import android.app.Activity; +import android.graphics.Canvas; + +public abstract class GameStateInterface +{ + // GameState Parameters + final static int GS_STOPPED = 0; + final static int GS_LOADING = 1; + final static int GS_PLAYING = 2; + final static int GS_GAMEOVER = 3; + final static int GS_PAUSED = 4; + final static int GS_START = 5; + final static int GS_LOAD = 6; + final static int GS_READY = 7; + + // Methods. + public abstract void DrawFrame(Canvas canvas); + + public abstract void SendMove(float x,float y, boolean pointerUp); + + public abstract void SetGameState(int gameState); + + public abstract void onPause(); + + // SetParameters. + public abstract void SetActivity(Activity activity); + + public abstract void SetCanvas(CanvasView _CanvasView); + + public abstract void SetPayedVersion(boolean payedVersion); + + // Get + public abstract int GetGameState(); +}