还是错了QwQ,明明看起来都没事

P1000 超级玛丽游戏

mxyywjc @ 2024-07-24 11:00:10

# 可见输出有四个东西:马里奥、金币、地面、水管

# 思路是创建一个字符画板,然后把这些贴图粘上去

# 字符画布类,创建一个空白的字符版
class charCanvas:
    def __init__(self,width,height):
        self.width = width
        self.height = height
        self.data = [list(' '*height) for count in range(0,width)]
    # 粘贴符号图片
    def paste(self,x,y,picture):
        startX = x
        startY = y
        height = len(picture)
        if y + height > self.height:
            height -= y + height - self.height
        width = len(picture[0])
        if x + width > self.width:
            width -= x + width - self.width
        for y in range(startY,startY + height):
            for x in range(startX,startX + width):
                self.data[x][y] = picture[y - startY][x - startX]
    # 显示画布
    def show(self):
        for y in range(0,self.height):
            for x in range(0,self.width):
                print(self.data[x][y],end='')
            print()

# 马里奥
mario = [
    '     ********        ',
    '    ************     ',
    '    ####....#.       ',
    '  #..###.....##....  ',
    '  ###.......######   ',
    '     ...........     ',
    '    ##*#######       ',
    ' ####*******######   ',
    '...#***.****.*###....',
    '....**********##.....',
    '....****    *****....',
    '  ####        ####   ',
    '######        ###### '
]
# 金币
gold = [
    ' ### ',
    '#...#',
    '#.#.#',
    '#.#.#',
    '#...#',
    ' ### '
]
# 地面
ground = [
    '##########################################',
    '#...#......#.##...#......#.##...#......#.#',
    '##########################################',
    '#..#....#....##..#....#....##..#....#....#',
    '##########################################',
    '#.....#......##.....#......##.....#......#',
    '##########################################',
    '#.#..#....#..##.#..#....#..##.#..#....#..#',
    '##########################################'
]
# 水管
pipe = [
    '####################',
    '#------------------#',
    '#------------------#',
    '####################',
    '    #----------#    ',
    '    #----------#    ',
    '    #----------#    ',
    '    #----------#    ',
    '    ############    '
]

# 一张草稿纸
paper = charCanvas(62,22)
paper.paste(10,0,mario)
paper.paste(42,4,gold)
paper.paste(57,4,gold)
paper.paste(0,13,ground)
paper.paste(42,13,pipe)
paper.show()

by Crab_Tang @ 2024-07-24 11:06:20

@mxyywjc 6


by lihaoda @ 2024-07-24 11:07:36

用这么多东西多复杂呀,PHP复制上直接AC


by mxyywjc @ 2024-07-24 11:08:37

@Crab_Tang 不6 QwQ


by ikunTLE @ 2024-07-24 11:17:35

@mxyywjc 看着不管用,左边的是你的


by ikunTLE @ 2024-07-24 11:18:20

@mxyywjc 少了空格


by mxyywjc @ 2024-07-24 13:56:52

@ikunTLE 。。。。


by tangyiqi @ 2024-07-25 14:19:19

@mxyywjc
你可以用我的

#include <bits/stdc++.h>
using namespace std;
int main() {
    cout<<"                ********\n";
    cout<<"               ************\n";
    cout<<"               ####....#.\n             #..###.....##....\n";
    cout<<"             ###.......######              ###            ###\n";
    cout<<"                ...........               #...#          #...#\n";
    cout<<"               ##*#######                 #.#.#          #.#.#\n";
    cout<<"            ####*******######             #.#.#          #.#.#\n";
    cout<<"           ...#***.****.*###....          #...#          #...#\n";
    cout<<"           ....**********##.....           ###            ###\n";
    cout<<"           ....****    *****....\n             ####        ####\n";
    cout<<"           ######        ######\n##############################################################\n";
    cout<<"#...#......#.##...#......#.##...#......#.##------------------#\n";
    cout<<"###########################################------------------#\n";
    cout<<"#..#....#....##..#....#....##..#....#....#####################\n";
    cout<<"##########################################    #----------#\n";
    cout<<"#.....#......##.....#......##.....#......#    #----------#\n";
    cout<<"##########################################    #----------#\n";
    cout<<"#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#\n";
    cout<<"##########################################    ############";
    return 0;
}

求关,谢谢!


|