Skip to content

Commit

Permalink
add todo list file and update jigsawBoardView to show images.shuffle …
Browse files Browse the repository at this point in the history
…them and more
  • Loading branch information
Naveed Ahmad authored and Naveed Ahmad committed Aug 9, 2011
1 parent cb245c5 commit 2279475
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 19 deletions.
Binary file added .todo.text.swp
Binary file not shown.
Binary file modified bin/GamePack.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file modified bin/com/nav/gamepack/puzzle/jigsaw/JigsawBoardView$1.class
Binary file not shown.
Binary file modified bin/com/nav/gamepack/puzzle/jigsaw/JigsawBoardView.class
Binary file not shown.
Binary file modified bin/com/nav/gamepack/puzzle/jigsaw/JigsawCell.class
Binary file not shown.
33 changes: 18 additions & 15 deletions src/com/nav/gamepack/puzzle/jigsaw/JigsawBoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void init(final Context context) {
@Override
public void onClick(View v) {
new AlertDialog.Builder(context).setMessage(
((JigsawCell) v).getCellCurrentPosition() + "").show();
((JigsawCell) v).getCurrentPosition() + "").show();
}
};

Expand Down Expand Up @@ -78,7 +78,7 @@ private void prepareJigsawBoardImage() {
cells[currentCell] = new JigsawCell(context);
cells[currentCell].layout(imageStartX, imageStartY, imageStartX
+ width, imageStartY + height);
cells[currentCell].setCellImageIndex(currentCell);
cells[currentCell].setJigsawImageIndex(currentCell);
cells[currentCell].setClickable(true);
cells[currentCell].setOnClickListener(jigsawCellClickListener);
// cells[currentCell].onTouchEvent(jigsawCellTouchListener);
Expand All @@ -91,7 +91,7 @@ private void prepareJigsawBoardImage() {
cells[currentCell] = new JigsawCell(context);
cells[currentCell].layout((columns - 1) * width, imageStartY, columns
* width, imageStartY + height);
cells[currentCell].setCellImageIndex(currentCell);
cells[currentCell].setJigsawImageIndex(currentCell);

// new
// AlertDialog.Builder(context).setMessage("w="+height+"\nh="+width+"\nrows"+rows).setNegativeButton("cancle",
Expand All @@ -107,7 +107,7 @@ private void prepareJigsawBoardImage() {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (!isBoardInitialized)
initBoard(false);
initBoard(true);

Paint p1 = new Paint();
p1.setStyle(Style.STROKE);
Expand All @@ -120,10 +120,10 @@ protected void onDraw(Canvas canvas) {
// else
// canvas.drawRect(10, 10, getRight() - 10, getBottom() - 10, p1);
// int i=0;
for (int i = 0; i < cells.length; i++) {
for (int i = 0; i < cells.length-1; i++) {

// canvas.drawBitmap(jigsawCellImages[i], cells[i].getLeft(),
// cells[i].getTop(), p1);
canvas.drawBitmap(jigsawCellImages[cells[i].getJigsawImageIndex()], cells[i].getLeft(),
cells[i].getTop(), p1);
canvas.drawRect(cells[i].getLeft(), cells[i].getTop(), cells[i]
.getRight(), cells[i].getBottom(), p1);

Expand Down Expand Up @@ -172,11 +172,11 @@ public void initBoard(boolean shuffleCells) {
public void shuffleCells(int shuffleCount) {
Random r = new Random();
for (int i = 0; i < shuffleCount; i++) {
int num1 = r.nextInt(cells.length);
int num2 = r.nextInt(cells.length);
JigsawCell c = cells[num1];
cells[num1] = cells[num2];
cells[num2] = c;
int num1 = r.nextInt(cells.length-2);
int num2 = r.nextInt(cells.length-2);
int tempImageIndex=cells[num1].getJigsawImageIndex();
cells[num1].setJigsawImageIndex(cells[num2].getJigsawImageIndex());
cells[num2].setJigsawImageIndex(tempImageIndex);
}
}

Expand All @@ -199,9 +199,12 @@ private int findClickedCellIndex(final float x, final float y) {
public boolean onTouchEvent(MotionEvent event) {
int cellIndex=findClickedCellIndex(event.getX(), event.getY());
if (cellIndex>0)
new AlertDialog.Builder(context).setMessage(
cells[cellIndex].getLeft() + " R "+cells[cellIndex].getRight()+" T: "+cells[cellIndex].getTop()+" D "+cells[cellIndex].getBottom()).show();
else
//new AlertDialog.Builder(context).setMessage(
// cells[cellIndex].getLeft() + " R "+cells[cellIndex].getRight()+" T: "+cells[cellIndex].getTop()+" D "+cells[cellIndex].getBottom()).show();
new AlertDialog.Builder(context).setMessage(
cells[cellIndex].getJigsawImageIndex() + " P "+cells[cellIndex].getCurrentPosition()).show();

else
new AlertDialog.Builder(context).setMessage("zero").show();

return true;
Expand Down
8 changes: 4 additions & 4 deletions src/com/nav/gamepack/puzzle/jigsaw/JigsawCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public JigsawCell(Context context) {
/**
* @param cellImageIndex the cellImageIndex to set
*/
public void setCellImageIndex(int cellImageIndex) {
this.cellImageIndex = cellImageIndex;
public void setJigsawImageIndex(int jigsawImageIndex) {
this.cellImageIndex = jigsawImageIndex;
}

/**
* @return the cellImageIndex
*/
public int getCellImageIndex() {
public int getJigsawImageIndex() {
return cellImageIndex;
}

Expand All @@ -60,7 +60,7 @@ public void setCellCurrentPosition(int cellCurrentPosition) {
/**
* @return the cellCurrentPosition
*/
public int getCellCurrentPosition() {
public int getCurrentPosition() {
return cellCurrentPosition;
}

Expand Down
7 changes: 7 additions & 0 deletions todo.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
voice reconginzation for movement instruction]
git pic from cam
search pic from mem/sdcard
image selector
save game in db
ColorPicker

0 comments on commit 2279475

Please sign in to comment.