制作坊(搬运贴)Flapy-bird(就是那个童年玩的蹦蹦蹦穿障碍的小鸟) 专区

(搬运贴)Flapy-bird(就是那个童年玩的蹦蹦蹦穿障碍的小鸟)

8202922862019-05-17 1557人围观
简介直接搬运的游戏代码,文件我每次都发不上来,祝你们玩的愉快,我读透了会发一贴解释的。我只是个游戏的搬运工哈哈哈

简单介绍一下操作,A+B键开始,开始后按A或者B键可以使小鸟上升,每前进一格小鸟会

下降一格,把握好不要使小鸟撞到柱子,游戏结束会显示一个骷髅头,此时按A+B可以重新开始,下面上代码:

let r_new = 0

let show_3 = 0

let math = 0

let show_2 = 0

let show_4 = 0

let x_4 = 0

let y_3_1 = 0

let show_1 = 0

let x_3 = 0

let y_4_1 = 0

let y_3_0 = 0

let x_2 = 0

let y_4_0 = 0

let x_1 = 0

let y_2_1 = 0

let show_0 = 0

let x_0 = 0

let r_org = 0

let y_2_0 = 0

let y_1_1 = 0

let car_y = 0

let car_x = 0

let y_0_1 = 0

let y_1_0 = 0

let score = 0

let y_0_0 = 0

let flag_a_key = 0

let play_start = 0

input.onButtonPressed(Button.AB, function () {

if (play_start == 0) {

music.beginMelody(music.builtInMelody(Melodies.Entertainer), MelodyOptions.Once)

play_start = 1

}

})

input.onButtonPressed(Button.A, function () {

if (play_start == 1) {

flag_a_key = 0

led.unplot(car_x, car_y)

car_y += -1

if (car_y < 0) {

car_y = 0

}

led.plot(car_x, car_y)

basic.pause(200)

flag_a_key = 1

}

})

input.onButtonPressed(Button.B, function () {

if (play_start == 1) {

flag_a_key = 0

led.unplot(car_x, car_y)

car_y += -1

if (car_y < 0) {

car_y = 0

}

led.plot(car_x, car_y)

basic.pause(200)

flag_a_key = 1

}

})

function game_over_fun2() {

play_start = -1

music.beginMelody(music.builtInMelody(Melodies.Punchline), MelodyOptions.Once)

basic.showLeds(`

       . . . . .

       . . . . .

       . . . . .

       . . . . .

       . . . . .

       `)

basic.showNumber(score)

basic.pause(500)

}

led.setBrightness(80)

score = 0

play_start = 0

car_y = 0

car_x = 0

x_0 = 0

x_1 = 1

x_2 = 2

x_3 = 3

x_4 = 4

show_4 = 1

flag_a_key = 1

r_org = Math.randomRange(0, 4)

if (r_org == 4) {

y_4_0 = r_org - 1

y_4_1 = r_org

} else {

y_4_0 = r_org

y_4_1 = r_org + 1

}

while (play_start == 0) {

basic.showIcon(IconNames.Pitchfork)

basic.showLeds(`

       . . . . .

       . . . . .

       . . . . .

       . . . . .

       . . . . .

       `)

}

for (let i = 0; i < 4; i++) {

led.plot(car_x, car_y)

basic.pause(100)

led.unplot(car_x, car_y)

basic.pause(100)

led.plot(car_x, car_y)

}

