Commits

shoda  committed 9684931

first commit

  • Participants

Comments (0)

Files changed (40)

+<?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="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>
+bin/*
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>Antivirus</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>

File AndroidManifest.xml

+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.antivirus"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="16" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name="com.example.antivirus.MainActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity android:name="GameActivity"/>
+        <activity android:name="PracticeActivity"/>
+    </application>
+
+</manifest>

File gen/com/example/antivirus/BuildConfig.java

+/** Automatically generated file. DO NOT MODIFY */
+package com.example.antivirus;
+
+public final class BuildConfig {
+    public final static boolean DEBUG = true;
+}

File gen/com/example/antivirus/R.java

+/* 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.example.antivirus;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int ic_launcher=0x7f020000;
+        public static final int jb_4=0x7f020001;
+        public static final int jb_5=0x7f020002;
+        public static final int jb_6=0x7f020003;
+        public static final int jb_7=0x7f020004;
+        public static final int jb_8=0x7f020005;
+        public static final int majikichi11=0x7f020006;
+        public static final int majikichi21=0x7f020007;
+        public static final int majikichi31=0x7f020008;
+        public static final int majikichi41=0x7f020009;
+        public static final int majikichi51=0x7f02000a;
+        public static final int majikichi61=0x7f02000b;
+        public static final int majikichi71=0x7f02000c;
+        public static final int test2=0x7f02000d;
+    }
+    public static final class id {
+        public static final int menu_settings=0x7f070000;
+    }
+    public static final class layout {
+        public static final int activity_main=0x7f030000;
+    }
+    public static final class menu {
+        public static final int activity_main=0x7f060000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f040000;
+        public static final int hello_world=0x7f040001;
+        public static final int menu_settings=0x7f040002;
+    }
+    public static final class style {
+        /** 
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    
+
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        
+
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    
+ API 11 theme customizations can go here. 
+
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    
+ API 14 theme customizations can go here. 
+         */
+        public static final int AppBaseTheme=0x7f050000;
+        /**  Application theme. 
+ All customizations that are NOT specific to a particular API-level can go here. 
+         */
+        public static final int AppTheme=0x7f050001;
+    }
+}

File ic_launcher-web.png

Added
New image

File libs/android-support-v4.jar

Binary file added.

File proguard-project.txt

+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

File project.properties

+# 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 edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-17

File res/drawable-hdpi/ic_launcher.png

Added
New image

File res/drawable-ldpi/ic_launcher.png

Added
New image

File res/drawable-mdpi/ic_launcher.png

Added
New image

File res/drawable-nodpi/jb_4.png

Added
New image

File res/drawable-nodpi/jb_5.png

Added
New image

File res/drawable-nodpi/jb_6.png

Added
New image

File res/drawable-nodpi/jb_7.png

Added
New image

File res/drawable-nodpi/jb_8.png

Added
New image

File res/drawable-nodpi/majikichi11.png

Added
New image

File res/drawable-nodpi/majikichi21.png

Added
New image

File res/drawable-nodpi/majikichi31.png

Added
New image

File res/drawable-nodpi/majikichi41.png

Added
New image

File res/drawable-nodpi/majikichi51.png

Added
New image

File res/drawable-nodpi/majikichi61.png

Added
New image

File res/drawable-nodpi/majikichi71.png

Added
New image

File res/drawable-nodpi/test2.png

Added
New image

File res/drawable-xhdpi/ic_launcher.png

Added
New image

File res/layout/activity_main.xml

+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".MainActivity" >
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"
+        android:text="@string/hello_world" />
+
+</RelativeLayout>

File res/menu/activity_main.xml

+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/menu_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/menu_settings"/>
+
+</menu>

File res/values-v11/styles.xml

+<resources>
+
+    <!--
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+        <!-- API 11 theme customizations can go here. -->
+    </style>
+
+</resources>

File res/values-v14/styles.xml

+<resources>
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>

File res/values/strings.xml

+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">Antivirus</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="menu_settings">Settings</string>
+
+</resources>

File res/values/styles.xml

+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="AppBaseTheme">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+    </style>
+
+</resources>

File src/com/example/antivirus/GameActivity.java

+package com.example.antivirus;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.content.Intent;
+import android.view.Window;
+import android.view.WindowManager;
+
+public class GameActivity extends Activity{
+	@Override
+	public void onCreate(Bundle bundle){
+		Intent intent = getIntent();
+		String level = intent.getStringExtra("level");
+		super.onCreate(bundle);
+		getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+		requestWindowFeature(Window.FEATURE_NO_TITLE);
+		setContentView(new GameView2(this, level));
+	}
+
+}

File src/com/example/antivirus/GameView.java

