android游戏源码用android编出来的小游戏有哪些
android游戏源码 时间:2021-09-24 阅读:(
)
求一个安卓开发小游戏源代码,临时交作业用
.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);
}
}
.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-1 || c<0 || c>col-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 && r=0 && c=0 && r+x=0 && c+y0){
c++;
}else if(y<0){
c--;
}
if(x>0){
r++;
}else if(x<0){
r--;
}
}
while(a>=0 && a=0 && b=0 && a-x=0 && b-y0){
b--;
}else if(y<0){
b++;
}
if(x>0){
a--;
}else if(x<0){
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,一个类文件,别把它当成一个文件了我想开发一个游戏,Android,2D,网络游戏。这个游戏已经存在,我要如何不看源代码自己编写出来
开发一个游戏。
要人物/风景的设计和美工。
要人物的动作,流畅度的调试和编程。
要将设计的人物与编程的动作进行结合。
如果你要单独开发一个游戏,我觉得你要学习三维制作/平面设计/c
++/java等不少于十项科目,学费10万不到吧。
自己考虑用android编出来的小游戏有哪些
小鸟、水果忍着什么的就不用说了,想必你也玩烂了。
我推荐几个我在玩的:
1、stupidzombies(几个子弹内打死所有屏幕上的僵尸,子弹会在屏幕上弹来弹去)
2、ageofwind2(中世纪海盗游戏,出去炸翻海上的船,然后捡桶子回去卖钱,修船买新船,挺有意思,重力感应操作方向,刚开始有点不熟,熟练了可以风筝n只船)
3、whackyourboss(只有20关,中文名好像叫老板的20种死法,如果你在工作,说不定你会喜欢)
4、三国杀。
这个就不用说了吧
5、beats。
跳舞机游戏。
6、battleheart(中文名勇者之心,打怪升级的,有法师、猎人、战士、dk、野蛮人、盗贼几种职业)
7、canknockdown(踢罐子,拿球砸罐子,有点意思)
8、where‘smywater?(鳄鱼爱洗澡)
9、三剑之舞(棒子的游戏,类似于地下城与勇士)
10、deathrally(死亡拉力赛,赛车咯)
11、游戏发展国(这个会玩上瘾的,不过很快就通关了,通关后还是可以继续玩)
12、streetball(街头篮球,挺容易的,基本上随便选一个人物都能完爆对手,我每场得分28+,盖帽18个,两双啊,哈哈)
13、skaterboy(滑板游戏)
14、cheesetower(某些网站上排名靠前的游戏,玩了觉得一般般)
好了就这些,还有很多删了都不记得了。
官方网站:点击访问CDN客服QQ:123008公司名:贵州青辞赋文化传媒有限公司域名和IP被墙封了怎么办?用cloudsecre.com网站被攻击了怎么办?用cloudsecre.com问:黑客为什么要找网站来攻击?答:黑客需要找肉鸡。问:什么是肉鸡?答:被控的服务器和电脑主机就是肉鸡。问:肉鸡有什么作用?答:肉鸡的作用非常多,可以用来干违法的事情,通常的行为有:VPN拨号,流量P2P,攻击傀儡,...
触摸云国内IDC/ISP资质齐全商家,与香港公司联合运营, 已超8年运营 。本次为大家带来的是双12特惠活动,美国高防|美国大宽带买就可申请配置升档一级[CPU内存宽带流量选一]升档方式:CPU内存宽带流量任选其一,工单申请免费升级一档珠海触摸云科技有限公司官方网站:https://cmzi.com/可新购免费升档配置套餐:地区CPU内存带宽数据盘价格购买地址美国高防 1核 1G10M20G 26...
819云是我们的老熟人了,服务器一直都是稳定为主,老板人也很好,这次给大家带来了新活动,十分给力 香港CN2 日本CN2 物理机 E5 16G 1T 20M 3IP 240元0官方网站:https://www.819yun.com/ 特惠专员Q:442379204套餐介绍套餐CPU内存硬盘带宽IP价格香港CN2 (特价)E5 随机分配16G1T 机械20M3IP240元/月日本CN2 (...
android游戏源码为你推荐
动易动易系统怎么在线安装飘零网络验证如何在飘零网络验证里面加入成品软件有DLL文件深圳市气象台深圳市天气波粒高清那家是波粒代理或者波粒百万高清代理和波粒视频采集卡代理?智慧充电桩星星充电加速布局充电桩市场 充电桩概念股票有哪些数据库系统概论数据库系统概论的重点是哪些章节?北京移动官网北京移动网上营业厅神州行套餐修改ctf网络安全大赛安全知识竞赛要的队名和口号,有哪些?皮城警备现在皮城警备这区怎么样,?rd640联想thinkserver rd640能不能装win7 64位系统
主机租赁 域名注册使用godaddy 天津服务器租赁 合租服务器 国外bt 北京主机 ibox官网 qq数据库下载 京东商城0元抢购 腾讯实名认证中心 100m独享 福建铁通 100mbps 卡巴斯基免费试用版 双线机房 厦门电信 双线asp空间 移动服务器托管 丽萨 新加坡空间 更多