forked from naveed-ahmad/Android-Game-Pack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
baseline with jigwas puzzle game is nearly completed
- Loading branch information
Naveed Ahmad
authored and
Naveed Ahmad
committed
Aug 8, 2011
0 parents
commit 11d52e3
Showing
37 changed files
with
564 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GamePack</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Thu Aug 04 21:54:13 PKT 2011 | ||
eclipse.preferences.version=1 | ||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.nav.gamepack" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-sdk android:minSdkVersion="8" /> | ||
|
||
<application android:icon="@drawable/icon" android:label="@string/app_name"> | ||
<activity android:name=".GamePackActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
</manifest> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system use, | ||
# "build.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
* | ||
* This class was automatically generated by the | ||
* aapt tool from the resource data it found. It | ||
* should not be modified by hand. | ||
*/ | ||
|
||
package com.nav.gamepack; | ||
|
||
public final class R { | ||
public static final class attr { | ||
} | ||
public static final class drawable { | ||
public static final int icon=0x7f020000; | ||
public static final int image=0x7f020001; | ||
} | ||
public static final class id { | ||
public static final int button1=0x7f060002; | ||
public static final int button2=0x7f060005; | ||
public static final int button3=0x7f060004; | ||
public static final int button4=0x7f060003; | ||
public static final int jigsawBoard=0x7f060000; | ||
public static final int quickContactBadge1=0x7f060001; | ||
} | ||
public static final class layout { | ||
public static final int jigsawboard=0x7f030000; | ||
public static final int main=0x7f030001; | ||
} | ||
public static final class menu { | ||
public static final int main=0x7f050000; | ||
} | ||
public static final class string { | ||
public static final int app_name=0x7f040001; | ||
public static final int hello=0x7f040000; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-optimizationpasses 5 | ||
-dontusemixedcaseclassnames | ||
-dontskipnonpubliclibraryclasses | ||
-dontpreverify | ||
-verbose | ||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||
|
||
-keep public class * extends android.app.Activity | ||
-keep public class * extends android.app.Application | ||
-keep public class * extends android.app.Service | ||
-keep public class * extends android.content.BroadcastReceiver | ||
-keep public class * extends android.content.ContentProvider | ||
-keep public class * extends android.app.backup.BackupAgentHelper | ||
-keep public class * extends android.preference.Preference | ||
-keep public class com.android.vending.licensing.ILicensingService | ||
|
||
-keepclasseswithmembernames class * { | ||
native <methods>; | ||
} | ||
|
||
-keepclasseswithmembernames class * { | ||
public <init>(android.content.Context, android.util.AttributeSet); | ||
} | ||
|
||
-keepclasseswithmembernames class * { | ||
public <init>(android.content.Context, android.util.AttributeSet, int); | ||
} | ||
|
||
-keepclassmembers enum * { | ||
public static **[] values(); | ||
public static ** valueOf(java.lang.String); | ||
} | ||
|
||
-keep class * implements android.os.Parcelable { | ||
public static final android.os.Parcelable$Creator *; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="wrap_content" android:layout_height="wrap_content"> | ||
<com.nav.gamepack.puzzle.jigsaw.JigsawBoardView | ||
android:id="@+id/jigsawBoard" | ||
android:layout_width="fill_parent" android:layout_height="fill_parent"> | ||
</com.nav.gamepack.puzzle.jigsaw.JigsawBoardView> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?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" | ||
> | ||
<QuickContactBadge android:id="@+id/quickContactBadge1" android:layout_width="wrap_content" android:layout_height="wrap_content"></QuickContactBadge> | ||
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> | ||
<Button android:text="Button" android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> | ||
<Button android:text="Button" android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> | ||
<Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="hello">Hello World, GamePackActivity!</string> | ||
<string name="app_name">GamePack</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.nav.gamepack; | ||
|
||
import com.nav.gamepack.puzzle.jigsaw.JigsawBoardView; | ||
|
||
import android.app.Activity; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
|
||
public class GamePackActivity extends Activity { | ||
/** Called when the activity is first created. */ | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
JigsawBoardView board=new JigsawBoardView(this); | ||
setContentView(board); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.nav.gamepack.puzzle.jigsaw; | ||
|
||
import com.nav.gamepack.R; | ||
import android.app.Activity; | ||
import android.os.Bundle; | ||
|
||
/** | ||
* @author Naveed Ahmad | ||
* | ||
*/ | ||
|
||
public class JigsawActivity extends Activity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.jigsawboard); | ||
} | ||
} |
143 changes: 143 additions & 0 deletions
143
src/com/nav/gamepack/puzzle/jigsaw/JigsawBoardView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package com.nav.gamepack.puzzle.jigsaw; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.graphics.Paint.Style; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
/** | ||
* @author Naveed Ahmad | ||
* | ||
*/ | ||
|
||
public class JigsawBoardView extends View { | ||
private JigsawSetting setting; | ||
private Bitmap[] jigsawCellImages; | ||
private boolean isBoardInitialized; | ||
private JigsawCell[] cells; | ||
private Context context; | ||
|
||
public JigsawBoardView(Context context) { | ||
super(context); | ||
init(context); | ||
} | ||
|
||
public JigsawBoardView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(context); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
private void init(Context context) { | ||
this.context = context; | ||
isBoardInitialized = false; | ||
setting = new JigsawSetting(context, getWidth(),getWidth()); | ||
|
||
} | ||
|
||
public JigsawBoardView(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
init(context); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
/* | ||
* | ||
*/ | ||
private void prepareJigsawBoardImage() { | ||
Bitmap jigsawImage = setting.getJigwasImage(); | ||
setting.prepareJigwasCellDimension(); | ||
int width = setting.getJigsawCellWidth(); | ||
int height = setting.getJigsawCellHeight(); | ||
int rows = setting.getBoardRowCount(); | ||
int columns = setting.getBoardColumnCount(); | ||
int imageStartX = 0, imageStartY = 0; | ||
int currentCell = 0; | ||
for (int column = 0; column < columns; column++) { | ||
for (int row = 0; row < rows; row++) { | ||
jigsawCellImages[currentCell] = Bitmap.createBitmap( | ||
jigsawImage, imageStartX, imageStartY, width, height); | ||
cells[currentCell] = new JigsawCell(context); | ||
cells[currentCell].layout(imageStartX, imageStartY, imageStartX | ||
+ width, imageStartY + height); | ||
imageStartX += width; | ||
currentCell++; | ||
} | ||
imageStartX = 0; | ||
imageStartY += height; | ||
} | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see android.view.View#onDraw(android.graphics.Canvas) | ||
*/ | ||
protected void onDraw(Canvas canvas) { | ||
super.onDraw(canvas); | ||
if (!isBoardInitialized) | ||
initGame(false); | ||
|
||
Paint p1 = new Paint(); | ||
p1.setStyle(Style.STROKE); | ||
p1.setColor(Color.RED); | ||
//Bitmap img; | ||
//img = setting.getJigwasImage(); | ||
|
||
//if (img != null) | ||
//canvas.drawBitmap(img, 0, 0, p1); | ||
//else | ||
canvas.drawRect(10, 10, getRight() - 10, getBottom() - 10, p1); | ||
int i=0; | ||
//for (int i = 0; i < cells.length - 2; i++) | ||
//canvas.drawRect(cells[i].getLeft(), cells[i].getTop(), cells[i] | ||
// .getRight(), cells[i].getBottom(), p1); | ||
//if(i%5==1) | ||
// canvas.drawBitmap(jigsawCellImages[i], cells[i].getLeft(), cells[i].getTop(), p1); | ||
i=5; | ||
canvas.drawBitmap(jigsawCellImages[i], cells[i].getLeft(), cells[i].getTop(), p1); | ||
// i=2; | ||
//canvas.drawBitmap(jigsawCellImages[i], cells[i].getLeft(), cells[i].getTop(), p1); | ||
//i=3; | ||
// canvas.drawBitmap(jigsawCellImages[i], cells[i].getLeft(), cells[i].getTop(), p1); | ||
|
||
} | ||
|
||
/* | ||
* initialize game..crop jigsaw image.prepar cells.and draw cells | ||
*/ | ||
public void initGame(boolean shuffleCells) { | ||
if (isBoardInitialized) | ||
return;// Board is already initialized | ||
int cellCount = setting.getBoardColumnCount() | ||
* setting.getBoardRowCount() + 1; | ||
cells = new JigsawCell[cellCount]; | ||
jigsawCellImages = new Bitmap[cellCount]; | ||
prepareJigsawBoardImage(); | ||
if (shuffleCells) | ||
shuffleCells(); | ||
isBoardInitialized = true; | ||
// drawBoard(); | ||
} | ||
|
||
/* | ||
* Shuffle cells of jigsaw board | ||
*/ | ||
public void shuffleCells(int shuffleCount) { | ||
// TODO: Implementation pending | ||
|
||
} | ||
|
||
public void shuffleCells() { | ||
shuffleCells(setting.getShuffleCount()); | ||
} | ||
|
||
public boolean isGameOver() { | ||
return false; | ||
} | ||
|
||
} |
Oops, something went wrong.