+package com.example.antivirus;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.view.GestureDetector;
+import android.view.GestureDetector.OnGestureListener;
+import android.view.MotionEvent;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+
+public class GameView extends SurfaceView implements SurfaceHolder.Callback,Runnable,GestureDetector.OnDoubleTapListener, OnGestureListener{
+	private GestureDetector gestureDetector;
+	private final static int S_STANDBY=0,
+			S_PLAY = 1,
+			S_CLEAR = 2,
+			S_GAMEOVER = 3;
+	
+	private int[][] status = new int[6][13];
+	
+	private SurfaceHolder holder;
+	private Thread thread;
+	private Bitmap[] bmp = new Bitmap[3];
+	
+	private int scene = S_STANDBY;
+	private int init = S_STANDBY;
+	private String message = null;
+	private int score = 0;
+	
+	public GameView(Context context) {
+		super(context);
+		// TODO Auto-generated constructor stub
+		bmp[0] = readBitmap(context, "test2");
+		bmp[1] = readBitmap(context, "jb_4");
+		bmp[2] = readBitmap(context, "jb_5");
+		
+		gestureDetector = new GestureDetector(context,this);
+		holder = getHolder();
+		holder.addCallback(this);
+		holder.setFixedSize(480, 800);
+	}
+
+	private Bitmap readBitmap(Context context, String name) {
+		// TODO Auto-generated method stub
+		int resID = context.getResources().getIdentifier(name, "drawable", context.getPackageName());
+		return BitmapFactory.decodeResource(context.getResources(), resID);
+	}
+
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+		Canvas canvas;
+		Paint paint = new Paint();
+		
+		while(thread != null){
+			if(init >= 0){
+				scene = init;
+				init = -1;
+				if(scene == S_STANDBY){
+					message = "Touch Start";
+					for(int i=0;i<6;i++)
+						for(int j=0;j<13;j++)
+							status[i][j] = 0;
+				}else if (scene == S_PLAY){
+					message = null;
+				}else if (scene == S_CLEAR){
+					message = "Clear";
+				}else if(scene == S_GAMEOVER){
+					message = "Game Over";
+					
+				}
+			}
+			if (scene == S_PLAY){
+				if (move() == false)
+					init = S_GAMEOVER;
+			}
+			canvas = holder.lockCanvas();
+			canvas.drawBitmap(bmp[0], 0, 0, null);
+			
+			paint.setColor(Color.WHITE);
+			paint.setTextSize(30);
+			canvas.drawText("SCORE:" + num2str(score,4), 10, 40, paint);
+			
+			for(int i=0;i<6;i++)
+				for(int j=1;j<13;j++){
+					if(status[i][j] != 0){
+						canvas.drawBitmap(bmp[1],i*80,(j-1)*60 + 62, null);
+					}
+				}
+			if(message != null){
+				canvas.drawText(message, (480-paint.measureText(message))/2, 450, paint);
+			}
+			holder.unlockCanvasAndPost(canvas);
+			try{
+				Thread.sleep(300);
+			}catch(Exception e){
+				
+			}
+		}
+	}
+	public int Count(int x,int y,int n)	{
+	    if(x+1<6 && status[x+1][y]==2) Count(x+1,y,n++);
+	    if(y+1<13 && status[x][y+1]==2) Count(x,y+1,n++);
+	    if(x-1>=0 && status[x-1][y]==2) Count(x-1,y,n++);
+	    if(y-1>=0 && status[x][y-1]==2) Count(x,y-1,n++);
+	    return n;
+	}
+	private void checkDelete() {
+		// TODO Auto-generated method stub
+		int[][] deleteArray = new int[6][13];
+		for(int i=0;i<6;i++)
+			for(int j=0;j<13;j++)
+				deleteArray[i][j] = 1;
+		for(int i=0;i<6;i++)
+			for(int j=0;j<13;j++)
+				if(status[i][j] == 2)
+					if(Count(i,j,0) > 4)
+						deleteArray[i][j] = 0;
+		for(int i=0;i<6;i++)
+			for(int j=0;j<13;j++)
+				if(deleteArray[i][j] == 0)
+					status[i][j] = 0;
+	}
+
+	@Override
+	public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void surfaceCreated(SurfaceHolder holder) {
+		// TODO Auto-generated method stub
+		init = S_STANDBY;
+		thread = new Thread(this);
+		thread.start();
+	}
+
+	@Override
+	public void surfaceDestroyed(SurfaceHolder holder) {
+		// TODO Auto-generated method stub
+		thread = null;
+	}
+	
+	private static String num2str(int num, int len){
+		String str = " " + num;
+		while(str.length()<len) str = "0" + str;
+		return str;
+	}
+	private boolean move(){
+		int[] new_status  = new int[6]; 
+		for(int i=0;i<6;i++)
+			new_status[i] = 0;
+		int mov = 0;
+		boolean result = true;
+		for(int i=0;i<6;i++)
+			for(int j=0;j<13;j++){
+				if(status[i][j] == 1 || status[i][j] == 3){
+					new_status[i] = 1;
+				}
+				if(new_status[i] == 1 && status[i][j] == 0){
+					new_status[i] = 2;
+					mov++;
+				}
+			}
+		if(mov == 0){
+			if(status[3][0] == 0){
+				status[3][0] = 1;
+				status[3][1] = 3;
+			}else
+				result = false;
+		}
+		for(int i=0;i<6;i++)
+				for(int j=12;j>0;j--){
+					boolean f = true;
+					if(status[i][j] == 0){
+						status[i][j] = status[i][j-1];
+						status[i][j-1] = 0;
+						f = false;
+					}
+					if(f==true){
+						status[i][j] = 2;
+					}
+				}
+		return result;
+	}
+	
+	
+	public void cycle(int i, int j){
+		if (status[i-1][j] == 3){
+			status[i-1][j] = 0;
+			status[i][j+1] = 3;
+		}else if (status[i][j+1] == 3){
+			if(status[i-1][j] != 2){
+				status[i][j+1] = 0;
+				status[i-1][j] = 3;
+			}
+		}else if (status[i+1][j] == 3){
+			if(status[i][j+1] != 2){
+				status[i+1][j] = 0;
+				status[i][j+1] = 3;
+			}
+		}else if (status[i][j-1] == 3){
+			if(status[i+1][j] != 2){
+				status[i][j-1] = 0;
+				status[i+1][j] = 3;
+			}
+		}
+		
+	}
+	
+	
+	@Override
+	public boolean onTouchEvent(MotionEvent event){
+		gestureDetector.onTouchEvent(event);
+		
+		return true;	
+	}
+
+	@Override
+	public boolean onDoubleTap(MotionEvent event) {
+		// TODO Auto-generated method stub
+//		if (scene == S_PLAY){
+//			for(int i=1;i<5;i++)
+//				for(int j=1;j<12;j++){
+//					if(status[i][j] == 1){
+//						cycle(i,j);
+//					}
+//				}
+		
+//		}
+		
+		return true;
+	}
+
+	@Override
+	public boolean onDoubleTapEvent(MotionEvent e) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean onSingleTapConfirmed(MotionEvent event) {
+		// TODO Auto-generated method stub
+		if (scene == S_STANDBY){
+			init = S_PLAY;
+		}else if(scene == S_PLAY){
+			float  X = event.getX();
+			
+			for(int i=0;i<6;i++)
+				for(int j=0;j<13;j++){
+					if(status[i][j] == 1 || status[i][j] == 3){
+						if(i*80 + 40 < X){
+							if(i != 5 && status[i+1][j] != 2){
+								status[i+1][j] = 1;
+								status[i][j] = 0;
+							}
+						}else if(i*80 + 40 > X){
+							if(i != 0 && status[i-1][j] != 2){
+								status[i-1][j] = 1;
+								status[i][j] = 0;
+							}
+					}
+				}
+			}
+			
+		}else{
+			init = S_STANDBY;
+
+		}
+		return true;
+	}
+
+	@Override
+	public boolean onDown(MotionEvent e) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
+			float velocityY) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void onLongPress(MotionEvent e) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
+			float distanceY) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void onShowPress(MotionEvent e) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public boolean onSingleTapUp(MotionEvent e) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	
+
+}

