安卓翻牌游戏源代码(安卓2048游戏源代码)
admin 发布:2022-12-19 20:59 146
本篇文章给大家谈谈安卓翻牌游戏源代码,以及安卓2048游戏源代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
记忆翻牌游戏,要求翻对一组牌时牌消失,直到所有牌消失。求源程序。
这个靠记忆里,是没辅助的,建议从左到右一个一个按顺序翻,这样容易记忆。
安卓手机游戏中的代码如何获得?
您好
获取游戏源代码需要对APK进行反编译,如果APK已经加密,无法通过反编译的方法获取源代码
目前反编译的软件有很多,您可以在腾讯电脑管家中下载,推荐使用【改之理】,一款非常好用的反编译软件,傻瓜式操作,适合新手,您百度也能搜索到
希望可以帮到您,望采纳
腾讯电脑管家企业平台:
求一个安卓开发小游戏源代码,临时交作业用
package com.fiveChess;
import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends Activity {
GameView gameView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Display display = this.getWindowManager().getDefaultDisplay();
gameView = new GameView(this,display.getWidth(),display.getHeight());
setContentView(gameView);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("重新开始").setIcon(android.R.drawable.ic_menu_myplaces);
menu.add("退出");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getTitle().equals("重新开始")){
gameView.canPlay = true;
gameView.chess = new int[gameView.row][gameView.col];
gameView.invalidate();
}else if(item.getTitle().equals("退出")){
finish();
}
return super.onOptionsItemSelected(item);
}
}
package com.fiveChess;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.view.MotionEvent;
import android.view.View;
public class GameView extends View {
Context context = null;
int screenWidth,screenHeight;
String message = "";//提示轮到哪个玩家
int row,col; //划线的行数和列数
int stepLength = 30;//棋盘每格间距
int[][] chess = null;//0代表没有棋子,1代表是黑棋,2代表白旗
boolean isBlack = true;
boolean canPlay = true;
public GameView(Context context,int screenWidth,int screenHeight) {
super(context);
this.context = context;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
this.message = "黑棋先行";
row = (screenHeight-50)/stepLength+1;
col = (screenWidth-10)/stepLength+1;
chess = new int[row][col];
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(Color.WHITE);
canvas.drawRect(0, 0, screenWidth, screenHeight, paint);//画背景
paint.setColor(Color.BLUE);
paint.setTextSize(25);
canvas.drawText(message, (screenWidth-100)/2, 30, paint);//画最顶层的字
paint.setColor(Color.BLACK);
//画棋盘
for(int i=0;irow;i++){
canvas.drawLine(10, 50+i*stepLength, 10+(col-1)*stepLength, 50+i*stepLength, paint);
}
for(int i=0;icol;i++){
canvas.drawLine(10+i*stepLength,50,10+i*stepLength,50+(row-1)*stepLength, paint);
}
for(int r=0;rrow;r++){
for(int c=0;ccol;c++){
if(chess[r][c] == 1){
paint.setColor(Color.BLACK);
paint.setStyle(Style.FILL);
canvas.drawCircle(10+c*stepLength, 50+r*stepLength, 10, paint);
}else if(chess[r][c] == 2){
//画白棋
paint.setColor(Color.WHITE);
paint.setStyle(Style.FILL);
canvas.drawCircle(10+c*stepLength, 50+r*stepLength, 10, paint);
paint.setColor(Color.BLACK);
paint.setStyle(Style.STROKE);
canvas.drawCircle(10+c*stepLength, 50+r*stepLength, 10, paint);
}
}
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if(!canPlay){return false;}
float x = event.getX();
float y = event.getY();
int r = Math.round((y-50)/stepLength);
int c = Math.round((x-10)/stepLength);
if(r0 || rrow-1 || c0 || ccol-1){return false;}
if(chess[r][c]!=0){return false;}//若有棋子则不再画棋子了
if(isBlack){
chess[r][c] = 1;
isBlack = false;
message = "轮到白棋";
}else{
chess[r][c] = 2;
isBlack = true;
message = "轮到黑棋";
}
invalidate();
if(judge(r, c,0,1)) return false;
if(judge(r, c,1,0)) return false ;
if(judge(r, c,1,1)) return false;
if(judge(r, c,1,-1)) return false;
return super.onTouchEvent(event);
}
private boolean judge(int r, int c,int x,int y) {//r,c表示行和列,x表示在y方向上的偏移,y表示在x方向上的偏移
int count = 1;
int a = r;
int b = c;
while(r=0 rrow c=0 ccol r+x=0 r+xrow c+y=0 c+ycol chess[r][c] == chess[r+x][c+y]){
count++;
if(y0){
c++;
}else if(y0){
c--;
}
if(x0){
r++;
}else if(x0){
r--;
}
}
while(a=0 arow b=0 bcol a-x=0 a-xrow b-y=0 b-ycol chess[a][b] == chess[a-x][b-y]){
count++;
if(y0){
b--;
}else if(y0){
b++;
}
if(x0){
a--;
}else if(x0){
a++;
}
}
if(count=5){
String str = "";
if(isBlack){
str = "白棋胜利";
}else{
str = "黑棋胜利";
}
new AlertDialog.Builder(context).setTitle("游戏结束").setMessage(str).setPositiveButton("重新开始", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
chess = new int[row][col];
invalidate();
}
}).setNegativeButton("观看棋局", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
canPlay = false;
}
}).show();
return true;
}
return false;
}
}
PS:五子棋,无需图片,直接在程序里画出来的。注意我发的是两个文件,一个activity,一个类文件,别把它当成一个文件了
如何查看安卓游戏源代码
网上买礼物方便实惠,还时尚,我空间有详细的网购步骤和技巧总结。
我在网购经验比较多,网上的东西真的便宜很多,选购也很方便,我收集了很多热卖好评的商品和店铺,并做了统计排行,很多都是专家通过比较店铺信誉和销售记录以及网友的评价,做出的排行榜,当然也有很多是我通过购买和网友的交流统计出来的,都是热卖好评的,网购这么多年了,现在才知道,原来这样统计下,真的方便很多,现在分享给大家,当然主要是希望大家给我空间加加人气,还有采纳我的答案,让我赚赚分^_^,地址:
taobibuy点cn(把“点”改成“.”访问,注意是“点cn”,其他全为假冒的),那里有我的超级经验分享,有我总结的详细购物步骤和购物心得,肯定对你购物有很大帮助!快去看看吧,登陆的人比较多,打不开,请多刷新几次.
o(∩_∩)o希望对您有帮助,希望采纳我哦~
安卓翻牌游戏源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于安卓2048游戏源代码、安卓翻牌游戏源代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:物体碰撞模块c源代码的简单介绍
- 下一篇:简历源代码(制作简历源代码)
相关推荐
- 05-17游戏推广平台代理,游戏推广代理赚钱吗
- 05-09百度游戏客服在线咨询,百度游戏客服在线咨询平台
- 05-07pb超级报表源代码(pb报表工具)[20240507更新]
- 05-07简历源代码可以上传照片的简单介绍[20240507更新]
- 05-07广告切换源代码免费下载(广告切换源代码免费下载安装)[20240507更新]
- 05-06阁楼网源代码(阁楼是什么网站)[20240506更新]
- 05-06源代码管理资源管理器(资源管理器运行代码)[20240506更新]
- 05-06人脸识别源代码pdf的简单介绍[20240506更新]
- 05-06包含超市管理系统java源代码的词条[20240506更新]
- 05-06商城app源代码免费(商城App源码)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接