收藏 分销(赏)

Android连连看源代码.doc

上传人:人****来 文档编号:4316131 上传时间:2024-09-05 格式:DOC 页数:32 大小:181.23KB
下载 相关 举报
Android连连看源代码.doc_第1页
第1页 / 共32页
Android连连看源代码.doc_第2页
第2页 / 共32页
Android连连看源代码.doc_第3页
第3页 / 共32页
Android连连看源代码.doc_第4页
第4页 / 共32页
Android连连看源代码.doc_第5页
第5页 / 共32页
点击查看更多>>
资源描述

1、运行出来效果如下:MainActivity:package games.llk;import android.app.Activity;import android.os.Bundle;public class Main extends Activity /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); /setContentView(R.layout.main)

2、; setContentView(new GameView(this); GameView:package games.llk;import java.util.Random;import android.content.Context;import android.content.res.Resources;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.Paint;import android

3、.graphics.Point;import android.graphics.Rect;import android.graphics.Bitmap.Config;import android.os.Handler;import android.view.MotionEvent;import android.view.View;public class GameView extends View private int m_w;private int m_h;private int top_client;private int right_client;private int bottom_

4、client;private int left_client;private Rect client_r;private Paint p_client_r;private boolean display_moreInfo;private boolean isInited;private Paint p;private Paint p_line;private Paint p_line_2;private Paint p_text;private Paint p_pross_b;private Paint p_pross;private int point_w;private int point

5、_h;private Rect btn_r_1;private Rect btn_r_2;private Rect btn_r_close;private Bitmap bmp_btn;private Rect pross_r;private Rect pross_r_2;private Rect t_r;private Rect t_r_2;private boolean ispause=false;private boolean isstart=false;private String s_pause=暂停中。;private Bitmap buff;private Bitmap bmp_

6、point;private Bitmap bmp_hint;private Canvas buff_Canvas;private int flevel ;private int ffen =0;private int timecount=0;private int timecountper_l = 480;private boolean isdrawing=false ;private Random random=new Random();private Resources res;private Point pointlist_tmp ;private int pointlist_tmp_c

7、ount=0;private RefreshHandler mRedrawHandler = new RefreshHandler();private Point mousept ;private Point lastpt ;private Point hintpt_1 ;private Point hintpt_2 ;private boolean isontimering=false;private boolean isonmousedown=false;private int ontimercount=0;class RefreshHandler extends Handler Over

8、ridepublic void handleMessage(android.os.Message msg)GameView.this.ontimer(); nexttimer(240);public void nexttimer( long delayMillis) this.removeMessages(0);sendMessageDelayed(obtainMessage(0), delayMillis);private Pointlist fpointlist =new Pointlist();class Pointlistprivate int fxcount;private int

9、fycount;private int l1;private int l2;private PointData fpointreclist;class PointDatapublic int x;public int y;public boolean value;public Object data;public Rect rect;public int stat;public int imgidx;private Point plist_1;private int plist_1_len;private Point plist_2;private int plist_2_len;privat

10、e Point pathlist;public int pcount =0;public void init(int xcount, int ycount)fxcount=xcount;fycount=ycount;fpointreclist=new PointDatafxcount+2fycount+2;for (int x_i = 0; x_i fpointreclist.length; x_i+)for (int y_i = 0; y_i fpointreclistx_i.length; y_i+)fpointreclistx_iy_i=new PointData();fpointrec

11、listx_iy_i.x=x_i;fpointreclistx_iy_i.y=y_i;fpointreclistx_iy_i.value=false;fpointreclistx_iy_i.data=null;fpointreclistx_iy_i.rect=new Rect(0,0,0,0);fpointreclistx_iy_i.stat=-1;fpointreclistx_iy_i.imgidx=-1;plist_1=new Point(fxcount+fycount+2)*4;for (int i = 0; i plist_1.length; i+)plist_1i=new Point

12、(0,0);plist_1_len=0;plist_2=new Point(fxcount+fycount+2)*4;for (int i = 0; i plist_2.length; i+)plist_2i=new Point(0,0);plist_2_len=0;pathlist=new Point2;for (int i = 0; i pathlist.length; i+)pathlisti=new Point(0,0);l1=new intfxcount*2;l2=new intfxcount*2;public void setValue(int x,int y,Boolean va

13、lue) fpointreclistxy.value = value;public boolean getValue(int x,int y)return fpointreclistxy.value ;public void setData(int x,int y,Object data) fpointreclistxy.data = data;public void setrect(int x,int y,Rect r) fpointreclistxy.rect.left = r.left; fpointreclistxy.rect.top = r.top; fpointreclistxy.

14、rect.right = r.right; fpointreclistxy.rect.bottom = r.bottom; public Rect getrect(int x,int y) return fpointreclistxy.rect;public void setstat(int x,int y,int v) fpointreclistxy.stat=v;public int getstat(int x,int y)return fpointreclistxy.stat;public void setimgidx(int x,int y,int v) fpointreclistxy

15、.imgidx=v;public int getimgidx(int x,int y)return fpointreclistxy.imgidx;public boolean checkpp(Point p1,Point p2)boolean result=false; if (p1.x = p2.x) & (p1.y = p2.y) return true; if (p1.y = p2.y) int x1 = p1.x p2.x?p1.x:p2.x; for (int i=x1+1 ;i=x2-1;i+) if (fpointreclistip1.y.value ) return false

16、; result = true; if (p1.x = p2.x) int y1 = p1.y p2.y?p1.y:p2.y; for (int i=y1+1 ;i=y2-1;i+) if (fpointreclistp1.xi.value ) return false; result = true; return result;public void mousetoxy(int x,int y ,Point pt)for (int x_i = 1; x_i = fxcount; x_i+)for (int y_i = 1; y_i = fycount; y_i+)if (fpointrecl

17、istx_iy_i.rect.contains(x,y)pt.x=x_i;pt.y=y_i;return;pt.x=-1;pt.y=-1;public boolean isallok()for (int x_i = 1; x_i = fxcount; x_i+)for (int y_i = 1; y_i =0)return false;return true;public void changeplace(int v)int idx=0;if ( (v = 2)| (v = 6) for (int i = 1 ;i=fxcount;i+ ) idx = 0; for (int j = 1 ;j

18、= 0 ) idx=idx+1; l1idx = getimgidx(i, j); l2idx = getstat(i, j); for (int j = 1 ;j idx) setimgidx(i, j, -1); setstat(i, j, -1); setValue(i, j, false); else setimgidx(i, j, l1j); setstat(i, j, l2j); setValue(i, j, true); if ( (v = 3)| (v = 7) for (int i = 1 ;i=1 ;j-) if (getstat(i, j) = 0 ) idx=idx-1

19、; l1idx = getimgidx(i, j); l2idx = getstat(i, j); for (int j = fycount ;j=1;j-) if (j idx) setimgidx(i, j, -1); setstat(i, j, -1); setValue(i, j, false); else setimgidx(i, j, l1j); setstat(i, j, l2j); setValue(i, j, true); if( (v = 4)| (v = 8) for (int j = 1 ;j= fycount ;j+) idx = 0; for (int i = 1

20、;i= 0 ) idx=idx+1; l1idx = getimgidx(i, j); l2idx = getstat(i, j); for (int i = 1 ;i idx) setimgidx(i, j, -1); setstat(i, j, -1); setValue(i, j, false); else setimgidx(i, j, l1i); setstat(i, j, l2i); setValue(i, j, true); if ( (v = 5)| (v = 9) for (int j = 1 ;j=1;i- ) if (getstat(i, j) = 0 ) idx=idx

21、-1; l1idx = getimgidx(i, j); l2idx = getstat(i, j); for (int i = fxcount ;i=1;i- ) if (i idx) setimgidx(i, j, -1); setstat(i, j, -1); setValue(i, j, false); else setimgidx(i, j, l1i); setstat(i, j, l2i); setValue(i, j, true); public void findstat(int v ,Point pt)for (int x_i = 0; x_i fpointreclist.l

22、ength; x_i+)for (int y_i = 0; y_i =0;i-) x = x1;y = i;if (fpointreclistxy.value)break; else plist_1plist_1_len.x = x; plist_1plist_1_len.y = y; plist_1_len=plist_1_len+1; for (int i = y1 + 1;i=0;i-) x = i; y = y1; if (fpointreclistxy.value ) break; else plist_1plist_1_len.x = x; plist_1plist_1_len.y

23、 = y; plist_1_len=plist_1_len+1; for (int i = x1 + 1 ;i= 0;i- ) x = x2; y = i; if (fpointreclistxy.value ) break; else plist_2plist_2_len.x = x; plist_2plist_2_len.y = y; plist_2_len=plist_2_len+1; for( int i = y2 + 1 ;i= 0 ;i-) x = i; y = y2; if (fpointreclistxy.value ) break; else plist_2plist_2_l

24、en.x = x; plist_2plist_2_len.y = y; plist_2_len=plist_2_len+1; for (int i = x2 + 1 ;i= fxcount + 1;i+) x = i; y = y2; if (fpointreclistxy.value) break; else plist_2plist_2_len.x = x; plist_2plist_2_len.y = y; plist_2_len=plist_2_len+1; pcount = 0; for (int i = 0 ;i plist_1_len;i+) for (int j = 0 ;j 0) pathlistpcount.x = plist_1i.x; pathlistpcount.y = plist_1i.y; pcount=pcount+1; if (j 0)

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
百度文库年卡

猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服