Sudoku Game Source Code Android Project

Sudoku Game Source Code Android Project

Sudoku Game Source Code Android Project

Hi Friends.The tittle of this post is Sudoku Game Source Code Android Project. Here are free android project . The Sudoku Game Source Code Android Project is easy to use and easy to develop. Developer can download this free Sudoku Game Source Code Android Project for our collage purpose and other project.

android_header_abanner_news

Here I am come with new Android Project (Sudoku Game Source Code Android Project) For Android Lover and Android user. This game is most popular in game market. And most number of the user play this game. It’s a puzzle game. Its too interesting game. This game (Sudoku Game Source Code Android Project) use to be available only for systems. But now days in mobile market increasing day by day. the developers developing this game for mobile. We know in mobile market has many operating system available like,” Android, Window and bada. But today’s trend is android  operating system.

Sudoku Game Source Code Android Project is a top class game project … thanx to download here …

 

Sudoku Game Source Code Android Project

Sudoku Game Source Code Android Project

 

 

Sudoku Game Source Code Android Project Copy Source Code :-

ublic class Tictactoelib extends VIEW {

public static final long FPS_MS = 1000/2;

public enum State {
UNKNOWN(-3),
WIN(-2),
EMPTY(0),
PLAYER1(1),
PLAYER2(2);

private INT mValue;

private State(INT VALUE) {
mValue = VALUE;
}

public INT getValue() {
RETURN mValue;
}

public static State fromInt(INT i) {
FOR (State s : VALUES()) {
IF (s.getValue() == i) {
RETURN s;
}
}
RETURN EMPTY;
}
}

private static final INT MARGIN = 4;
private static final INT MSG_BLINK = 1;

private final Handler mHandler = NEW Handler(NEW MyHandler());

private final Rect mSrcRect = NEW Rect();
private final Rect mDstRect = NEW Rect();

private INT mSxy;
private INT mOffetX;
private INT mOffetY;
private Paint mWinPaint;
private Paint mLinePaint;
private Paint mBmpPaint;
private Bitmap mBmpPlayer1;
private Bitmap mBmpPlayer2;
private Drawable mDrawableBg;

private ICellListener mCellListener;

/** Contains one of {@link State#EMPTY}, {@link State#PLAYER1} or {@link State#PLAYER2}. */
private final State[] mData = NEW State[9];

private INT mSelectedCell = -1;
private State mSelectedValue = State.EMPTY;
private State mCurrentPlayer = State.UNKNOWN;
private State mWinner = State.EMPTY;

private INT mWinCol = -1;
private INT mWinRow = -1;
private INT mWinDiag = -1;

private BOOLEAN mBlinkDisplayOff;
private final Rect mBlinkRect = NEW Rect();

 

public interface ICellListener {
abstract void onCellSelected();
}

public Tictactoelib(Context context, AttributeSet attrs) {
super(context, attrs);
requestFocus();

mDrawableBg = getResources().getDrawable(R.drawable.icon);
setBackgroundDrawable(mDrawableBg);

mBmpPlayer1 = getResBitmap(R.drawable.icon);
mBmpPlayer2 = getResBitmap(R.drawable.icon);

IF (mBmpPlayer1 != NULL) {
mSrcRect.SET(0, 0, mBmpPlayer1.getWidth() -1, mBmpPlayer1.getHeight() – 1);
}

mBmpPaint = NEW Paint(Paint.ANTI_ALIAS_FLAG);

mLinePaint = NEW Paint();
mLinePaint.setColor(0xFFFFFFFF);
mLinePaint.setStrokeWidth(5);
mLinePaint.setStyle(STYLE.STROKE);

mWinPaint = NEW Paint(Paint.ANTI_ALIAS_FLAG);
mWinPaint.setColor(0xFFFF0000);
mWinPaint.setStrokeWidth(10);
mWinPaint.setStyle(STYLE.STROKE);

FOR (INT i = 0; i < mData.LENGTH; i++) {
mData[i] = State.EMPTY;
}

IF (isInEditMode()) {
// IN edit mode (e.g. IN the Eclipse ADT graphical layout editor)
// we’ll use some random data to display the state.
Random rnd = new Random();
for (int i = 0; i < mData.length; i++) {
mData[i] = State.fromInt(rnd.nextInt(3));
}
}
}

public State[] getData() {
return mData;
}

public void setCell(int cellIndex, State value) {
mData[cellIndex] = value;
invalidate();
}

public void setCellListener(ICellListener cellListener) {
mCellListener = cellListener;
}

public int getSelection() {
if (mSelectedValue == mCurrentPlayer) {
return mSelectedCell;
}

return -1;
}

public State getCurrentPlayer() {
return mCurrentPlayer;
}

public void setCurrentPlayer(State player) {
mCurrentPlayer = player;
mSelectedCell = -1;
}

public State getWinner() {
return mWinner;
}

public void setWinner(State winner) {
mWinner = winner;
}

/** Sets winning mark on specified column or row (0..2) or diagonal (0..1). */
public void setFinished(int col, int row, int diagonal) {
mWinCol = col;
mWinRow = row;
mWinDiag = diagonal;
}

//—————————————–
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

int sxy = mSxy;
int s3 = sxy * 3;
int x7 = mOffetX;
int y7 = mOffetY;

for (int i = 0, k = sxy; i < 2; i++, k += sxy) {
canvas.drawLine(x7 , y7 + k, x7 + s3 – 1, y7 + k , mLinePaint);
canvas.drawLine(x7 + k, y7 , x7 + k , y7 + s3 – 1, mLinePaint);
}

for (int j = 0, k = 0, y = y7; j < 3; j++, y += sxy) {
for (int i = 0, x = x7; i < 3; i++, k++, x += sxy) {
mDstRect.offsetTo(MARGIN+x, MARGIN+y);

State v;
if (mSelectedCell == k) {
if (mBlinkDisplayOff) {
continue;
}
v = mSelectedValue;
} else {
v = mData[k];
}

switch(v) {
case PLAYER1:
if (mBmpPlayer1 != null) {
canvas.drawBitmap(mBmpPlayer1, mSrcRect, mDstRect, mBmpPaint);
}
break;
case PLAYER2:
if (mBmpPlayer2 != null) {
canvas.drawBitmap(mBmpPlayer2, mSrcRect, mDstRect, mBmpPaint);
}
break;
}
}
}

if (mWinRow >= 0) {
int y = y7 + mWinRow * sxy + sxy / 2;
canvas.drawLine(x7 + MARGIN, y, x7 + s3 – 1 – MARGIN, y, mWinPaint);

} else if (mWinCol >= 0) {
int x = x7 + mWinCol * sxy + sxy / 2;
canvas.drawLine(x, y7 + MARGIN, x, y7 + s3 – 1 – MARGIN, mWinPaint);

} else if (mWinDiag == 0) {
// diagonal 0 is from (0,0) to (2,2)

canvas.drawLine(x7 + MARGIN, y7 + MARGIN,
x7 + s3 – 1 – MARGIN, y7 + s3 – 1 – MARGIN, mWinPaint);

} else if (mWinDiag == 1) {
// diagonal 1 is from (0,2) to (2,0)

canvas.drawLine(x7 + MARGIN, y7 + s3 – 1 – MARGIN,
x7 + s3 – 1 – MARGIN, y7 + MARGIN, mWinPaint);
}
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Keep the view squared
int w = MeasureSpec.getSize(widthMeasureSpec);
int h = MeasureSpec.getSize(heightMeasureSpec);
int d = w == 0 ? h : h == 0 ? w : w < h ? w : h;
setMeasuredDimension(d, d);
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);