basic.forever(function () {

while (play_start == 1) {

y_0_0 = y_1_0

y_0_1 = y_1_1

if (y_0_0 != 0 || y_0_1 != 0) {

if (show_0 == 1) {

score = score + 1

if (y_0_0 != car_y && y_0_1 != car_y) {

game_over_fun2()

}

for (let i_0 = 0; i_0 <= 4; i_0++) {

led.plot(x_0, i_0)

}

if (y_0_0 != car_y) {

led.unplot(x_0, y_0_0)

}

if (y_0_1 != car_y) {

led.unplot(x_0, y_0_1)

}

} else {

for (let i_02 = 0; i_02 <= 4; i_02++) {

led.unplot(x_0, i_02)

}

led.plot(car_x, car_y)

}

}

y_1_0 = y_2_0

y_1_1 = y_2_1

if (y_1_0 != 0 || y_1_1 != 0) {

if (show_1 == 1) {

for (let i_1 = 0; i_1 <= 4; i_1++) {

led.plot(x_1, i_1)

}

led.unplot(x_1, y_1_0)

led.unplot(x_1, y_1_1)

} else {

for (let i_12 = 0; i_12 <= 4; i_12++) {

led.unplot(x_1, i_12)

}

led.plot(car_x, car_y)

}

}

y_2_0 = y_3_0

y_2_1 = y_3_1

if (y_2_0 != 0 || y_2_1 != 0) {

if (show_2 == 1) {

for (let i_2 = 0; i_2 <= 4; i_2++) {

led.plot(x_2, i_2)

}

led.unplot(x_2, y_2_0)

led.unplot(x_2, y_2_1)

} else {

for (let i_22 = 0; i_22 <= 4; i_22++) {

led.unplot(x_2, i_22)

}

led.plot(car_x, car_y)

}

}

y_3_0 = y_4_0

y_3_1 = y_4_1

if (y_3_0 != 0 || y_3_1 != 0) {

if (show_3 == 1) {

for (let i_3 = 0; i_3 <= 4; i_3++) {

led.plot(x_3, i_3)

}

led.unplot(x_3, y_3_0)

led.unplot(x_3, y_3_1)

} else {

for (let i_32 = 0; i_32 <= 4; i_32++) {

led.unplot(x_3, i_32)

}

led.plot(car_x, car_y)

}

}

math = Math.randomRange(0, 2)

if (math == 0) {

if (r_org == 0) {

r_new = r_new + 1

} else {

r_new = r_org - 1

}

}

if (math == 1) {

r_new = r_org

}

if (math == 2) {

if (r_org == 4) {

r_new = r_new - 1

} else {

r_new = r_org + 1

}

}

if (r_new == 4) {

y_4_0 = r_new - 1

y_4_1 = r_new

} else {

y_4_0 = r_new

y_4_1 = r_new + 1

}

if (show_4 == 1) {

for (let i_4 = 0; i_4 <= 4; i_4++) {

led.plot(x_4, i_4)

}

led.unplot(x_4, y_4_0)

led.unplot(x_4, y_4_1)

} else {

for (let i_42 = 0; i_42 <= 4; i_42++) {

led.unplot(x_4, i_42)

}

led.plot(car_x, car_y)

}

show_0 = show_1

show_1 = show_2

show_2 = show_3

show_3 = show_4

if (show_4) {

show_4 = 0

} else {

show_4 = 1

}

r_org = r_new

if (score <= 20) {

basic.pause(600)

}

if (score > 20 && score <= 40) {

basic.pause(500)

}

if (score > 40 && score <= 60) {

basic.pause(400)

}

if (score > 60) {

basic.pause(300)

}

}

basic.pause(500)

while (play_start == -1 || play_start == 0) {

play_start = 0

score = 0

car_y = 0

car_x = 0

y_0_0 = 0

y_0_1 = 0

y_3_0 = 0

y_3_1 = 0

y_2_0 = 0

y_2_1 = 0

y_1_0 = 0

y_1_1 = 0

show_0 = 0

show_1 = 0

show_2 = 0

show_3 = 0

show_4 = 1

flag_a_key = 1

basic.showIcon(IconNames.Skull)

basic.showLeds(`

           . . . . .

           . . . . .

           . . . . .

           . . . . .

           . . . . .

           `)

}

basic.showLeds(`

       . . . . .

       . . . . .

       . . . . .

       . . . . .

       . . . . .

       `)

for (let i = 0; i < 4; i++) {

led.plot(car_x, car_y)

basic.pause(100)

led.unplot(car_x, car_y)

basic.pause(100)

led.plot(car_x, car_y)

}

r_org = Math.randomRange(0, 4)

if (r_org == 4) {

y_4_0 = r_org - 1

y_4_1 = r_org

} else {

y_4_0 = r_org

y_4_1 = r_org + 1

}

})

control.inBackground(function () {

while (true) {

if (play_start == 1) {

if (flag_a_key) {

led.unplot(car_x, car_y)

led.plot(car_x, car_y)

}

basic.pause(400)

if (flag_a_key) {

led.unplot(car_x, car_y)

car_y += 1

}

if (car_y > 4) {

game_over_fun2()

}

} else {

basic.pause(100)

}

}

})




复制到Javascript编辑器里。


11 +1

评论