public class gameView extends View {
private int m_x;
private int m_y;
private String m_strAction = "None";
Bitmap _android;
Bitmap _finish;
Bitmap _backside;
Bitmap _hart1;
Bitmap _hart2;
Bitmap _hart3;
Bitmap _hart4;
Bitmap _hart5;
Bitmap _hart6;
Bitmap _hart7;
Bitmap _hart8;
Bitmap _hart9;
Bitmap _hart10;
Bitmap _clover1;
Bitmap _clover2;
Bitmap _clover3;
Bitmap _clover4;
Bitmap _clover5;
Bitmap _clover6;
Bitmap _clover7;
Bitmap _clover8;
Bitmap _clover9;
Bitmap _clover10;
Bitmap _dia1;
Bitmap _dia2;
Bitmap _dia3;
Bitmap _dia4;
Bitmap _dia5;
Bitmap _dia6;
Bitmap _dia7;
Bitmap _dia8;
Bitmap _dia9;
Bitmap _dia10;
Bitmap _spade1;
Bitmap _spade2;
Bitmap _spade3;
Bitmap _spade4;
Bitmap _spade5;
Bitmap _spade6;
Bitmap _spade7;
Bitmap _spade8;
Bitmap _spade9;
Bitmap _spade10;
public gameView(Context context) {
super(context);
_backside = BitmapFactory.decodeResource(getResources(), R.drawable.backside);
_finish = BitmapFactory.decodeResource(getResources(), R.drawable.finish);
_android = BitmapFactory.decodeResource(getResources(), R.drawable.android);
_hart1 = BitmapFactory.decodeResource(getResources(), R.drawable.hart1);
_hart2 = BitmapFactory.decodeResource(getResources(), R.drawable.hart2);
_hart3 = BitmapFactory.decodeResource(getResources(), R.drawable.hart3);
_hart4 = BitmapFactory.decodeResource(getResources(), R.drawable.hart4);
_hart5 = BitmapFactory.decodeResource(getResources(), R.drawable.hart5);
_hart6 = BitmapFactory.decodeResource(getResources(), R.drawable.hart6);
_hart7 = BitmapFactory.decodeResource(getResources(), R.drawable.hart7);
_hart8 = BitmapFactory.decodeResource(getResources(), R.drawable.hart8);
_hart9 = BitmapFactory.decodeResource(getResources(), R.drawable.hart9);
_hart10 = BitmapFactory.decodeResource(getResources(), R.drawable.hart10);
_clover1 = BitmapFactory.decodeResource(getResources(), R.drawable.clover1);
_clover2 = BitmapFactory.decodeResource(getResources(), R.drawable.clover2);
_clover3 = BitmapFactory.decodeResource(getResources(), R.drawable.clover3);
_clover4 = BitmapFactory.decodeResource(getResources(), R.drawable.clover4);
_clover5 = BitmapFactory.decodeResource(getResources(), R.drawable.clover5);
_clover6 = BitmapFactory.decodeResource(getResources(), R.drawable.clover6);
_clover7 = BitmapFactory.decodeResource(getResources(), R.drawable.clover7);
_clover8 = BitmapFactory.decodeResource(getResources(), R.drawable.clover8);
_clover9 = BitmapFactory.decodeResource(getResources(), R.drawable.clover9);
_clover10 = BitmapFactory.decodeResource(getResources(), R.drawable.clover10);
_dia1 = BitmapFactory.decodeResource(getResources(), R.drawable.dia1);
_dia2 = BitmapFactory.decodeResource(getResources(), R.drawable.dia2);
_dia3 = BitmapFactory.decodeResource(getResources(), R.drawable.dia3);
_dia4 = BitmapFactory.decodeResource(getResources(), R.drawable.dia4);
_dia5 = BitmapFactory.decodeResource(getResources(), R.drawable.dia5);
_dia6 = BitmapFactory.decodeResource(getResources(), R.drawable.dia6);
_dia7 = BitmapFactory.decodeResource(getResources(), R.drawable.dia7);
_dia8 = BitmapFactory.decodeResource(getResources(), R.drawable.dia8);
_dia9 = BitmapFactory.decodeResource(getResources(), R.drawable.dia9);
_dia10 = BitmapFactory.decodeResource(getResources(), R.drawable.dia10);
_spade1 = BitmapFactory.decodeResource(getResources(), R.drawable.spade1);
_spade2 = BitmapFactory.decodeResource(getResources(), R.drawable.spade2);
_spade3 = BitmapFactory.decodeResource(getResources(), R.drawable.spade3);
_spade4 = BitmapFactory.decodeResource(getResources(), R.drawable.spade4);
_spade5 = BitmapFactory.decodeResource(getResources(), R.drawable.spade5);
_spade6 = BitmapFactory.decodeResource(getResources(), R.drawable.spade6);
_spade7 = BitmapFactory.decodeResource(getResources(), R.drawable.spade7);
_spade8 = BitmapFactory.decodeResource(getResources(), R.drawable.spade8);
_spade9 = BitmapFactory.decodeResource(getResources(), R.drawable.spade9);
_spade10 = BitmapFactory.decodeResource(getResources(), R.drawable.spade10);
}
@Override
public void onDraw(Canvas canvas){
//canvas.drawBitmap(_backside, 0, 0, null);
canvas.drawBitmap(_android, m_x, m_y, null);
canvas.drawBitmap(_finish,540,130,null);
Paint p = new Paint();
p.setTextSize(30);
p.setColor(Color.BLACK);
canvas.drawText("미션 : 카드를 순차적으로 정리하라", 0, 40, p);
{for(int y = 1; y < 4; y++)
for(int x = 0; x < 5; x++)
canvas.drawBitmap(_backside, x* 160, 280 + y * 210, null);
}
}
@Override
public boolean onTouchEvent(MotionEvent event){
m_x = (int) event.getX();
m_y = (int) event.getY();
if(event.getAction() == MotionEvent.ACTION_DOWN){
m_strAction = "ACTION_DOWN";
}
if(event.getAction() == MotionEvent.ACTION_MOVE){
m_strAction = "ACTION_MOVE";
}
if(event.getAction() == MotionEvent.ACTION_UP){
m_strAction = "ACTION_UP";
m_x = 0;
m_y = 0;
}
invalidate();
return true;
}
}
package com.example.dk_bg_401_000.cardgame;
/**
* Created by DK_BG_401-000 on 2015-04-13.
*/
public class card {
public static final int IMG_clover1 = 1;
public static final int IMG_clover2 = 2;
public static final int IMG_clover3 = 3;
public static final int IMG_clover4 = 4;
public static final int IMG_clover5 = 5;
public static final int IMG_clover6 = 6;
public static final int IMG_clover7 = 7;
public static final int IMG_clover8 = 8;
public static final int IMG_clover9 = 9;
public static final int IMG_clover10 = 10;
public static final int IMG_dia1 = 11;
public static final int IMG_dia2 = 12;
public static final int IMG_dia3 = 13;
public static final int IMG_dia4 = 14;
public static final int IMG_dia5 = 15;
public static final int IMG_dia6 = 16;
public static final int IMG_dia7 = 17;
public static final int IMG_dia8 = 18;
public static final int IMG_dia9 = 19;
public static final int IMG_dia10 = 20;
public static final int IMG_hart1 = 21;
public static final int IMG_hart2 = 22;
public static final int IMG_hart3 = 23;
public static final int IMG_hart4 = 24;
public static final int IMG_hart5 = 25;
public static final int IMG_hart6 = 26;
public static final int IMG_hart7 = 27;
public static final int IMG_hart8 = 28;
public static final int IMG_hart9 = 29;
public static final int IMG_hart10 = 30;
public static final int IMG_spade1 = 31;
public static final int IMG_spade2 = 32;
public static final int IMG_spade3 = 33;
public static final int IMG_spade4 = 34;
public static final int IMG_spade5 = 35;
public static final int IMG_spade6 = 36;
public static final int IMG_spade7 = 37;
public static final int IMG_spade8 = 38;
public static final int IMG_spade9 = 39;
public static final int IMG_spade10 = 40;
public int _Color;
public int _state;
}
카드게임을 만들려구합니다.
제가 설정해둔 카드들을 화면에 랜덤으로 배치하려고합니다.
어떻게 하면 될까요...감이 안잡히네요 소스좀 만들어 주실수 있나요