public static final int redstar=0x7f020002;
public static final int yellowstar=0x7f020003;
}
+ public static final class id {
+ public static final int level_display=0x7f050001;
+ public static final int score_display=0x7f050000;
+ }
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
+ public static final int level=0x7f040001;
+ public static final int score=0x7f040000;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- >
+ android:orientation="vertical">
+ <TextView android:id="@+id/score_display"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textSize="20dip"
+ android:typeface="monospace"
+ android:text="@string/score" >
+ </TextView>
+ <TextView android:id="@+id/level_display"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textSize="20dip"
+ android:typeface="monospace"
+ android:text="@string/level" >
+ </TextView>
+
</LinearLayout>
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;
//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);
}
return false;
}
-}
\ No newline at end of file
+}