FLASH游戏之贪吃蛇游戏源代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

scorecommand("allowscale", "false");

fscommand("showmenu", "false");

loadedbytes=0;

total=_root.getBytesTotal();

loadedbytes=_root.getBytesLoaded()

if (loadedbytes==total){nextScene();}

else{bfb=int((loadedbytes/total*100))+"%";}

stop();

fscommand("allowscale", "false");

fscommand("showmenu", "false");

music=new Sound()

music.attachSound("music");

music.stop()

music.start(0,10000)

musicstart=true

onClipEvent(keyDown){

temp=Key.getCode();

if(!keyon){;}

else if(game=="stop" and (temp==189 or temp==109)){ if (speed>1) {

speed--;

rate = speed;}}

else if (game=="stop" and (temp==107 or temp==187)) { if (speed

speed ++;

rate =speed;}

}else if(game<>"start"){enter();

}else if(temp==Key.ENTER){

enter();

}else if (temp == Key.DOWN and y1>=0) {

x1=0;

y1 = 1;

walk();

timestart()

}else if (temp == Key.UP and y1<=0) {

x1=0;

y1 = -1;

walk();

timestart()

}else if (temp == Key.LEFT and x1<=0) {

y1=0;

x1 = -1;

walk();

timestart()

}else if (temp == Key.RIGHT and x1>=0) {

y1=0;

x1 = 1;

walk();

timestart()

}

}

walks=new Sound();

walks.attachSound("walks");

die=new Sound();

die.attachSound("die");

eat=new Sound();

eat.attachSound("eat");

snakebody="snake1";

game="stop";

keyon=true;

startlong = 7;

maxspeed=10;

speed = 4;

time=new Array(0,1000,800,600,400,250,175,100,75,50,30) rate = speed;

function walk() {

x = x+x1;

y = y+y1;

if (x<0 or x>19 or y<0 or y>19) {

gotoAndStop("over");

} else if (map[x][y] == 2) {

eat.start();

body(x, y);

egg();

long++;

score=score+speed;

} else {

map[snake[0]._x/8][snake[0]._y/8] = 0;

if (map[x][y] == 1) {

gotoAndStop("over");

} else {

snake.push(snake[0]);

snake.shift(0);

snake[long-1]._x = x*8;

snake[long-1]._y = y*8;

map[x][y] = 1;

walks.start();

}

}

}

function egg() {

var x2, y2;

x2 = random(20);

y2 = random(20);

while (map[x2][y2] == 1) {

x2 = random(20);

y2 = random(20);

}

map[x2][y2] = 2;

egg2._x = x2*8;

egg2._y = y2*8;

}

function body(x3, y3) {

window.attachMovie(snakebody, "snake"+long,long);

temp=eval("window.snake"+long);

temp._x=x3*8;

temp._y=y3*8;

snake.push(temp);

map[x3][y3] = 1;

}

function enter(){

if(game=="stop"){

stopallsound()

gotoandplay("start");

}else if(game=="pause"){

game="start";

gotoandplay("play");

}else if(game=="start"){

game="pause";

gotoandplay("pause")

}

}

function clear(){

if (long>startlong) {

for (i=0; i<=long; i++) {

snake[i].removeMovieClip();

相关文档
最新文档