Ⅰ 求俄罗斯方块的手机游戏源代码
是俄罗斯方块
但不晓得是不是手机游戏
#include <graphics.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
void draw_block(int x,int y,int style,int way);
void kill_line(int y);
void draw_little_block(int x,int y,int z,int style);
int check_block(int x,int y,int style);
int change(int *i,int *j,int key);
int style1,style,score,speed,l;
int board[10][20];
char str[100];
struct shape
{
int xy[8],next;
};
struct shape shapes[19]= /* 19种方块(前
8个点表示4个小方块的相对位置 第9点表示类型) */
{
{
0,-2, 0,-1, 0, 0, 1, 0, 1
},
{-1, 0, 0, 0, 1,-1, 1, 0, 2},
{ 0,-2, 1,-2, 1,-1, 1, 0, 3},
{-1,-1,-1, 0, 0,-1, 1,-1, 0},
{ 0,-2, 0,-1, 0, 0, 1,-2, 5},
{-1,-1, 0,-1, 1,-1, 1, 0, 6},
{ 0, 0, 1,-2, 1,-1, 1, 0, 7},
{-1,-1,-1, 0, 0, 0, 1, 0, 4},
{-1, 0, 0,-1, 0, 0, 1, 0, 9},
{ 0,-2, 0,-1, 0, 0, 1,-1,10},
{-1,-1, 0,-1, 1,-1, 0, 0,11},
{ 0,-1, 1,-2, 1,-1, 1, 0, 8},
{-1, 0, 0,-1, 0, 0, 1,-1,13},
{ 0,-2, 0,-1, 1,-1, 1, 0,12},
{-1,-1, 0,-1, 0, 0, 1, 0,15},
{ 0,-1, 0, 0, 1,-2, 1,-1,14},
{ 0,-3, 0,-2, 0,-1, 0, 0,17},
{-1, 0, 0, 0, 1, 0, 2, 0,16},
{ 0,-1, 0, 0, 1,-1, 1, 0,18}
};
#define MAPXOFT 9 /* 第1个方块的位置 */
#define MAPYOFT 5
#define MAPXOFT1 18 /* 下一个方块的位置 */
#define MAPYOFT1 17
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
#define ENTER 0x1c0d
int main()
{
int gdriver,gmode,
i,j,key,x0=5,y0=1,m,n,c,key1,p,q,le=0,b;
l=1,score=0;
gdriver=DETECT;
initgraph(&gdriver,&gmode,"D:\\TURBOC2");
randomize();
for(m=0;m<=19;m++)
for(n=0;n<=19;n++)
board[m][n]=0; /* 初始游戏版 */
setcolor(10); /* 开机的画面 */
settextstyle(0,0,3);
outtextxy(10,150,"WELCOME TO RUSSIS");
outtextxy(10,250,"READY GO");
setcolor(14);
settextstyle
(0,0,4);
outtextxy(10,350,"^_^");
/*
circle(400,350,60);
ellipse(370,340,60,120,25,25);
ellipse(430,340,60,120,25,25);
ellipse(400,350,225,315,30,30);*/
getch();
settextstyle(0,0,1);
cleardevice();
setcolor(LIGHTRED); /* 画出游戏所在的范围图
*/
setlinestyle(0,0,3);
setfillstyle(1,14);
rectangle(157,419,533,429);
floodfill(300,424,LIGHTRED);
setcolor(LIGHTRED);
setlinestyle(0,0,3);
setfillstyle(1,14);
rectangle(147,95,157,429);
floodfill(152,200,LIGHTRED);
setcolor(LIGHTRED);
setlinestyle(0,0,3);
setfillstyle(1,14);
rectangle(323,95,333,429);
floodfill(330,320,LIGHTRED);
setcolor(LIGHTRED);
setlinestyle(0,0,1);
setfillstyle(1,BLUE);
rectangle(450,50,500,70);
floodfill(455,55,LIGHTRED);
setcolor(10);
for(m=0;m<=10;m=m+2)
ellipse(240,94,0,180,84+m,84+m);
setcolor(14);
setfillstyle(1,0);
circle(440,330,60);
floodfill(440,330,14);
outtextxy(420,80,"* you can change the game");
/* 对游戏的说明 */
outtextxy(440,90,"-speed and the gradth by"); /*
上为变形 左右 为 调整
下为快下 ESC为退出 */
outtextxy(440,100," using 'up'and'down'.");
outtextxy(420,110,"* when you are plying the");
outtextxy(440,120,"game,you can use these pu");
outtextxy(440,130,"-tturns.");
outtextxy(420,140,"* if you want to go into t");
outtextxy(440,150,"-he game,please 'enter'.");
outtextxy(420,160,"* you can chang shapes ");
outtextxy(440,170," using UP");
outtextxy(420,180,"* RIGHT and LEFT can" );
outtextxy(440,190," move shapes");
outtextxy(10,40,"GAMESPEED:");
outtextxy(10,100,"GRADTH:");
printf("\n\n\n 1");
printf("\n\n\n\n 0");
/* setcolor(LIGHTRED);
setlinestyle(0,0,1);
setfillstyle(1,10);
rectangle(10,65,110,85);
floodfill(15,75,LIGHTRED); */
outtextxy(450,40,"SCORES:");
outtextxy(10,190,"**The speed will");
outtextxy(10,200,"increas if score");
outtextxy(10,210,"increas 3");
for(p=0;p<=100;p++) /* 对速度的调整 */
{ key=bioskey(0);
if(key==ENTER)
break;
if(key==UP)
{
if(l==9)
l=9;
if(l<9)
l++;
}
if(key==DOWN)
{
if(l==1)
l=l;
if(l>1)
l--;
}
gotoxy(2,4);
printf("%d",l);
}
for(q=0;q<=100;q++) /* 对高度的调整 */
{
key=bioskey(0);
if(key==ENTER)
break;
if(key==UP)
{
if(le==5)
le=le;
if(le<5)
le++;
}
if(key==DOWN)
{
if(le==0)
le=le;
if(le>0)
le--;
}
gotoxy(2,8);
printf("%d",le);
}
key=bioskey(0);
if(key==ENTER)
{
style=random(19);
for(m=1;m<=le;m++) /* 具体的对高度的调整 */
{
b=random(7)+1;
for(n=1;n<=10;n++)
{
if(random(2))
{
board[n-1][20-m]=1;
draw_little_block(MAPXOFT+n,MAPYOFT+21-m,1,b);
}
}
}
while(1)
{
while(1)
{
i=x0,j=y0;
style1=random(19);
setcolor(14); /* 画出下一个方
块 */
draw_block(MAPXOFT1,MAPYOFT1,style1,1);
for(j=y0;j<=20;j++)
{
while(1)
{
if(bioskey(1)) /* 方块的
调整 */
{
key=bioskey(0);
change(&i,&j,key);
}
if(!check_block
(i,j+1,style)) /* 判断方块能不能下降 */
break;
if(j==20)
break;
if(speed==1)
{
draw_block
(i,j,style,0); /* 方块的下降 */
j++;
draw_block
(i,j,style,1);
delay(10000);
}
if(speed!=1)
{
m++;
delay
(10000);
if(m>=3*(10-l))
{
m=0;
draw_block
(i,j,style,0); /* 方块的下降 */
j++;
draw_block
(i,j,style,1);
}
}
}
speed=0;
for(m=0;m<=6;m+=2) /* 对有方块的位置给予1
的数值 */
board[i+shapes[style].xy[m]-1]
[j+shapes[style].xy[m+1]-1]=1;
if(board[ i][4]==1)
{
setcolor(14);
settextstyle(0,0,2);
outtextxy(10,450,"CAREFUL -_-");
delay(100000000);
delay(100000000);
setcolor(0);
outtextxy(10,450,"CAREFUL -_-");
settextstyle(0,0,1);
setcolor(LIGHTRED);
}
/* setcolor(LIGHTRED);
setlinestyle(0,0,1);
setfillstyle(1,10);
rectangle(10,65,110,85);
floodfill(15,75,LIGHTRED);*/
if(l==1) /* 显示当前游戏等级 */
{
setcolor(LIGHTRED);
setlinestyle(0,0,1); /* 容易的速度 */
setfillstyle(1,10);
rectangle(10,65,110,85);
floodfill(15,75,LIGHTRED);
outtextxy(7,70," easy speed");
}
if(l==4)
{
setcolor(BLACK);
outtextxy(7,70," easy speed");
setcolor(LIGHTRED); /* 中等难度 */
setlinestyle(0,0,1);
setfillstyle(1,10);
rectangle(10,65,110,85);
floodfill(15,75,LIGHTRED);
outtextxy(7,70," normal speed");
}
if(l==7)
{
setcolor(BLACK);
outtextxy(7,70," normal speed");
setcolor(LIGHTRED);
setlinestyle(0,0,1); /* 困难的难度 */
setfillstyle(1,10);
rectangle(10,65,110,85);
floodfill(15,75,LIGHTRED);
outtextxy(7,70," hard speed");
}
kill_line(j);
if(j==20)
break;
if(!check_block(i,j+1,style))
break;
}
draw_block(MAPXOFT1,MAPYOFT1,style1,0);
/* 对下1个方块显示位置进行覆盖 */
style=style1; /* 使的方块和显示的方块一样
*/
if(j==1) /* 关机的画面 */
{
setcolor(14);
settextstyle(0,0,2);
outtextxy(170,200,"GAME OVER");
outtextxy(170,240,"THANK YOU");
sleep(3);
exit(0);
}
}
}
}
getch();
}
int change(int *i,int *j,int key) /* 方块的具体的变化(
移动 变形 下降) */
{
if(key==UP&&check_block(*i,*j,shapes[style].next)) /*
变形 */
{
draw_block(*i,*j,style,0);
style=shapes[style].next;
draw_block(*i,*j,style,1);
}
else if(key==LEFT&&check_block(*i-1,*j,style)) /* 移动
*/
{
draw_block(*i,*j,style,0);
(*i)--;
draw_block(*i,*j,style,1);
}
else if(key==RIGHT&&check_block(*i+1,*j,style))
{
draw_block(*i,*j,style,0);
(*i)++;
draw_block(*i,*j,style,1);
}
else if(key==DOWN&&check_block(*i,*j+1,style)) /* 下降
*/
{
draw_block(*i,*j,style,0);
(*j)++;
draw_block(*i,*j,style,1);
speed=1;
}
else if(key==ESC) /* 退出 */
exit(0);
}
void draw_block(int x,int y,int style,int way) /* 画出方块
的位置 */
{
int x1=x+MAPXOFT,y1=y+MAPYOFT;
int i;
if(way==1)
{
setcolor(WHITE);
}
else
{
setcolor(BLACK);
}
for(i=0;i<=6;i+=2)
{
draw_little_block(x1+shapes[style].xy[
i],y1+shapes[style].xy[i+1],way,style);
}
}
void draw_little_block(int x,int y,int z,int style) /* 画
出方块的每一个小方块的形状(方块的色彩) */
{ int m,n;
if(z==1) /* 对色彩的调整 */
{
if(0<=style&&style<=3)
n=2;
if(4<=style&&style<=7)
n=3;
if(8<=style&&style<=11)
n=4;
if(12<=style&&style<=13)
n=5;
if(14<=style&&style<=15)
n=6;
if(16<=style&&style<=17)
n=7;
if(style==18)
n=8;
m=1;
}
if(z==0)
{
m=0,n=0;
}
setcolor(m);
setfillstyle(1,n);
rectangle(x*16,y*16,x*16+16,y*16+16);
floodfill(x*16+2,y*16+2,m);
}
void kill_line(int y) /* 消行 */
{
int i,t=1,j,k,color=random(7)+1;
for(;y>=1&&t<=4;y--,t++) /* 对4行进行验证 */
{
for(i=1;i<=10;i++)
if(!board[i-1][y-1]) /* 严整1行的数组是不是全
为1 */
break;
if(i==11)
{
setcolor(LIGHTRED); /* 对积分底色的画法
*/
setlinestyle(0,0,1);
setfillstyle(1,BLUE);
rectangle(450,50,500,70);
floodfill(455,55,LIGHTRED);
score++; /* 每消去1行 可以得1分 */
setcolor(14);
itoa(score,str,10);
outtextxy(460,55,str);
if(score!=0&&score%3==0)
l++; /* 每次分到一定位置是 速度进
行提高(目前是3行加1次 可以调整) */
setcolor(14); /* 每次消去是进行庆祝模式 */
settextstyle(0,0,4);
outtextxy(10,310,"COOL");
outtextxy(10,270,"^_^");
delay(100000000);
delay(100000000);
delay(100000000);
setcolor(BLACK);
settextstyle(0,0,4);
outtextxy(10,310,"COOL");
outtextxy(10,270,"^_^");
settextstyle(0,0,1);
if(score%3==0&&score!=0)
{
setcolor(14);
settextstyle(0,0,2);
outtextxy(10,435,"CONGRATULATION ON YOU ^_^");
sleep(2);
setcolor(BLACK);
settextstyle(0,0,2);
outtextxy(10,435,"CONGRATULATION ON YOU ^_^ ");
settextstyle(0,0,1);
}
for(k=1;k<=10;k++) /* 对满了行进行消去
*/
{
setcolor(BLACK);
draw_little_block
(k+MAPXOFT,y+MAPYOFT,0,2);
}
for(j=y-1;j>=1;j--) /* 消去1行后 用上面的
累下来(并且调整色彩) */
for(k=1;k<=10;k++)
{
board[k-1][j]=board[k-1][j-1];
if(board[k-1][j])
{
setcolor(BLACK);
draw_little_block
(k+MAPXOFT,j+MAPYOFT,0,2);
setcolor(WHITE);
draw_little_block
(k+MAPXOFT,j+1+MAPYOFT,1,color);
}
}
delay(100000000000);
y++;
}
}
}
int check_block(int x,int y,int style) /* 验证能不能往下1
个位置累方块 */
{
int x1=x+MAPXOFT,y1=y+MAPYOFT;
int x2,y2,i;
for(i=0;i<=6;i+=2)
{
x2=x1+shapes[style].xy[ i];
y2=y1+shapes[style].xy[i+1];
if(x2>=10&&x2<20&&y2<26&&(y2<6||board[x2-10][y2-
6]==0))
continue;
else
break;
}
if(i==8)
return 1;
else
return 0;
getch();
}
Ⅱ 谁能给我一个手机游戏的源代码啊
这个地址也有,不过直接给你吧,这样比较好
先给你看看主要的类吧
package Game;
import DreamBubbleMidlet;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.microedition.lci.Graphics;
import javax.microedition.lci.Image;
import javax.microedition.lci.game.GameCanvas;
import javax.microedition.lci.game.LayerManager;
import javax.microedition.lci.game.Sprite;
public class Game extends GameCanvas implements Runnable {
protected DreamBubbleMidlet dreamBubbleMidlet;
protected Graphics g;
protected Image loadingImage;
protected Image pauseImage;
protected Image cursorImage;
protected Image jackStateImage;
protected Image johnStateImage;
protected Image numberImage;
protected Sprite cursor;
protected Sprite number;
protected LayerManager cursorManager;
protected LayerManager numberManager;
protected Hashtable bombTable;
protected Map map;
protected LayerManager gameLayerManager;
protected Role player;
protected Sprite playerGhost;
protected int screenWidth;
protected int screenHeight;
protected int delay = 50;
protected int[][] bornPlace;
protected int chooseIndex;
protected int stageIndex = 1;
protected int gameClock;
protected int loadPercent;
protected boolean isPause;
protected boolean isEnd;
protected boolean isPlaying;
protected boolean isLoading;
protected Thread mainThread;
public Game(DreamBubbleMidlet dreamBubbleMidlet) {
super(false);
this.setFullScreenMode(true);
this.dreamBubbleMidlet = dreamBubbleMidlet;
this.screenWidth = this.getWidth();
this.screenHeight = this.getHeight();
try {
this.loadingImage = Image.createImage("/Game/Loading.png");
this.pauseImage = Image.createImage("/Game/Pause.png");
this.cursorImage = Image.createImage("/Game/Cursor.png");
this.jackStateImage = Image.createImage("/State/JackState.png");
this.johnStateImage = Image.createImage("/State/JohnState.png");
this.numberImage = Image.createImage("/State/Number.png");
} catch (IOException e) {
e.printStackTrace();
}
this.g = this.getGraphics();
}
public void loadStage(int stage) {
this.isEnd = false;
this.isPause = false;
this.isPlaying = false;
this.gameLayerManager = new LayerManager();
this.cursorManager = new LayerManager();
this.numberManager = new LayerManager();
this.bombTable = new Hashtable();
this.cursor = new Sprite(this.cursorImage, 32, 32);
this.number = new Sprite(this.numberImage, 12, 10);
this.loadPercent = 20;
sleep();
loadMap(stage);
this.loadPercent = 40;
sleep();
loadPlayer();
this.loadPercent = 60;
sleep();
this.gameLayerManager.append(map.getBombLayer());
this.gameLayerManager.append(map.getBuildLayer());
this.gameLayerManager.append(map.getToolLayer());
this.gameLayerManager.append(map.getFloorLayer());
this.gameLayerManager.setViewWindow(0, -5, screenWidth,
Global.MAP_HEIGHT + 5);
this.cursorManager.append(cursor);
this.numberManager.append(number);
this.loadPercent = 80;
sleep();
this.loadPercent = 100;
sleep();
isPlaying = true;
}
public void run() {
while (!isEnd) {
long beginTime = System.currentTimeMillis();
this.drawScreen();
long endTime = System.currentTimeMillis();
if (endTime - beginTime < this.delay) {
try {
Thread.sleep(this.delay - (endTime - beginTime));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public void loadMap(int stage) {
switch (stage) {
case 0:
this.map = new Map(Global.MAP_BLOCK);
this.bornPlace = Global.MAP_BLOCK_BORNPLACE;
break;
case 1:
this.map = new Map(Global.MAP_FACTORY);
this.bornPlace = Global.MAP_FACTORY_BORNPLACE;
break;
case 2:
this.map = new Map(Global.MAP_FOREST);
this.bornPlace = Global.MAP_FOREST_BORNPLACE;
break;
case 3:
this.map = new Map(Global.MAP_PIRATE);
this.bornPlace = Global.MAP_PIRATE_BORNPLACE;
break;
case 4:
this.map = new Map(Global.MAP_FAUBOURG);
this.bornPlace = Global.MAP_FAUBOURG_BORNPLACE;
break;
}
}
public void loadPlayer() {
this.player = SingleGameRole.createSingleGameRole(this, Global.JACK,
this.bornPlace[0][0], this.bornPlace[0][1]);
this.gameLayerManager.append(player);
try {
this.playerGhost = new Sprite(Image.createImage("/Character/Jack.png"),
this.player.width, this.player.height);
this.gameLayerManager.append(playerGhost);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void playerUpdate() {
if(!this.player.isAlive)
this.playerGhost.setVisible(false);
this.playerGhost.setFrame(this.player.getFrame());
this.player.updateRole();
}
public void bombUpdate() {
Enumeration enu = this.bombTable.keys();
while (enu.hasMoreElements()) {
String key = (String) enu.nextElement();
Bomb bomb = (Bomb) (bombTable.get(key));
if (bomb.isvisable) {
bomb.update();
} else {
bombTable.remove(key);
bomb = null;
}
}
}
public void mapUpdate() {
this.map.update();
}
public void drawScreen() {
if (gameClock < 10000)
gameClock++;
else
gameClock = 0;
if (!this.isLoading) {
if (!isPause) {
this.operate();
this.bombUpdate();
this.playerUpdate();
this.mapUpdate();
g.setColor(0x000000);
g.fillRect(0, 0, getWidth(), getHeight());
this.drawState();
gameLayerManager.paint(g, 0, this.screenHeight
- Global.MAP_HEIGHT - 5);
} else {
this.drawPauseFrame();
}
} else {
this.drawLoadingFrame();
}
this.flushGraphics();
}
public void drawFailScreen() {
}
public void drawState() {
if (this.player.type == Global.JACK) {
g.drawImage(jackStateImage, 60, 5, Graphics.TOP | Graphics.LEFT);
}
if (this.player.type == Global.JOHN) {
g.drawImage(johnStateImage, 60, 5, Graphics.TOP | Graphics.LEFT);
}
this.number.setFrame(this.player.bombNums);
this.numberManager.paint(g, 101, 15);
this.number.setFrame(this.player.speed);
this.numberManager.paint(g, 133, 15);
this.number.setFrame(this.player.power);
this.numberManager.paint(g, 165, 15);
}
protected void drawPauseFrame() {
g.setColor(0x000000);
g.fillRect(0, 0, getWidth(), getHeight());
this.drawState();
if (gameClock % 5 == 0)
this.cursor.setFrame((this.cursor.getFrame() + 1) % 4);
this.gameLayerManager.paint(g, 0, this.screenHeight - Global.MAP_HEIGHT
- 5);
this.cursorManager.paint(g, screenWidth / 2 - pauseImage.getWidth() / 2
- 32, screenHeight / 2 - pauseImage.getHeight() / 2
+ this.chooseIndex * 33 + 24);
g.drawImage(pauseImage, screenWidth / 2, screenHeight / 2,
Graphics.HCENTER | Graphics.VCENTER);
}
protected void drawLoadingFrame() {
g.setColor(66, 70, 246);
g.fillRect(0, 0, screenWidth, screenHeight);
g.drawImage(loadingImage, screenWidth / 2, 2 * screenHeight / 5,
Graphics.HCENTER | Graphics.VCENTER);
g.setColor(0, 255, 0);
g.fillRect((screenWidth - 120) / 2, 2 * screenHeight / 3,
(this.loadPercent * 120) / 100, 10);
g.setColor(255, 0, 0);
g.drawRect((screenWidth - 120) / 2, 2 * screenHeight / 3, 120, 10);
}
public void showMe() {
new Loading(this.stageIndex);
if (this.mainThread == null) {
mainThread = new Thread(this);
mainThread.start();
}
this.dreamBubbleMidlet.show(this);
}
public void operate() {
int keyStates = getKeyStates();
this.playerGhost.setPosition(this.player.xCoodinate, this.player.yCoodinate);
if ((keyStates & DOWN_PRESSED) != 0) {
this.player.walk(Global.SOUTH);
} else {
if ((keyStates & UP_PRESSED) != 0) {
this.player.walk(Global.NORTH);
} else {
if ((keyStates & RIGHT_PRESSED) != 0) {
this.player.walk(Global.EAST);
} else {
if ((keyStates & LEFT_PRESSED) != 0) {
this.player.walk(Global.WEST);
}
}
}
}
}
protected void keyPressed(int key) {
if (!this.isPlaying)
return;
if (!this.isPause && key == -7) {// 右键
this.chooseIndex = 0;
this.pauseGame();
return;
}
if (key == 35) {// #键
this.nextStage();
return;
}
if (key == 42) {// *键
this.preStage();
return;
}
if (this.isPause) {
switch (key) {
case -1:
case -3:
if (this.chooseIndex == 0)
this.chooseIndex = 2;
else
this.chooseIndex = (this.chooseIndex - 1) % 3;
break;
case -2:
case -4:
this.chooseIndex = (this.chooseIndex + 1) % 3;
break;
case -5:// 确认键
case -6:// 左软键
switch (chooseIndex) {
case 0:
this.continueGame();
break;
case 1:
this.restart();
break;
case 2:
this.endGame();
break;
}
break;
default:
break;
}
} else {
switch (key) {
case 53:
case -5:// 确认键
this.player.setBomb(this.player.getRow(), this.player.getCol());
break;
}
}
}
public void restart() {
new Loading(this.stageIndex);
}
public void continueGame() {
this.isPause = false;
this.player.play();
}
public void pauseGame() {
this.isPause = true;
this.player.stop();
}
public void endGame() {
this.isEnd = true;
this.mainThread = null;
System.gc();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.dreamBubbleMidlet.menu.showMe();
}
public void nextStage() {
if (this.stageIndex < 4) {
this.stageIndex++;
}
new Loading(this.stageIndex);
}
public void preStage() {
if (this.stageIndex > 0) {
this.stageIndex--;
}
new Loading(this.stageIndex);
}
class Loading implements Runnable {
private Thread innerThread;
private int stageIndex;
public Loading(int stageIndex) {
this.stageIndex = stageIndex;
innerThread = new Thread(this);
innerThread.start();
}
public void run() {
isLoading = true;
loadPercent = 0;
System.gc();
loadStage(stageIndex);
isLoading = false;
}
}
public void sleep() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这个是游戏主体类
下面是游戏的人物类
package Game;
import javax.microedition.lci.Image;
import javax.microedition.lci.game.Sprite;
public abstract class Role extends Sprite {
/**
* 人物的基本属性
*/
protected int type;
protected int xCoodinate;
protected int yCoodinate;
protected int row;
protected int col;
protected int width;
protected int height;
protected int speed;
protected int status;
protected boolean isCanOperate = false;
protected boolean isAlive = true;
/**
* 人物放置炸弹的基本属性
*/
protected int power;
protected int bombNums;
protected int characterClock = 0;
protected int deadTime = 0;
protected Game game;
protected Role(Image image, int width, int Height, Game game) {
super(image, width, Height);
this.game = game;
}
/**
* 人物拾起道具
* @param tool
*/
public abstract void pickupTool(int tool);
/**
* 碰撞检测以及坐标的改变,如果对行走条件有特殊需求,既可以在这里写自己的条件
* @param direction
*/
public abstract void collisionCheck(int direction);
public void updateRole() {
if (this.characterClock < 10000) {
this.characterClock++;
} else {
this.characterClock = 100;
}
int row = this.getRow();
int col = this.getCol();
if (this.isAlive) {
int tool = this.game.map.getToolLayer().getCell(col, row);
if (tool > 0) {
this.pickupTool(tool);
this.game.map.getToolLayer().setCell(col, row, 0);
}
if (this.game.map.hasFeature(row, col, Global.DEADLY)) {
this.isAlive = false;
return;
}
if (this.status == Global.BORN
&& this.characterClock > Global.BORN_TIME) {
this.status = Global.SOUTH;
this.setFrame(Global.SOUTH * 6);
this.isCanOperate = true;
}
if (this.status == Global.BORN) {
if (this.characterClock % 2 == 0)
this.setFrame(Global.BORN * 6 + (this.getFrame() - 1) % 4);
return;
}
} else {
this.isCanOperate = false;
if (this.deadTime <= 20) {
this.deadTime++;
} else {
this.deadTime = 100;
this.setVisible(false);
return;
}
if (this.characterClock % 2 == 0) {
if (this.getFrame() < Global.DEAD * 6) {
this.setFrame(Global.DEAD * 6);
} else {
if (this.getFrame() < 29) {
this.setFrame(this.getFrame() + 1);
} else {
if (this.characterClock % 4 == 0) {
this.setFrame(29);
this.setVisible(true);
} else {
this.setVisible(false);
}
}
}
}
}
}
public void walk(int direction) {
if (!isAlive)
return;
if (!isCanOperate)
return;
if(direction==9) return;
this.collisionCheck(direction);
if (this.characterClock % 2 == 0) {
if (this.status == direction) {
this.setFrame(this.status * 6 + (this.getFrame() + 1) % 6);
} else {
this.status = direction;
this.setFrame(this.status * 6);
}
}
this.setPosition(xCoodinate, yCoodinate);
}
public void stop() {
this.isCanOperate = false;
}
public void play() {
this.isCanOperate = true;
}
public abstract void setBomb(int row, int col);
public void increaseBomb() {
if (this.bombNums < Global.MAX_BOMB_NUMBER)
this.bombNums++;
}
public int getRow() {
return getRow(getBottomY(yCoodinate) - Global.MAP_CELL / 2);
}
public int getCol() {
return getCol(xCoodinate + Global.MAP_CELL / 2);
}
protected int getBottomY(int y) {
return y + this.height - 1;
}
protected int getRightX(int x) {
return x + Global.MAP_CELL - 1;
}
protected int getPreY(int y) {
return getBottomY(y) + 1 - Global.MAP_CELL;
}
protected int getRow(int x) {
return x / Global.MAP_CELL;
}
protected int getCol(int y) {
return y / Global.MAP_CELL;
}
}
我的QQ是609419340
看不明白的可以随时来问我哦,还可以当时传给你撒
Ⅲ 求:手机软件源代码!
其实这里有很多的:
[gnokii-0.3.2.tar.gz]
Nokia手机工具程序。可以管理手机的电话薄,发送/接收短消息,查看电池状态等 (2001-02-14, UNIX, 731KB, 2130次)
[smslink-0.44b.tar.gz]
手机短消息服务的服务器和客户端 (2001-01-08, LINUX, 91KB, 1883次)
[移动短信SMS综合资料库.rar]
短消息基础知识;短消息的信息处理流程及其分析、解决问题的方法;手机短信息SMS开发—编码,解码;PDU介绍;短消息的体系结构等 (2005-09-28, CHM, 1009KB, 1536次)
[nle-0.0.1-2.tgz]
可以修改Nokia手机的logo图标的程序 (2001-02-14, LINUX, 21KB, 1442次)
[是男人就下一百层SHY.rar]
制作的第一款休闲类的手机游戏,适合初学者参考 (2005-06-15, Java, 484KB, 1357次)
[sms_client-2.0.7k.tgz]
使用TAP的蜂窝型GSM手机短消息服务中心 (2001-01-08, LINUX, 82KB, 1333次)
[mobile_sms.zip]
使用手机发送短消息的编程方法 (2001-11-21, HTML, 5KB, 1174次)
[kvanttisms-src-0.5.tgz]
Java写的通过手机收发短信息的程序。 (2001-11-20, Java, 10KB, 1049次)
[BREW开发-海信(王宏兵).rar]
深入研究BREW手机游戏开发———— 王洪信开发者最好的初学资料 (2005-09-26, Visual C++, 7229KB, 841次)
[jSMSEngine_2_0_4.zip]
开源的手机短信开发包!包括例子程序和比较详细的文档,还有开发者的网站!来源于sourceforge! (2006-01-21, Java, 438KB, 729次)
[qrcode_js.zip]
手机内嵌二维条码图像识别的JAVA的源程序,强烈推荐下载。 (2006-01-14, Java, 2210KB, 677次)
[gprs_sms.zip]
一个用COM或USB接口连接gsm/gprs手机进行短信收发的程序,用到的是simense的通讯模块 (2003-02-20, Visual C++, 97KB, 629次)
[PaoPao.rar]
j2me手机泡泡龙游戏。写得不错还未完工的版本。不过可以用来学习。 (2005-03-04, Java, 83KB, 613次)
[MakeMap.rar]
用java写的地图编辑器,可用于j2me手机游戏的地图编辑。 (2005-03-04, Java, 26KB, 606次)
[J2mebox.rar]
一个类似打地鼠的j2me手机游戏。 (2005-03-04, Java, 58KB, 521次)
[shoujihaomachaxun.rar]
输入手机号码可查询:归属地址、手机号码、区号、所属卡型 (2006-06-05, Java, 686KB, 520次)
[rich_man+src.rar]
大富翁手机游戏。 (2005-03-04, Java, 269KB, 513次)
[gsmssend-1.6.tar.gz]
通过网站发送手机短信息的程序。需要GNOME/GTK支持 (2001-11-20, LINUX, 352KB, 498次)
[MTKstart.rar]
台湾联发(MTK)手机芯片资料,可作为手机应用的平台 (2007-08-09, C-C++, 118KB, 495次)
[C# 发短信.rar]
使用C#发短信,连接Modem或者手机,通过串口发送短信, (2004-06-30, CSharp, 437KB, 469次)
[WindowsMobile5.0.rar]
Windows Mobile 5.0 三十几个经典手机软件开发源码希望对大家有帮助. (2006-08-30, CSharp, 578KB, 449次)
[motorola_RingerToneFormat.zip]
motorola手机铃声格式文档 (2002-06-07, PDF, 45KB, 445次)
[ksiemens-0.1.tar.gz]
KDE下的西门子手机管理程序,如图标,电话薄,短信息等管理 (2001-11-21, LINUX, 3437KB, 444次)
[nec麻将.rar]
一个java编的小游戏.对初学手机游戏编程的人很有用啊. (2005-06-07, Java, 50KB, 434次)
[nokiacomposer.src.zip]
Nokia手机语音管理程序,如上载音乐等。 (2001-11-21, Visual C++, 315KB, 422次)
[SmartMessagingFAQ.zip]
诺基亚手机图片铃声开发文档 (2002-06-07, PDF, 23KB, 410次)
[motolora_smscertguide.zip]
motorola手机短信息开发文档 (2002-06-07, PDF, 134KB, 400次)
[MV100-0.1.rar]
是一个手机功能的模拟程序,从界面到功能都做了很好的模拟 (2005-07-29, C-C++, 14630KB, 384次)
[helix.src.0812.rar]
着名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码,内含编译工具、以及配套相关软件:WinCVS、Python等。花了近一个多月才整理完成,是非常难得的全套代码。 (2005-05-19, C++, 43787KB, 373次)
[eluosi方块.rar]
经典的手机游戏源码俄罗斯方块,基于C+Brew开发 (2005-07-14, C-C++, 425KB, 373次)
[MTK2.rar]
这是我上传MTK手机开发的一些资料2,这两天起上传6份资料,全部是手开发的。希望对你们有用。 (2007-04-13, C-C++, 5859KB, 371次)
[resource]
压缩包中一个为一般操作系统下的fft,一个是手机或类似设备中的T9拼音输入法 (2003-08-05, C-C++, 53KB, 359次)
[SeaHorse.rar]
手机游戏,画面效果还可以,可以作为手机游戏入门参考 (2005-06-15, Java, 273KB, 356次)
[nec 打飞机.rar]
一个JAVA编的小游戏,对初学手机游戏的人很有帮助. (2005-06-07, Java, 73KB, 335次)
[多级菜单.rar]
/*[原创]一个树形多级菜单参考程序 这是一个用于车载电话的菜单程序,可以看成是手机功能菜单的简化板. 我所认为的树形多级菜单是指:在一个父菜单项目下面有多个子菜单, 子菜单下面又有多个孙菜单...,进入下层菜单主要依*当前选中的索引.有点象文件的目录结构. 本木从前实现这类的菜单主要*分层的switch语句,每层都是一个switch.但当我看到晓奇大侠的 程序和耳朵灌满lq等人的争论后,那时那地,我的心境变化了,我意识到指针代表了先进的生产力, 代表了社会的发展方向,是建设和谐社会的必要条件.不管你用了多长时间C语言,只要你不善于用 一个小针指来指去,你就是那种"用嘴吃饭的高贵骑士,决不用屁股装弹步枪"的守旧分子和社会发 展的绊脚石.(跑题太远,删去1万字...打住) .言归正传,下面的程序适用CPU为Mega16,编译器为CVAVR 1.24.4a 由于按键数目较多,所以按键程 序把按键事件分为数字键,快捷键,确认键,取消键,上下翻键几类,以减小菜单结构的容量.一下菜单 数据在菜单结构数组中的偏移量,有多少个菜单象就有多少个宏定义*/ (2005-08-02, C-C++, 2KB, 334次)
[与小灵通讯的软件.zip]
手机的通讯,特别是小灵通的通讯,是非常难得的技术,也是很受欢迎的,快下啊! (2005-09-30, Visual C++, 39KB, 324次)
[C16汉字输入方案.rar]
“C16汉字输入方案”,是针对小键盘设备(如手机、遥控器等)通常为16个基本键(“0”到“9”、“*”、“#”、左右键、删除键、确认键)的情况,充分发掘16个键位条件下进行汉字输入和符号输入的潜力,使汉字、英文、数字输入达到尽可能高的效率,是在16键的小键盘设备进行汉字输入的优秀方案。 (2005-10-27, C++ Builder, 76KB, 316次)
[CDMA短消息发送程序.zip]
用vc开发的cdma手机模块收发短信的功能,主要部分是串口通信和gb->unicode码间的转换。 (2005-12-08, Visual C++, 193KB, 313次)
Ⅳ 求一个安卓开发小游戏源代码,临时交作业用
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;i<row;i++){
canvas.drawLine(10, 50+i*stepLength, 10+(col-1)*stepLength, 50+i*stepLength, paint);
}
for(int i=0;i<col;i++){
canvas.drawLine(10+i*stepLength,50,10+i*stepLength,50+(row-1)*stepLength, paint);
}
for(int r=0;r<row;r++){
for(int c=0;c<col;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(r<0 || r>row-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<row && c>=0 && c<col && r+x>=0 && r+x<row && c+y>=0 && c+y<col && chess[r][c] == chess[r+x][c+y]){
count++;
if(y>0){
c++;
}else if(y<0){
c--;
}
if(x>0){
r++;
}else if(x<0){
r--;
}
}
while(a>=0 && a<row && b>=0 && b<col && a-x>=0 && a-x<row && b-y>=0 && b-y<col && chess[a][b] == chess[a-x][b-y]){
count++;
if(y>0){
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拼图游戏源码
主界面开始之前,可以在该按钮选择附加选项,代表意义是:是否开始声音、是否继续上次最后玩的拼图、是否随机选择一幅拼图。
菜单,可分类管理:在列表右侧,可上下拖动排序;在列表左侧,可长按分类的更新、添加、删除操作,可选择媒体库(sdcard 里图片)玩拼图。
列表界面图片,可跳到拼图界面。
长按图片,可以下操作:
开始 + 完成赠言,那么在完成拼图后,会显示您为该图片设置的赠言,这个功能只要是为了,当您想找别人玩您指定的拼图,当别人完成时可以看到您设置的赠言,增加些乐趣。
开始 + 比赛,那么您就可以和别人一起来玩拼图比赛(两幅同样的图同样的玩法设置),赛事完成后,会统计你们的各自所走的步数和用时。
改变分类,可对该图分类改变操作。
删除,可删除该图。
拆散关卡类,可对是关卡类的图拆散操作。
菜单,可以下操作:
分类筛选,快速找到该分类拼图。
操作选择,必须先选择图片,然后可以将选择的图片改变分类、组成关卡类、删除操作。
排序操作,当排序后,可图片列表的图片排序:先一张图片,然后再另一张图片,那么这两张图片就会互换位置,从而达到排序效果。
拼图界面菜单,可玩法设置。左右滑动可对照完整拼图。
Ⅵ 开发手游的代码
4.1游戏的的思路、构想
4.1.1游戏想法的产生
相信大家一定都在8位机机上玩过《冒险岛》这款游戏,非常有趣味性。
游戏中玩家通过不断的闯关,来解救公主。在每个关都很很多的怪物阻挡着你,所以需要运用各种机关或者秘籍来杀死它们。杀死他们的同时还可以获得各种奖励,加生命,加血等,增加了游戏的趣味性。
如图2所示:
这款《冒险岛》游戏的实现相对于其他RPG或者网络版手机游戏稍简单一些,适合初学者作为练习,所以我决定编写一款类似的手机游戏。
由于之前对手机游戏的编程知识以及游戏的设计只有初步的了解,因此,我们在游戏的构架和思路上经历了几个阶段。
这款《冒险岛》游戏的实现相对于其他RPG或者网络版手机游戏稍简单一些,适合初学者作为练习,所以我决定编写一款类似的手机游戏。
由于之前对手机游戏的编程知识以及游戏的设计只有初步的了解,因此,我们在游戏的构架和思路上经历了几个阶段。
4.1.2对游戏设计的初步认识
刚开始我们只对J2ME有初步的了解。这时我们只是模仿之前在PC上看到的游戏,用语言把游戏的实现感性的描述为几大部分:
游戏界面系统:包括游戏开始界面;游戏开局界面;游戏运行界面;游戏结束界面。
游戏元素:菜单类;画布类;人物类;排行榜类。
4.1.3模块成型阶段
在进一步熟悉了J2ME知识后,对框架做出了一些修改,逐步把游戏的基本功能确定。游戏依次进入加载界面;主菜单;游戏运行界面;游戏结束界面。
具体实现的功能为:
1.主菜单,有如下选项:
(1)开始游戏——进入游戏界面。
(2)声音——设置声音的有无选项。
(3)帮助——介绍游戏的玩法。
(4)排行榜——玩家所得分数的排行榜。
(5)关于——用来显示说明信息以及背景图片。
2.游戏运行界面,包括:
游戏界面;目前游戏得分;游戏关数;生命次数;
3.游戏结束界面:游戏结束后,显示一行说明信息,然后退回到菜单。
游戏的主要模块为:
1.游戏主MIDlet(GameMIDlet)——对游戏生命周期的判断;对画布类的调用;管理游戏程序中各个屏幕之间的转换。
2.游戏画布(MyGame)——对游戏所用变量,常量的设定;游戏的初始化;游戏中精灵运动轨迹的控制;精灵与砖块的碰撞检测以及砖块状态的控制;游戏中各关卡的基本设定;游戏中对按键状态的处理。
3.菜单类——游戏中菜单事件的处理。
4.GameOgre类——游戏中怪物的类。
5.GamePlayer类——玩家控制的精灵类。
6.GameRMS类——用于实现分数排行榜。
7.PlayMusic类——用于实现音乐的播放。
8.MySet类——声音大小的设置。
4.2 程序的类结构
程序一共有8个主要类,其中菜单类负责各个屏幕的切换。程序的类结构如图3所示:
4.3 游戏的流程图
进入游戏菜单。初始情况下,游戏菜单有5个选项,它们分别是开始游戏、游戏说明和排行榜、设置、关于。选择开始新游戏则进入游戏,在游戏中如果按下非游戏键则中断游戏返回菜单,此时菜单中增加了一个继续游戏的选项,可以返回游戏也可以重新开始新的游戏。在菜单中选择游戏说明或者高分记录,则进入相应的屏幕,他们都能用“后退”软键返回菜单。菜单中的退出选项用于退出程序。游戏的流程如图4所示:
4.4.1主类GameMIDlet的实现
MIDlet是最核心的类。MIDlet程序有三种状态:
1.暂停状态
2.运行状态
3.销毁状态
J2ME程序都是从MIDlet类开始执行,系统在执行MIDlet程序时,首先构造一个MIDlet类型的对象,然后使程序进入到暂停状态,按照生命周期的规定,系统会自动调用MIDlet对象的startApp方法使程序进入到运行状态,开始程序的执行。
下图是运行时显示的画布对象:
首先,先要创建MIDlet类型的对象,下面我们来看对象的构造方法:
//主程序构造方法
public GameMIDlet()
{
rs = null;
RecordName = “GameRMS”;
GameMenu.display = Display.getDisplay(this) ;
GameMenu.midlet = this;
}
java
开发语言
oppo手机型号及价格
精选推荐
广告
JAVA基于J2ME的手机游戏开发(文档+源代码).zip
0下载·0评论
2022年1月27日
JAVA基于J2ME的手机游戏开发免费
717阅读·0评论·0点赞
2022年8月23日
JAVA五子棋手机网络对战游戏的设计与实现(源代码+论文)
568阅读·2评论·0点赞
2022年12月5日
J2ME手机游戏引擎程序结构简述
170阅读·0评论·0点赞
2021年9月12日
最新45款Java手机游戏开发源代码免费下载
10下载·0评论
2019年3月4日
经典50个Java手机游戏源码.7z
3下载·0评论
2022年7月8日
无敌版游戏下载
精选推荐
广告
java手机小游戏源码_Java手机版数独小游戏(J2me)JAVA游戏源码下载
435阅读·0评论·0点赞
2021年3月14日
java 300行代码 冒险闯关小游戏(代码+讲解)
2637阅读·1评论·6点赞
2022年9月9日
java俄罗斯方块代码_【俄罗斯方块java】分享一个Java写的俄罗斯方块源码 算法简单(300行) 注释详细!...
304阅读·0评论·0点赞
2021年3月5日
java小游戏源码_分享几款java小游戏源码
4921阅读·0评论·4点赞
2021年3月5日
java手机游戏开发如何_用JAVA开发手机游戏需要如何构建开发环境?
1209阅读·0评论·0点赞
2021年2月26日
《精通Java手机游戏与应用程序设计》源码
35阅读·0评论·0点赞
2022年3月24日
java怎么制作游戏,看完这篇彻底明白了
4803阅读·0评论·2点赞
2021年6月29日
泡泡堂代码 JAVA_Java手机游戏泡泡堂源码
566阅读·0评论·1点赞
2021年3月14日
十款经典游戏的Java版本(开源)
19.0W阅读·95评论·214点赞
2014年12月7日
飞翔的小鸟--Java小游戏实战(代码完整)
1.1W阅读·13评论·50点赞
2021年4月5日
Vue——获取后端json数据中的URL并通过按钮跳转到此URL
1683阅读·4评论·0点赞
2021年2月5日
java安卓游戏源码下载_77个安卓游戏 android源码
801阅读·0评论·0点赞
2021年3月15日
去首页
看看更多热门内容
Ⅶ 手机游戏源代码是什么,怎么使用
不知道你玩的啥游戏,但是看样子估计是c++代码,我英文学的不好
从英文描述中我猜测这是v c++的代码,“//”在代码中表示注释,前三行是注释,其大意如下:
stdafx.cpp :源文件,包括刚才的标准单元?
fixyou.pch将是预编译的标题
stdafx.obj将包含预编译的类型信息
“cpp”明显是c++源码文件的缩写名,而最后一行是头文件。
所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样快编译速度,节省时间。
预编译头文件通过编译stdafx.cpp生成,以工程名命名,由于预编译的头文件的后缀是“pch”,所以编译结果文件是projectname.pch。
编译器通过一个头文件stdafx.h来使用预编译头文件。stdafx.h这个头文件名是可以在project的编译设置里指定的。编译器认为,所有在指令#include "stdafx.h"前的代码都是预编译的,它跳过#include "stdafx. h"指令,使用projectname.pch编译这条指令之后的所有代码。
因此,所有的CPP实现文件第一条语句都是:#include "stdafx.h"。
其实我学的pascal,所以对c++了解的少,如果你真的想学会他,还是自己找几本c++的书学一下,这样才能“使用”代码得心应手。
Ⅷ 手机如何自己编程做游戏
如果你有兴趣在android上设计一些游戏,那么我这儿有一些对你有所帮助的东西,我是android Market上一个名为LightRacer的小赛车游戏的开发者,虽然在此之前我也曾开发过游戏,但这仍然是我的第一个android上的应用,在这个过程中我学到了很多在android上开发游戏的经验,并且,我也很乐意将这一切与你分享。好了,让我们开始吧,如果你之前做过游戏的开发,那么转移到android这样的移动平台上并不是件难事,你要做的只是学习一下新的架构与API,如果你是一个新手,我这儿也为你准备了一个入门清单,它适用于任何类型的游戏开发,比如动作类、策略类、模拟类或者智力类。
开启分步阅读模式
操作方法
01
在这门课最后,你会完成一个可以运行在安卓机或者安卓平板上的游戏。你可以与你的家人朋友分享它,用你的新知识进一步改进你的游戏,或者完全自己创造一个游戏。
02
如果你有兴趣在android上设计一些游戏,那么我这儿有一些对你有所帮助的东西,我是android Market上一个名为LightRacer的小赛车游戏的开发者,虽然在此之前我也曾开发过游戏,但这仍然是我的第一个android上的应用,在这个过程中我学到了很多在android上开发游戏的经验,并且,我也很乐意将这一切与你分享。好了,让我们开始吧,如果你之前做过游戏的开发,那么转移到android这样的移动平台上并不是件难事,你要做的只是学习一下新的架构与API,如果你是一个新手,我这儿也为你准备了一个入门清单,它适用于任何类型的游戏开发,比如动作类、策略类、模拟类或者智力类。
03
获取SDK第一步当然是下载并安装android的SDK[软件开发套件],这套SDK主要包括有核心库文件,一个模拟器,开发工具和一些示范的样例文件。我强烈推荐你使用 Eclipse 和 android eclipse 扩展。如果你只是使用android,Eclipse IDE就已经足够了,但如果这是你第一次开发Java应用,建议你还是下载完整的
04
学习应用架构就像迷人的内在美一样,这是理解
android 应用架构的关键,如果你不学习它,你设计出来的游戏将是一种很难修复bug的产品。你需要了解应用程序、活动、Intents以及它们是如何互相联系交互的,Google在这儿提供了良好的信息架构。真正重要的是,你要理解为什么在你设计的游戏中需要不止一个的活动进程以及如何设计一个用户体验良好的游戏。这些都应当配合到应用的生命周期中。
05
学习应用的生命周期应用的生命周期是由AndroidOS操作系统进行管理的,你的活动进程都将做为系统命令进行创建,正确处理这些事件对一个应用程序来说是极为重要的,因为终端用户不会知道什么是正确的。最好在开始设计你的游戏之前搞明白这些,因为这有助于节省你的调试时间以及避免代价高昂的重新设计。
06
对大多数应用而言,默认设置即可开始工作,但对游戏而言,你可能需要调整单态实例的信号为打开。在默认情况下,Android会新建一个活动实例进程,因为它认为这是比较合适的,而游戏,你可能只希望有一个活动的实例进程,这有一点儿影响,它需要你了解一些系统状态的管理,但对我来说,它解决了资源管理的问题,还是值得的。
07
主循环是否需要一个主循环是根据你写的游戏类型而决定的,如果你写的游戏没有时间依赖性或者只是响应用户的输入而没有其它的视觉变化,你可能并不需要一个主循环。如果你设计的是一个平面的动作游戏或者动画游戏,计时游戏或者其实类型的自动游戏,你就应该认真考虑使用主循环。