From 11df54a6430a825737006e423b725e34b1932818 Mon Sep 17 00:00:00 2001 From: gumartinm Date: Tue, 24 Apr 2012 09:10:27 +0200 Subject: [PATCH] Working on my AndroidTetris. Messing around with the views. --- Android/AndroidTetris/AndroidManifest.xml | 1 + .../gen/de/android/androidtetris/BuildConfig.java | 6 ++++++ .../AndroidTetris/gen/de/android/androidtetris/R.java | 8 ++++++-- Android/AndroidTetris/res/layout/main.xml | 18 ++++++++++++++++-- Android/AndroidTetris/res/values/strings.xml | 4 ++-- .../android/androidtetris/AndroidTetrisActivity.java | 2 ++ .../src/de/android/androidtetris/DrawView.java | 14 +++++++------- 7 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 Android/AndroidTetris/gen/de/android/androidtetris/BuildConfig.java diff --git a/Android/AndroidTetris/AndroidManifest.xml b/Android/AndroidTetris/AndroidManifest.xml index 046dc01..80d109a 100644 --- a/Android/AndroidTetris/AndroidManifest.xml +++ b/Android/AndroidTetris/AndroidManifest.xml @@ -4,6 +4,7 @@ android:versionCode="1" android:versionName="1.0"> + + android:orientation="vertical"> + + + + + diff --git a/Android/AndroidTetris/res/values/strings.xml b/Android/AndroidTetris/res/values/strings.xml index 8c45b4c..ab72029 100644 --- a/Android/AndroidTetris/res/values/strings.xml +++ b/Android/AndroidTetris/res/values/strings.xml @@ -1,5 +1,5 @@ - Hello World, AndroidTetrisActivity! - AndroidTetris + Score: + Level: diff --git a/Android/AndroidTetris/src/de/android/androidtetris/AndroidTetrisActivity.java b/Android/AndroidTetris/src/de/android/androidtetris/AndroidTetrisActivity.java index 82b604f..283a20a 100644 --- a/Android/AndroidTetris/src/de/android/androidtetris/AndroidTetrisActivity.java +++ b/Android/AndroidTetris/src/de/android/androidtetris/AndroidTetrisActivity.java @@ -1,8 +1,10 @@ package de.android.androidtetris; import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.util.DisplayMetrics; +import android.view.inputmethod.InputMethodManager; public class AndroidTetrisActivity extends Activity { DrawView drawView; diff --git a/Android/AndroidTetris/src/de/android/androidtetris/DrawView.java b/Android/AndroidTetris/src/de/android/androidtetris/DrawView.java index 1a2e892..4277223 100644 --- a/Android/AndroidTetris/src/de/android/androidtetris/DrawView.java +++ b/Android/AndroidTetris/src/de/android/androidtetris/DrawView.java @@ -22,7 +22,7 @@ import android.view.SurfaceView; public class DrawView extends SurfaceView { private SurfaceHolder holder; private final MainLoop mainLoop; - private static final int TILESIZE=16; + private static final int TILESIZE=32; private static final int MAPWIDTH=10; private static final int MAPHEIGHT=20; private static final int GREY=8; @@ -168,30 +168,30 @@ public class DrawView extends SurfaceView { //canvas.getWidth() <----------------- retrieve the screen width //canvas.getWidth()/TILESIZE <-------- the tile size is 16, so we have to count on it when finding the center //((canvas.getWidth()/TILESIZE))/2 <-- this is the middle of our screen, it depends on the tile size. - final int initX = (((canvas.getWidth()/TILESIZE)/2) - MAPWIDTH); + final int initX = ((((canvas.getWidth()/TILESIZE)/2) - MAPWIDTH) + 1); //draw the left bar (with scores, and next pieces for(int x=MAPWIDTH; x< MAPWIDTH + GREY; x++) for(int y=0; y< MAPHEIGHT; y++) - drawTile(canvas, Tile.GRAY.getColor(), x + initX, y); + drawTile(canvas, Tile.GRAY.getColor(), x + initX, y + 10); //draw the pre-piece for(int x=0; x < PrePiece.WIDTH; x++) for(int y=0; y< PrePiece.HEIGHT; y++) if(prePiece.size[x][y] != Tile.NOCOLOR) - drawTile(canvas, prePiece.size[x][y].getColor(), prePiece.x + x + initX, prePiece.y +y); + drawTile(canvas, prePiece.size[x][y].getColor(), prePiece.x + x + initX, prePiece.y + y + 10); //draw grid for(int x=0; x < MAPWIDTH; x++) for(int y=0; y < MAPHEIGHT; y++) - drawTile(canvas, mapMatrix[x][y].getColor(), x + initX, y); + drawTile(canvas, mapMatrix[x][y].getColor(), x + initX, y+10); //draw the current block for(int x=0; x < CurrentPiece.WIDTH; x++) for(int y=0; y < CurrentPiece.HEIGHT; y++) if(currentPiece.size[x][y] != Tile.NOCOLOR) - drawTile(canvas, currentPiece.size[x][y].getColor(), currentPiece.x + x + initX, currentPiece.y +y); + drawTile(canvas, currentPiece.size[x][y].getColor(), currentPiece.x + x + initX, currentPiece.y +y +10); } @@ -371,4 +371,4 @@ public class DrawView extends SurfaceView { return false; } -} \ No newline at end of file +} -- 2.1.4