用户:
WMoSo岛同号查看:3 回复:4 评论:3 创建时间:2021-10-17T17:31:05
最近我的代码又出问题了,难道是……

这些是具体代码……头晕!
import arcade
SCREEN_HEIGHT = 652
SCREEN_WIDTH = 827
SCREEN_TITLE = '我的房子'
class Road(path):
def __init__(self, image):
super().__init__(image)
self.road=road
img=Sprite(road)
self.img.center_x = SCREEN_WIDTH//2
self.img.center_y = SCREEN_HEIGHT//2
class StatusBar():
def __init__(self):
self.distance = 0
self.hp = 2
def draw_bar(self):
arcade.draw_rectangle_filled(
SCREEN_WIDTH//2, SCREEN_HEIGHT-15, SCREEN_WIDTH, 30, arcade.color.BLUE
)
def draw_hp(self):
pos_x = SCREEN_WIDTH//2-50
pos_y = SCREEN_HEIGHT-20
arcade.draw_text('血量:', pos_x, pos_y, arcade.color.WHITE,
font_name='simhei')
hearts = arcade.SpriteList()
for i in range(self.hp):
heart = arcade.Sprite('heart.png')
heart.center_x = pos_x+50+heart.width*i
heart.center_y = pos_y+5
hearts.append(heart)
hearts.draw()
class Program(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
center_x = SCREEN_WIDTH//2
center_y = SCREEN_HEIGHT//2
self.status=StatusBar()
self.road=Road('background.bmp')
def on_draw(self):
arcade.start_render()
self.status.draw_bar()
self.status.draw_hp()
if __name__ == '__main__':
game = Program(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
arcade.run()
伴雪纷飞import arcade
SCREEN_HEIGHT = 652
SCREEN_WIDTH = 827
SCREEN_TITLE = '我的房子'
class Road():
def __init__(self, image,path):
super().__init__(image)
self.road=road
self.img=Sprite(road)
self.img.center_x = SCREEN_WIDTH//2
self.img.center_y = SCREEN_HEIGHT//2
class StatusBar():
def __init__(self):
self.distance = 0
self.hp = 2
def draw_bar(self):
arcade.draw_rectangle_filled(
SCREEN_WIDTH//2, SCREEN_HEIGHT-15, SCREEN_WIDTH, 30, arcade.color.BLUE
)
def draw_hp(self):
pos_x = SCREEN_WIDTH//2-50
pos_y = SCREEN_HEIGHT-20
arcade.draw_text('血量:', pos_x, pos_y, arcade.color.WHITE,
font_name='simhei')
hearts = arcade.SpriteList()
for i in range(self.hp):
heart = arcade.Sprite('heart.png')
heart.center_x = pos_x+50+heart.width*i
heart.center_y = pos_y+5
hearts.append(heart)
hearts.draw()
class Program(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
center_x = SCREEN_WIDTH//2
center_y = SCREEN_HEIGHT//2
self.status=StatusBar()
self.road=Road('background.bmp')
def on_draw(self):
arcade.start_render()
self.status.draw_bar()
self.status.draw_hp()
if __name__ == '__main__':
game = Program(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
arcade.run()
这可能是你想改动的
点赞0
评论