File src/com/example/antivirus/GameView2.java

+package com.example.antivirus;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.Log;
+import android.view.GestureDetector;
+import android.view.GestureDetector.OnGestureListener;
+import android.view.MotionEvent;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.app.Activity;
+import android.app.AlertDialog;
+
+public class GameView2 extends SurfaceView implements SurfaceHolder.Callback,Runnable,
+		GestureDetector.OnDoubleTapListener, OnGestureListener{
+	Context myContext;
+	private GestureDetector gestureDetector;
+	private final static int S_STANDBY=0,
+			S_PLAY = 1,
+			S_CLEAR = 2,
+			S_GAMEOVER = 3;
+
+	private Stage stage;
+	
+	private SurfaceHolder holder;
+	private Thread thread;
+	private Bitmap[] bmp = new Bitmap[6];
+	
+	private int scene = S_STANDBY;
+	private int init = S_STANDBY;
+	private String message = null;
+	private String level = "normal";
+	private int speed;
+	
+	public GameView2(Context context , String select) {
+		super(context);
+		myContext = context;
+		// TODO Auto-generated constructor stub
+		bmp[0] = readBitmap(context, "test2");
+		bmp[1] = readBitmap(context, "jb_4");
+		bmp[2] = readBitmap(context, "jb_6");
+		bmp[3] = readBitmap(context, "jb_7");
+		bmp[4] = readBitmap(context, "jb_8");
+		bmp[5] = readBitmap(context, "jb_5");
+		
+		
+//		bmp[1] = readBitmap(context, "majikichi11");
+//		bmp[2] = readBitmap(context, "majikichi51");
+//		bmp[3] = readBitmap(context, "majikichi61");
+//		bmp[4] = readBitmap(context, "majikichi71");
+//		bmp[5] = readBitmap(context, "majikichi41");
+		
+//		Log.i("GV", select);
+		level = select;
+		if(level.equals("easy"))	speed = 500;
+		else if(level.equals("hard"))	speed = 100;
+		else	speed = 300;
+		
+		stage = new Stage();
+		gestureDetector = new GestureDetector(context,this);
+		holder = getHolder();
+		holder.addCallback(this);
+		holder.setFixedSize(480, 800);
+	}
+
+	private Bitmap readBitmap(Context context, String name) {
+		// TODO Auto-generated method stub
+		int resID = context.getResources().getIdentifier(name, "drawable", context.getPackageName());
+		return BitmapFactory.decodeResource(context.getResources(), resID);
+	}
+
+	@Override
+	public void run() {
+		// TODO Auto-generated method stub
+//		Canvas canvas;
+//		Paint paint = new Paint(); 
+		
+		while(thread != null){
+			if(init >= 0){
+				scene = init;
+				init = -1;
+				if(scene == S_STANDBY){
+					message = "Touch Start";
+				}else if (scene == S_PLAY){
+					message = null;
+				}else if (scene == S_CLEAR){
+					message = "Clear";
+				}else if(scene == S_GAMEOVER){
+					message = "Game Over";
+				}
+			}
+			if (scene == S_PLAY){
+				if(stage.getResult()){
+					stage.step();
+					stage.puyoDelete();
+				}else
+					init = S_GAMEOVER;
+			}
+			drawCanvas();
+			try{
+				Thread.sleep(speed);
+			}catch(Exception e){
+				
+			}
+		}
+	}
+
+	private void drawCanvas(){
+		Canvas canvas;
+		Paint paint = new Paint(); 
+		canvas = holder.lockCanvas();
+		canvas.drawBitmap(bmp[0], 0, 0, null);
+//		canvas.drawColor(Color.WHITE);
+		
+		paint.setColor(Color.WHITE);
+//		paint.setColor(Color.BLACK);
+		paint.setTextSize(30);
+		canvas.drawText("SCORE:" + num2str(stage.getScore(),4), 10, 40, paint);
+		
+		drawIcon(canvas);
+		
+		if(message != null){
+			canvas.drawText(message, (480-paint.measureText(message))/2, 450, paint);
+		}
+		holder.unlockCanvasAndPost(canvas);
+	}
+	
+	private void drawIcon(Canvas canvas){
+		for(int i=0;i<6;i++)
+			for(int j=1;j<13;j++){
+				int col = stage.getField()[i][j];
+				if(col == 1){
+					if(!level.equals("extra"))
+						col = stage.getColor(i,j);
+					else
+						canvas.drawBitmap(bmp[5],i*80,(j-1)*60 + 62, null);
+				}
+				if(col == 2){
+					canvas.drawBitmap(bmp[1],i*80,(j-1)*60 + 62, null);
+				}else if(col == 3){
+					canvas.drawBitmap(bmp[2],i*80,(j-1)*60 + 62, null);
+				}else if(col == 4){
+					canvas.drawBitmap(bmp[3],i*80,(j-1)*60 + 62, null);
+				}else if(col == 5){
+					canvas.drawBitmap(bmp[4],i*80,(j-1)*60 + 62, null);
+				}
+			}
+	}
+	@Override
+	public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void surfaceCreated(SurfaceHolder holder) {
+		// TODO Auto-generated method stub
+		init = S_STANDBY;
+		thread = new Thread(this);
+		thread.start();
+	}
+
+	@Override
+	public void surfaceDestroyed(SurfaceHolder holder) {
+		// TODO Auto-generated method stub
+		thread = null;
+	}
+	
+	private static String num2str(int num, int len){
+		String str = " " + num;
+		while(str.length()<len) str = "0" + str;
+		return str;
+	}
+	
+	
+	@Override
+	public boolean onTouchEvent(MotionEvent event){
+		gestureDetector.onTouchEvent(event);
+		
+		return true;	
+	}
+
+	@Override
+	public boolean onDoubleTap(MotionEvent event) {
+		// TODO Auto-generated method stub	
+		if(scene == S_PLAY){
+			stage.rotate();
+			drawCanvas();
+		}
+		return true;
+	}
+
+	@Override
+	public boolean onDoubleTapEvent(MotionEvent e) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean onSingleTapConfirmed(MotionEvent event) {
+		// TODO Auto-generated method stub
+		if (scene == S_STANDBY){
+			init = S_PLAY;
+		}else if(scene == S_PLAY){
+			float  X = event.getX();
+			stage.move(X);
+			drawCanvas();
+		}else if(scene == S_GAMEOVER){
+			dialog();
+
+		}else{
+			init = S_STANDBY;
+		}
+		return true;
+	}
+
+	@Override
+	public boolean onDown(MotionEvent e) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
+			float velocityY) {
+		// TODO Auto-generated method stub
+		if (velocityY > 0) {
+			stage.puyoDown();
+			drawCanvas();
+		}
+		return true;
+	}
+
+	@Override
+	public void onLongPress(MotionEvent e) {
+		// TODO Auto-generated method stub
+		init = S_GAMEOVER;
+	}
+
+	@Override
+	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
+			float distanceY) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void onShowPress(MotionEvent e) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public boolean onSingleTapUp(MotionEvent e) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	
+	public void dialog(){
+        AlertDialog.Builder alert = new AlertDialog.Builder((Activity)myContext);  
+        alert.setTitle("GAME OVER");  
+        alert.setMessage("ONE MORE?");  
+        alert.setPositiveButton("Yes", new DialogInterface.OnClickListener(){  
+            public void onClick(DialogInterface dialog, int which) {  
+                //Yesボタンが押された時の処理  
+            	stage = new Stage();
+    			init = S_STANDBY;
+            }});  
+        alert.setNegativeButton("No", new DialogInterface.OnClickListener(){  
+            public void onClick(DialogInterface dialog, int which) {  
+                //Noボタンが押された時の処理  
+    			((Activity)myContext).finish();
+            }});  
+        alert.show();  
+    }    
+}

