猫史档案馆


麟_月

麟_月

Lv.1

获赞:141收藏:43浏览:1482作品收藏:2

签名:

回复帖子评论
上一页3 页 / 共 7下一页

嗨嗨嗨——喵小妙招2 中回复

{\__/}

( • . •) / >👍 你看到这个赞了吗

{\__/}

( • - •) 👍🔥< \ 烧了也不给你

{\__/}

( • . •) / >👍 开玩笑啦给你给你

{\__/}

( • - •) 👍< \ 我又抢回来了

 

2022-06-15T12:46:31 点赞:0

凤凰图(4783需) 中回复

可以

2022-06-18T11:09:36 点赞:0

神岛历代特性 中回复

我全知道emotion_doge

2022-06-18T14:21:27 点赞:0

请问这是什么语言 中回复

js,因为有var

2022-06-18T14:23:01 点赞:0

小游戏~~ 中回复

批示,老师,看么,评论

2022-06-18T14:25:37 点赞:0

【Python作品分享】 忍者大乱斗 中回复

import pgzrun
import random

WIDTH = 1280
HEIGHT = 720
ninja = [Actor('lucas_r', (200, 540)),
         Actor('roger_l', (1080, 540))]
dart = [Actor('dart', (-50, 100)),
        Actor('dart', (-50, 100))]
hp_bar = [Actor('hpl10', (370, 60)),
          Actor('hpr10', (910, 60))]
character = [Actor('ninja_head_l', (100, 70)),
             Actor('ninja_head_r', (1180, 70))]
heart = Actor('heart', (喵0, -2000))
mp_bar = [Actor('mpl3', (260, 90)),
          Actor('mpr3', (1020, 90))]

jump_speed = [10, 10]
dart_speed = [18, -18]
jump = [False, False]
shoot = [False, False]
init_pos = [(100, 100), (100, 100)]
hp = [10, 10]
game_state = 'start'
direction = ['R', 'L']
mp = [12, 12]


def draw():
    global game_state, hp, mp
    if game_state == 'start':
        screen.blit('background', (0, 0))
        screen.blit('cover', (320, 210))
        if keyboard.space:
            game_state = 'play'
    elif game_state == 'play':
        screen.blit('background', (0, 0))
        for i in range(2):
            ninja[i].draw()
            dart[i].draw()
            hp_bar[i].draw()
            character[i].draw()
            mp_bar[i].draw()
        heart.draw()
    else:
        screen.blit('background', (0, 0))
        for i in range(2):
            ninja[i].draw()
        screen.draw.text('GAME OVER!', (495, 270),
                         color='red', fontsize=70)
        winner = 'Ninja Lucas '
        if hp[1] > hp[0]:
            winner = 'Ninja Roger '
        screen.draw.text(winner + 'wins',
                         (510, 340), fontsize=50)
        screen.draw.text('press SPACE to restart',
                         (520, 390), fontsize=36)
        if keyboard.space:
            game_state = 'play'
            hp = [10, 10]
            hp_bar[0].image = 'hpl10'
            hp_bar[1].image = 'hpr10'
            mp = [12, 12]
            mp_bar[0].image = 'mpl3'
            mp_bar[1].image = 'mpr3'


def attack(index):
    global shoot, init_pos, dart, direction, dart_speed
    init_pos[index] = ninja[index].x, ninja[index].y + 10
    dart[index].pos = init_pos[index]
    shoot[index] = True
    if direction[index] == 'R':
        dart_speed[index] = 18
    else:
        dart_speed[index] = -18


def collision_detect(ninj, dar, index):
    global hp
    if ninj.collidepoint(dar.pos):
        if hp[index] > 0:
            hp[index] -= 1
            sounds.hit.play()
        dar.x = WIDTH + 200
        dar.y = HEIGHT - 100
        if index == 0:
            hp_bar[index].image = 'hpl' + str(hp[index])
        else:
            hp_bar[index].image = 'hpr' + str(hp[index])