int sx = (w – 2 * MARGIN) / 3;
int sy = (h – 2 * MARGIN) / 3;

int size = sx < sy ? sx : sy;

mSxy = size;
mOffetX = (w – 3 * size) / 2;
mOffetY = (h – 3 * size) / 2;

mDstRect.set(MARGIN, MARGIN, size – MARGIN, size – MARGIN);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();

if (action == MotionEvent.ACTION_DOWN) {
return true;

} else if (action == MotionEvent.ACTION_UP) {
int x = (int) event.getX();
int y = (int) event.getY();

int sxy = mSxy;
x = (x – MARGIN) / sxy;
y = (y – MARGIN) / sxy;

if (isEnabled() && x >= 0 && x < 3 && y >= 0 & y < 3) {
int cell = x + 3 * y;

State state = cell == mSelectedCell ? mSelectedValue : mData[cell];
state = state == State.EMPTY ? mCurrentPlayer : State.EMPTY;

stopBlink();

mSelectedCell = cell;
mSelectedValue = state;
mBlinkDisplayOff = false;
mBlinkRect.set(MARGIN + x * sxy, MARGIN + y * sxy,
MARGIN + (x + 1) * sxy, MARGIN + (y + 1) * sxy);

if (state != State.EMPTY) {
// Start the blinker
mHandler.sendEmptyMessageDelayed(MSG_BLINK, FPS_MS);
}

if (mCellListener != null) {
mCellListener.onCellSelected();
}
}

return true;
}

return false;
}

 

 

android software download

android software download

 

Related posts:

The following two tabs change content below.

Deepak Sudera

Founder of Techfameplus.com at Techfameplus
Hey, thanks for reading my reflection. This is Deep...Founder of Techfameplus.com. I am a Web Designer & Developer... My Personal Interest areas are Playing games,Internet.... My Skills are Photoshop, HTML, CSS, HTML5, CSS3, Website Design, Template Creation...Connect back him regarding on Facebook, Add him on Google+ and Follow him on Twitter.

About Author

Deepak Sudera

Hey, thanks for reading my reflection. This is Deep...Founder of Techfameplus.com. I am a Web Designer & Developer... My Personal Interest areas are Playing games,Internet.... My Skills are Photoshop, HTML, CSS, HTML5, CSS3, Website Design, Template Creation...Connect back him regarding on Facebook, Add him on Google+ and Follow him on Twitter.

Write a Comment

Your e-mail address will not be published.
Required fields are marked*