File src/com/example/antivirus/MainActivity.java

+package com.example.antivirus;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+import android.view.Window;
+import android.content.Intent;
+import android.graphics.Color;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+
+public class MainActivity extends Activity implements View.OnClickListener{
+	private final static int REQUEST_TEXT = 0;
+	private final static int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
+	@Override
+	protected void onCreate(Bundle bundle) {
+		super.onCreate(bundle);
+//		setContentView(R.layout.activity_main);
+		requestWindowFeature(Window.FEATURE_NO_TITLE);
+		
+		LinearLayout layout = new LinearLayout(this);
+		layout.setBackgroundColor(Color.rgb(255,255,255));
+		layout.setOrientation(LinearLayout.VERTICAL);
+		setContentView(layout);
+		
+		layout.addView(makeButton("aaaaaa","aaaa"));
+		layout.addView(makeButton("bbbbbb","bbbb"));
+
+
+	}
+
+	private Button makeButton(String text, String tag){
+		Button button = new Button(this);
+		button.setText(text);
+		button.setTag(tag);
+		button.setOnClickListener(this);
+		button.setLayoutParams(new LinearLayout.LayoutParams(WC,WC));
+		return button;
+	}
+	
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.activity_main, menu);
+		return true;
+	}
+
+	@Override
+	public void onClick(View v) {
+		// TODO Auto-generated method stub
+		String tag = (String)v.getTag();
+		if(tag == "aaaa"){
+			
+		}else if(tag == "bbbb"){
+			Intent intent = new Intent(this,com.example.antivirus.PracticeActivity.class);
+			startActivityForResult(intent,REQUEST_TEXT);
+		}
+		
+	}
+
+}