def update():
    global game_state, jump, init_pos, jump_speed, shoot, hp, \
        dart_speed, direction
    if game_state == 'play':
        if keyboard.d:
            ninja[0].x += 6
            ninja[0].image = 'lucas_r'
            direction[0] = 'R'
        elif keyboard.a:
            ninja[0].x -= 6
            ninja[0].image = 'lucas_l'
            direction[0] = 'L'
        if keyboard.right:
            ninja[1].x += 6
            ninja[1].image = 'roger_r'
            direction[1] = 'R'
        elif keyboard.left:
            ninja[1].x -= 6
            ninja[1].image = 'roger_l'
            direction[1] = 'L'

        if keyboard.w:
            jump[0] = True
        if keyboard.up:
            jump[1] = True

        if keyboard.v:
            dart[0].image = 'dart'
            attack(0)
        if keyboard.m:
            dart[1].image = 'dart'
            attack(1)

        if keyboard.r:
            if mp[0] >= 12:
                dart[0].image = 'big_dart'
                mp[0] = 0
                mp_bar[0].image = 'mpl0'
                attack(0)
        if keyboard.j:
            if mp[1] >= 12:
                dart[1].image = 'big_dart'
                mp[1] = 0
                mp_bar[1].image = 'mpr0'
                attack(1)

        for i in range(2):
            if jump[i]:
                if ninja[i].y <= 540:
                    ninja[i].y -= jump_speed[i]
                    jump_speed[i] -= 0.3
                else:
                    ninja[i].y = 540
                    jump[i] = False
                    jump_speed[i] = 12
            if shoot[i]:
                if dart[i].x < WIDTH + 50 and dart[i].x > -50:
                    dart[i].x += dart_speed[i]
                    dart[i].angle += 8

            if ninja[i].x < 50:
                ninja[i].x = 50
            elif ninja[i].x > WIDTH - 50:
                ninja[i].x = WIDTH - 50

            if hp[i] == 0:
                game_state = 'game over'

        collision_detect(ninja[1], dart[0], 1)
        collision_detect(ninja[0], dart[1], 0)

        heart.y += 6
        if heart.y > HEIGHT + 50:
            heart.y = random.randint(-5000, -2000)

        for i in range(2):
            if ninja[i].collidepoint(heart.pos):
                if hp[i] < 10:
                    hp[i] += 1
                    if i == 0:
                        hp_bar[i].image = 'hpl' + str(hp[i])
                    else:
                        hp_bar[i].image = 'hpr' + str(hp[i])
                    sounds.powerup.play()
                heart.y = random.randint(-5000, -2000)

            if mp[i] < 12:
                mp[i] += 0.01
                if i == 0:
                    mp_bar[i].image = 'mpl' + str(int(mp[i] // 4))
                else:
                    mp_bar[i].image = 'mpr' + str(int(mp[i] // 4))

        if keyboard.f:
            if mp[0] >= 12:
                mp[0] = 0
                if direction[0] == 'L':
                    ninja[0].x -= 400
                else:
                    ninja[0].x += 400
        if keyboard.n:
            if mp[1] >= 12:
                mp[1] = 0
                if direction[1] == 'L':
                    ninja[1].x -= 400
                else:
                    ninja[1].x += 400


pgzrun.go()

2022-06-19T15:15:36 点赞:0

怎么办我们学校好像闹鬼了 中回复

额。

2022-06-21T12:10:36 点赞:0

【API 教程三连更】 吉吉喵化身电工师傅 中回复

ddd

2022-06-21T12:33:40 点赞:0

本乌鸦也来测测知名度~(跟风ing) 中回复

2022-06-22T17:03:27 点赞:0

[Box3]官方这能不能封号? 中回复

??????

2022-06-23T20:49:47 点赞:1

如何注销账号 中回复

点我名字,再点又边的黄色按扭

2022-06-24T20:29:21 点赞:0

关于本室作品的现状总结 中回复

     

2022-06-25T14:01:07 点赞:0

【我是scoratch高级会员,爵士兵兵长,编程联合司通员(同时有两个及以上编程软件权位的人的... 中回复

2022/6/25 第23批考古队报道!

2022-06-25T15:24:19 点赞:0

【氵】讲述一下你的黑历史 中回复

挖  

2022-06-25T17:58:15 点赞:0

给室长的建议 中回复

挖 

2022-06-25T18:00:47 点赞:0

教你如何免费看会员电视 中回复

额,动漫有吗(我是1个斗粉emotion_doge

2022-06-26T11:26:51 点赞:0

氵盗版猫战 中回复

我这贴就是用coco发的emotion_doge

2022-06-26T14:14:51 点赞:1

在coco中用coco 中回复

center_image

2022-06-26T16:40:12 点赞:0

【浏览器】你们都用什么浏览器上编程猫的? 中回复

360

2022-06-26T20:47:06 点赞:0

不用F12就可以的无字天书! 中回复

                                                                      

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2022-06-27T17:40:00 点赞:2

数学函数问题 中回复

1个屑小学生点开了这贴

2022-06-28T12:33:57 点赞:0

不用F12就可以的无字天书! 中回复

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2022-06-29T17:26:23 点赞:0

【小游戏】当上帝创造你 中回复

加亿点恐怖

2022-06-30T16:25:51 点赞:0

谁没有以下宠物 中回复

1234567890

2022-06-30T16:33:47 点赞:0

如何做技能冷却 中回复

创建变量表示冷却时间,随便设个数,每秒减1,直到0

2022-07-01T11:21:33 点赞:1

求助代码师 中回复

呃,我个萌新……算了

2022-07-02T10:47:19 点赞:0

跟风测个知名度 中回复

2022-07-02T16:23:37 点赞:0

屑屑的教程——函数 中回复

  

2022-07-03T17:48:39 点赞:0

【7.5TC生日快乐】训练师送来生日祝福~ 中回复

生日快乐!

2022-07-05T16:36:48 点赞:0

【举报】挖坟的真是够了 中回复

《关于我挖坟发现拒绝挖坟的贴》

2022-07-05T16:38:09 点赞:0