導航:首頁 > 源碼編譯 > 自己在手機做游戲源碼

自己在手機做游戲源碼

發布時間:2023-03-05 09:53:24

Ⅰ 求俄羅斯方塊的手機游戲源代碼

是俄羅斯方塊
但不曉得是不是手機游戲

#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 里圖片)玩拼圖。

列表界面圖片,可跳到拼圖界面。

長按圖片,可以下操作:

  1. 開始 + 完成贈言,那麼在完成拼圖後,會顯示您為該圖片設置的贈言,這個功能只要是為了,當您想找別人玩您指定的拼圖,當別人完成時可以看到您設置的贈言,增加些樂趣。

  2. 開始 + 比賽,那麼您就可以和別人一起來玩拼圖比賽(兩幅同樣的圖同樣的玩法設置),賽事完成後,會統計你們的各自所走的步數和用時。

  3. 改變分類,可對該圖分類改變操作。

  4. 刪除,可刪除該圖。

  5. 拆散關卡類,可對是關卡類的圖拆散操作。

菜單,可以下操作:

  1. 分類篩選,快速找到該分類拼圖。

  2. 操作選擇,必須先選擇圖片,然後可以將選擇的圖片改變分類、組成關卡類、刪除操作。

  3. 排序操作,當排序後,可圖片列表的圖片排序:先一張圖片,然後再另一張圖片,那麼這兩張圖片就會互換位置,從而達到排序效果。

拼圖界面菜單,可玩法設置。左右滑動可對照完整拼圖。

Ⅵ 開發手游的代碼

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
主循環是否需要一個主循環是根據你寫的游戲類型而決定的,如果你寫的游戲沒有時間依賴性或者只是響應用戶的輸入而沒有其它的視覺變化,你可能並不需要一個主循環。如果你設計的是一個平面的動作游戲或者動畫游戲,計時游戲或者其實類型的自動游戲,你就應該認真考慮使用主循環。

閱讀全文

與自己在手機做游戲源碼相關的資料

熱點內容
程序員可以干什麼 瀏覽:70
績效考核權重分配演算法 瀏覽:524
android應用logo 瀏覽:898
光遇安卓服墓土商店什麼時候開 瀏覽:566
月收益翻倍的源碼 瀏覽:636
asop源碼放在哪裡 瀏覽:988
電腦伺服器密碼怎麼找 瀏覽:574
jdp轉換pdf 瀏覽:749
把pdf導入iphone 瀏覽:508
米哈游租賃的雲伺服器是哪個 瀏覽:524
android直接打電話 瀏覽:1016
ubuntu停止命令 瀏覽:283
cnc攻絲編程 瀏覽:869
換個手機號碼app怎麼注冊 瀏覽:320
怎麼下載小猴口算app 瀏覽:115
輕鏈app的貨怎麼樣 瀏覽:625
電腦里的u盤如何加密 瀏覽:370
我的世界全部版本伺服器下載地址 瀏覽:50
交換原理pdf 瀏覽:229
菜鳥驛站app怎麼邀請新人 瀏覽:448