File src/com/example/antivirus/PracticeActivity.java

+package com.example.antivirus;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Window;
+import android.content.Intent;
+import android.graphics.Color;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.Spinner;
+
+public class PracticeActivity extends Activity implements View.OnClickListener{
+	private final static int WC = LinearLayout.LayoutParams.WRAP_CONTENT;
+	private Spinner spinner;
+	
+	@Override
+	public void onCreate(Bundle bundle){
+		super.onCreate(bundle);
+		requestWindowFeature(Window.FEATURE_NO_TITLE);
+		
+		setResult(Activity.RESULT_CANCELED);
+		LinearLayout layout = new LinearLayout(this);
+		layout.setBackgroundColor(Color.rgb(255, 255, 255));
+		layout.setOrientation(LinearLayout.VERTICAL);
+		setContentView(layout);
+		
+		ArrayAdapter<String> adapter =new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item);
+		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+		String[] strs = {"easy","normal","hard","extra"};
+		for(int i=0;i<strs.length;i++) adapter.add(strs[i]);
+		spinner = new Spinner(this);
+		spinner.setAdapter(adapter);
+		spinner.setSelection(0);
+		spinner.setLayoutParams(new LinearLayout.LayoutParams(WC,WC));
+		layout.addView(spinner);
+		
+		layout.addView(makeButton("プレイ","play"));
+		layout.addView(makeButton("戻る","back"));
+	}
+	
+	private Button makeButton(String text, String tag){
+		Button button = new Button(this);
+		button.setText(text);
+		button.setTag(tag);
+		button.setOnClickListener(this);
+		button.setLayoutParams(new LinearLayout.LayoutParams(WC,WC));
+		return button;
+	}
+	
+	@Override
+	public void onClick(View v) {
+		// TODO Auto-generated method stub
+		String tag = (String)v.getTag();
+		if(tag == "play"){
+			Intent intent = new Intent(this,com.example.antivirus.GameActivity.class);
+			intent.putExtra("level", (String)spinner.getSelectedItem());
+			startActivityForResult(intent,0);
+			finish();
+		}else if(tag == "back"){
+			Intent intent = new Intent(this,com.example.antivirus.MainActivity.class);
+			startActivityForResult(intent,0);
+			finish();
+		}
+	}
+	
+}

File src/com/example/antivirus/Puyo.java

+package com.example.antivirus;
+
+import java.util.Random;
+
+public class Puyo {
+	private int state;
+	private int aColor;
+	private int bColor;
+	private int ax;
+	private int ay;
+	private int bx;
+	private int by;
+	
+	public Puyo(){
+		Random r = new Random();
+		
+		state = 0;
+		aColor = r.nextInt(4) + 2;
+		bColor = r.nextInt(4) + 2;
+		ax = 3;
+		ay = 0;
+		bx = 3;
+		by = 1;
+	}
+	public int[] getLocate(){
+		int[] locate = {ax,ay,bx,by};
+		return locate;
+	}
+	public void setLocate(int which,int x,int y){
+		if(which == 0){
+			ax = x;
+			ay = y;
+		}else if (which ==1){
+			bx = x;
+			by = y;
+		}
+	}
+	public void aFall(){
+		ay++;
+	}
+	public void bFall(){
+		by++;
+	}
+	public void aRight(){
+		ax++;
+	}
+	public void bRight(){
+		bx++;
+	}
+	public void aLeft(){
+		ax--;
+	}
+	public void bLeft(){
+		bx--;
+	}
+	public int getAColor(){
+		return aColor;
+	}
+	public int getBColor(){
+		return bColor;
+	}
+	public int getState(){
+		return state;
+	}
+	public void setState(int s){
+		state = s;
+	}
+}

File src/com/example/antivirus/Stage.java

+package com.example.antivirus;
+
+public class Stage {
+	private static final int XMax = 6;		//行のMax
+	private static final int YMax = 13;	//列のMax
+	private int  field[][];	//ぷよぷよの色とかの配置
+	private int deleteArray[][];	//削除用配列 
+	private int sequenceNum;	//連続色個数 
+	private int checkColor;	//チェック用に色を格納する変数
+	private int deleteNum=0;	//連鎖回数
+	private boolean deletingFlag = false;	//消してる途中
+	private boolean result = true;	//試合終了ですよ
+	private Puyo puyo;	//落ちてくるぷよ
+	public static final int LEFT = 0;
+	public static final int RIGHT = 1;
+	private int score;
+
+	public boolean deleteFlag; //ぷよを消したかどうかの判定
+
+	enum Direction {UP, DOWN, LEFT, RIGHT};
+	
+	//コンストラクタ
+	public Stage(){
+		field = new int[XMax][YMax];
+		for(int i=0;i<XMax;i++)
+			for(int j=0;j<YMax;j++)
+				field[i][j] = 0;
+		deleteFlag=false;
+	}
+
+	//落ちる1ステップ
+	public void step(){
+		boolean flag = true;
+		for(int i=0;i<XMax;i++)
+			for(int j=0;j<YMax;j++)
+				if(field[i][j] == 1){
+					flag = false;
+				}
+		if(flag == true){
+			if(field[3][1]==0){
+//				if(checkFalling() == false){
+				puyo = new Puyo();
+				setPuyo();
+//				}
+			}else{
+				result = false;
+			}
+		}else{
+			int[] locate = puyo.getLocate(); //{一つ目のx,一つ目のy,二つ目のx,二つ目のy}
+			for(int i=0;i<6;i++)
+				for(int j=12;j>0;j--){
+					if(field[i][j] == 0){
+						field[i][j] = field[i][j-1];
+						field[i][j-1] = 0;
+					}else if(field[i][j] == 1){
+						int col = 2;
+						if(locate[0] == i && locate[1] == j)
+							col = puyo.getAColor();
+						else if(locate[2] == i && locate[3] == j)
+							col = puyo.getBColor();
+						field[i][j] = col;
+					}
+				}
+			
+			if(locate[1] != 12 && locate[3] != 12){
+				puyo.aFall();
+				puyo.bFall();
+			}
+//			setPuyo();
+		}
+		boolean flaga = true;
+		for(int i=0;i<XMax;i++)
+			for(int j=0;j<YMax;j++)
+				if(field[i][j] == 1)
+					flaga = false;
+		if(flaga == true)
+			puyoDelete();
+	}
+	
+	//メソッドにする必要なし?
+	private void setPuyo(){
+		for(int i=0;i<XMax;i++)
+			for(int j=0;j<YMax;j++)
+				if(field[i][j] == 1)
+					field[i][j] = 0;
+		field[puyo.getLocate()[0]][puyo.getLocate()[1]] = 1;
+		field[puyo.getLocate()[2]][puyo.getLocate()[3]] = 1;
+	}
+	
+	//左右の移動
+	public void move(float touchX){
+		int direction;
+		int[] locate = puyo.getLocate(); //{一つ目のx,一つ目のy,二つ目のx,二つ目のy}
+		if(field[locate[0]][locate[1]] == 1 && field[locate[2]][locate[3]] == 1){
+			if(locate[0]*80 + 40 < touchX){
+				direction = RIGHT;
+			}else{
+				direction = LEFT;
+			}
+			for(int i=0;i<XMax;i++)
+				for(int j=0;j<YMax;j++)
+					if(field[i][j] == 1){
+						field[i][j] = 0;
+					}
+			if(direction == RIGHT){
+				if(locate[0] < XMax-1 && locate[2] < XMax-1)
+					if(field[locate[0]+1][locate[1]] == 0 && field[locate[2]+1][locate[3]] == 0)
+						puyo.aRight();
+				if(locate[2] < XMax-1 && locate[0] < XMax-1)
+					if(field[locate[2]+1][locate[3]] == 0 && field[locate[0]+1][locate[1]] == 0)
+						puyo.bRight();
+			}
+			if(direction == LEFT){
+				if(locate[0] > 0 && locate[2] > 0)
+					if(field[locate[0]-1][locate[1]] == 0 && field[locate[2]-1][locate[3]] == 0)
+						puyo.aLeft();
+				if(locate[2] > 0 && locate[0] > 0)
+					if(field[locate[2]-1][locate[3]] == 0 && field[locate[0]-1][locate[3]] == 0)
+						puyo.bLeft();
+			}
+			setPuyo();
+		}
+	}
+	
+	//回転する
+	public void rotate(){
+		int[] locate = puyo.getLocate(); //{一つ目のx,一つ目のy,二つ目のx,二つ目のy}
+		if(field[locate[0]][locate[1]] == 1 && field[locate[2]][locate[3]] == 1){
+			if(locate[1] == locate[3]){ //横の場合
+				if(locate[1] < YMax-1){
+					if(locate[0] > locate[2]){
+					if(field[locate[0]][locate[1]+1] == 0)
+						puyo.setLocate(1, locate[0], locate[1]+1);
+					}else if(locate[0] < locate[2]){
+						if(locate[1] > 0 && field[locate[0]][locate[1]-1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]-1);
+					}
+				}else if(locate[1] > 0){
+					if(locate[0] > locate[2]){
+						if(field[locate[0]][locate[1]-1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]-1);
+					}else if(locate[0] < locate[2]){
+						if(locate[1] < YMax-1 && field[locate[0]][locate[1]+1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]+1);
+					}
+				}			
+			}else if(locate[0] == locate[2]){ //縦の場合
+				if(locate[0] < XMax-1){
+					if(locate[1] < locate[3]){
+						if(field[locate[0]+1][locate[1]] == 0)
+							puyo.setLocate(1, locate[0]+1, locate[1]);
+						else if(locate[0] > 0 && field[locate[0]-1][locate[1]] == 0)
+							puyo.setLocate(1, locate[0]-1, locate[1]);
+						else if(field[locate[0]][locate[1]-1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]-1);
+					}else if(locate[1] > locate[3]){
+						if(locate[0] > 0 && field[locate[0]-1][locate[1]] == 0)
+							puyo.setLocate(1, locate[0]-1, locate[1]);
+						else if(locate[0] > 0 && field[locate[0]+1][locate[1]] == 0)
+							puyo.setLocate(1, locate[0]+1, locate[1]);
+						else if(field[locate[0]][locate[1]+1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]+1);
+					}
+				}else if(locate[0] > 0){
+					if(locate[1] > locate[3]){
+						if(field[locate[0]-1][locate[1]] == 0)
+							puyo.setLocate(1, locate[0]-1, locate[1]);
+						else if(locate[0] < XMax-1 && field[locate[0]+1][locate[1]] == 0)
+							puyo.setLocate(1, locate[0]+1, locate[1]);
+						else if(locate[1] < YMax-1 && field[locate[0]][locate[1]+1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]+1);
+					}else if(locate[1] < locate[3]){
+						if(locate[1] > 0 && field[locate[0]][locate[1]-1] == 0)
+							puyo.setLocate(1, locate[0], locate[1]-1);
+					}
+				}
+			}
+			setPuyo();
+		}
+	}
+	
+	//なんか落ちてる
+	private boolean checkFalling(){
+		boolean checkFlag = false;
+		for(int i=0; i<XMax; i++)
+			for(int j=YMax-1; j>0; j--){
+				if(field[i][j] == 0){
+					for(int x=i-1; x>=0; x--){
+						if(field[i][x]!= 0){
+							checkFlag = true;
+							break;
+						}
+					}
+				}
+			}
+		return checkFlag;
+	}
+	
+	public int[][] getField(){
+		return field;
+	}
+	
+	public boolean getResult(){
+		return result;
+	}
+	
+	public int getScore(){
+		return score;
+	}
+	
+	public int getColor(int x, int y){
+		int[] locate = puyo.getLocate(); //{一つ目のx,一つ目のy,二つ目のx,二つ目のy}
+		if(locate[0] == x && locate[1] == y){
+			return puyo.getAColor();
+		}else if(locate[2] == x && locate[3] == y){
+			return puyo.getBColor();
+		}
+		return 1;
+	}
+	
+	//以下コピペ
+	//ぷよぷよの削除
+	public void puyoDelete(){
+		for(int i=0;i<XMax;i++){
+			for(int j=0;j<YMax;j++){
+				deletMain(i,j);
+			}
+		}	
+	}
+
+	//削除メイン処理
+	private void deletMain(int i, int j) {
+		//連続している色のカウントリセット
+		sequenceNum = 0;
+
+		//ぷよがなければチェックしない。
+		if(field[i][j]==0) return;
+		
+		//チェックカラーのセット
+		checkColor = field[i][j];
+		
+		//削除チェック配列の初期化
+		deleteArray = new int[XMax][YMax];
+		for(int x=0; x<XMax; x++){
+			for(int y=0; y<YMax; y++){
+				deleteArray[x][y]=0;
+			}
+		}
+
+		//削除チェック
+		deleteSub(i,j,Direction.RIGHT);
+
+		//隣り合ったぷよぷよが4つ以上ある場合に消す。
+		if(sequenceNum > 3){
+			//チェック用配列が1以上の場所にあるぷよを消す
+			for(int l=0; l<XMax; l++){
+				for(int m=0; m<YMax; m++){
+					//削除対象かのチェック
+					if(deleteArray[l][m]>0){
+						//削除対象であればスペースを代入
+						field[l][m] = 0;
+						score++;
+					}
+				}
+		
+			}
+		}
+	}
+
+	//削除サブ処理
+	private void deleteSub(int i, int j, Stage.Direction direction) {
+
+		//一度チェックしたかの確認
+		if(deleteArray[i][j]!=0){
+			return;
+		}
+		
+		//色が同じかどうかのチェック
+		if(checkColor==field[i][j]){
+			sequenceNum++;
+		}else{
+			return;
+		}
+				
+		//一度チェックしたかの確認
+		if(deleteArray[i][j]!=0){
+			return;
+		}
+		else{
+			deleteArray[i][j]++;
+		}
+		
+		//右のチェック
+		if(i<XMax-1 && direction!=Direction.LEFT){
+			deleteSub(i+1, j, Direction.RIGHT);
+		}
+
+		//下のチェック
+		if(j<YMax-1){
+			deleteSub(i, j+1, Direction.DOWN);
+		}
+
+		//左のチェック
+		if(i>0 && direction!=Direction.RIGHT){
+			deleteSub(i-1, j, Direction.LEFT);
+		}
+		
+		return;
+	}
+
+	//ぷよぷよを落とす
+	public void puyoDown() {
+		int[] locate = puyo.getLocate(); //{一つ目のx,一つ目のy,二つ目のx,二つ目のy}
+		if(field[locate[0]][locate[1]] == 1 && field[locate[2]][locate[3]] == 1){
+			for(int j=YMax-1; j>0; j--){
+				if(locate[1] == locate[3]){
+					boolean flag = true;
+					if(field[locate[0]][j] == 0){
+						puyo.setLocate(0, locate[0], j);
+						if(flag == false)
+							break;
+						else	flag = false;
+					}
+					if(field[locate[2]][j] == 0){
+						puyo.setLocate(1, locate[2], j);
+						if(flag == false)
+							break;
+						else	flag = false;
+					}
+				}else if(locate[1] > locate[3]){
+					if(field[locate[0]][j] == 0){
+						puyo.setLocate(1, locate[2], j-1);
+						puyo.setLocate(0, locate[2], j);
+						break;
+					}
+				}else if(locate[1] < locate[3]){
+					if(field[locate[0]][j] == 0){
+						puyo.setLocate(1, locate[2], j);
+						puyo.setLocate(0, locate[2], j-1);
+						break;
+					}
+				}
+			}
+			setPuyo();
+		}
+	}
+	
+}